dispatch/server/json.go

195 lines
2.6 KiB
Go
Raw Normal View History

package server
2015-01-17 01:37:21 +00:00
import (
"crypto/x509"
2018-05-25 21:54:36 +00:00
"github.com/mailru/easyjson"
"github.com/khlieng/dispatch/pkg/irc"
2015-12-11 03:35:48 +00:00
"github.com/khlieng/dispatch/storage"
2015-01-17 01:37:21 +00:00
)
type WSRequest struct {
2018-05-25 21:54:36 +00:00
Type string
Data easyjson.RawMessage
2015-01-17 01:37:21 +00:00
}
type WSResponse struct {
2018-05-25 21:54:36 +00:00
Type string
Data interface{}
2015-01-17 01:37:21 +00:00
}
type Server struct {
*storage.Server
2018-05-25 21:54:36 +00:00
Status ConnectionUpdate
}
type ServerName struct {
2018-05-25 21:54:36 +00:00
Server string
Name string
}
type ReconnectSettings struct {
2018-05-25 21:54:36 +00:00
Server string
SkipVerify bool
}
type ConnectionUpdate struct {
2018-05-25 21:54:36 +00:00
Server string
Connected bool
Error string
ErrorType string
}
func newConnectionUpdate(server string, state irc.ConnectionState) ConnectionUpdate {
status := ConnectionUpdate{
Server: server,
Connected: state.Connected,
}
if state.Error != nil {
status.Error = state.Error.Error()
if _, ok := state.Error.(x509.UnknownAuthorityError); ok {
status.ErrorType = "verify"
}
}
return status
2015-01-17 01:37:21 +00:00
}
type Nick struct {
2018-05-25 21:54:36 +00:00
Server string
Old string `json:"oldNick,omitempty"`
New string `json:"newNick,omitempty"`
}
type NickFail struct {
2018-05-25 21:54:36 +00:00
Server string
}
2015-01-17 01:37:21 +00:00
type Join struct {
2018-05-25 21:54:36 +00:00
Server string
User string
Channels []string
2015-01-17 01:37:21 +00:00
}
type Part struct {
2018-05-25 21:54:36 +00:00
Server string
User string
Channel string
Channels []string
Reason string
}
type Mode struct {
2018-05-25 21:54:36 +00:00
Server string
Channel string
User string
Add string
Remove string
}
type Quit struct {
2018-05-25 21:54:36 +00:00
Server string
User string
Reason string
}
type Message struct {
2018-05-25 21:54:36 +00:00
ID string
Server string
From string
To string
Content string
Type string
2015-01-17 01:37:21 +00:00
}
type Messages struct {
2018-05-25 21:54:36 +00:00
Server string
To string
Messages []storage.Message
Prepend bool
Next string
}
2015-01-17 01:37:21 +00:00
type Topic struct {
2018-05-25 21:54:36 +00:00
Server string
Channel string
Topic string
Nick string
2015-01-17 01:37:21 +00:00
}
type Userlist struct {
2018-05-25 21:54:36 +00:00
Server string
Channel string
Users []string
2015-01-17 01:37:21 +00:00
}
type MOTD struct {
2018-05-25 21:54:36 +00:00
Server string
Title string
Content []string
2015-01-17 01:37:21 +00:00
}
type Invite struct {
2018-05-25 21:54:36 +00:00
Server string
Channel string
User string
}
type Kick struct {
2018-05-25 21:54:36 +00:00
Server string
Channel string
User string
}
type Whois struct {
2018-05-25 21:54:36 +00:00
Server string
User string
}
type WhoisReply struct {
2018-05-25 21:54:36 +00:00
Nick string
Username string
Host string
Realname string
Server string
Channels []string
}
2015-02-21 12:06:05 +00:00
type Away struct {
2018-05-25 21:54:36 +00:00
Server string
Message string
2015-02-21 12:06:05 +00:00
}
2016-01-27 19:48:47 +00:00
type Raw struct {
2018-05-25 21:54:36 +00:00
Server string
Message string
2016-01-27 19:48:47 +00:00
}
type SearchRequest struct {
2018-05-25 21:54:36 +00:00
Server string
Channel string
Phrase string
}
type SearchResult struct {
2018-05-25 21:54:36 +00:00
Server string
Channel string
Results []storage.Message
}
2016-01-11 20:04:57 +00:00
type ClientCert struct {
2018-05-25 21:54:36 +00:00
Cert []byte
Key []byte
2016-01-11 20:04:57 +00:00
}
2017-05-02 21:21:25 +00:00
type FetchMessages struct {
2018-05-25 21:54:36 +00:00
Server string
Channel string
Next string
2017-05-02 21:21:25 +00:00
}
type Error struct {
2018-05-25 21:54:36 +00:00
Server string
Message string
}