2015-05-01 20:59:46 +00:00
|
|
|
package server
|
2015-01-17 01:37:21 +00:00
|
|
|
|
|
|
|
import (
|
2017-07-04 09:28:56 +00:00
|
|
|
"crypto/x509"
|
2018-05-25 21:54:36 +00:00
|
|
|
|
|
|
|
"github.com/mailru/easyjson"
|
2015-05-10 23:09:59 +00:00
|
|
|
|
2018-05-31 21:24:59 +00:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
2017-07-02 01:31:00 +00:00
|
|
|
type Server struct {
|
2018-06-01 02:16:38 +00:00
|
|
|
*storage.Server
|
2019-01-27 07:53:07 +00:00
|
|
|
Status ConnectionUpdate
|
|
|
|
Features map[string]interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Features struct {
|
|
|
|
Server string
|
|
|
|
Features map[string]interface{}
|
2017-07-02 01:31:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ServerName struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
Name string
|
2017-07-02 01:31:00 +00:00
|
|
|
}
|
|
|
|
|
2017-07-04 09:28:56 +00:00
|
|
|
type ReconnectSettings struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
SkipVerify bool
|
2017-07-04 09:28:56 +00:00
|
|
|
}
|
|
|
|
|
2017-07-02 01:31:00 +00:00
|
|
|
type ConnectionUpdate struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
Connected bool
|
|
|
|
Error string
|
|
|
|
ErrorType string
|
2017-07-02 01:31:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func newConnectionUpdate(server string, state irc.ConnectionState) ConnectionUpdate {
|
|
|
|
status := ConnectionUpdate{
|
|
|
|
Server: server,
|
|
|
|
Connected: state.Connected,
|
|
|
|
}
|
|
|
|
if state.Error != nil {
|
|
|
|
status.Error = state.Error.Error()
|
2017-07-04 09:28:56 +00:00
|
|
|
if _, ok := state.Error.(x509.UnknownAuthorityError); ok {
|
|
|
|
status.ErrorType = "verify"
|
|
|
|
}
|
2017-07-02 01:31:00 +00:00
|
|
|
}
|
|
|
|
return status
|
2015-01-17 01:37:21 +00:00
|
|
|
}
|
|
|
|
|
2015-01-31 22:35:38 +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"`
|
2017-06-21 05:23:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type NickFail struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
2015-01-31 22:35:38 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-02-01 00:56:56 +00:00
|
|
|
type Part struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
User string
|
|
|
|
Channel string
|
|
|
|
Channels []string
|
|
|
|
Reason string
|
2015-02-01 00:56:56 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 01:35:46 +00:00
|
|
|
type Mode struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
Channel string
|
|
|
|
User string
|
|
|
|
Add string
|
|
|
|
Remove string
|
2015-01-25 01:35:46 +00:00
|
|
|
}
|
|
|
|
|
2015-01-21 02:06:34 +00:00
|
|
|
type Quit struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
User string
|
|
|
|
Reason string
|
2015-01-21 02:06:34 +00:00
|
|
|
}
|
|
|
|
|
2017-04-17 20:36:37 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2017-04-19 23:51:55 +00:00
|
|
|
type Messages struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
To string
|
|
|
|
Messages []storage.Message
|
|
|
|
Prepend bool
|
|
|
|
Next string
|
2017-04-19 23:51:55 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
2015-01-29 23:38:51 +00:00
|
|
|
|
2015-02-10 01:25:28 +00:00
|
|
|
type Invite struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
Channel string
|
|
|
|
User string
|
2015-02-10 01:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Kick struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
Channel string
|
|
|
|
User string
|
2015-02-10 01:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Whois struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
User string
|
2015-02-10 01:25:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-10 01:25:28 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-05-10 23:09:59 +00:00
|
|
|
type SearchRequest struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
Channel string
|
|
|
|
Phrase string
|
2015-05-10 23:09:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type SearchResult struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
Channel string
|
|
|
|
Results []storage.Message
|
2015-05-10 23:09:59 +00:00
|
|
|
}
|
|
|
|
|
2016-01-11 20:04:57 +00:00
|
|
|
type ClientCert struct {
|
2018-10-10 19:23:42 +00:00
|
|
|
Cert string
|
|
|
|
Key string
|
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
|
|
|
}
|
|
|
|
|
2015-01-29 23:38:51 +00:00
|
|
|
type Error struct {
|
2018-05-25 21:54:36 +00:00
|
|
|
Server string
|
|
|
|
Message string
|
2015-01-29 23:38:51 +00:00
|
|
|
}
|
2019-01-23 06:34:39 +00:00
|
|
|
|
2019-01-25 10:02:31 +00:00
|
|
|
type IRCError struct {
|
|
|
|
Server string
|
|
|
|
Target string
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2019-01-23 06:34:39 +00:00
|
|
|
type ChannelSearch struct {
|
|
|
|
Server string
|
|
|
|
Q string
|
|
|
|
Start int
|
|
|
|
}
|
|
|
|
|
|
|
|
type ChannelSearchResult struct {
|
2020-05-03 07:05:16 +00:00
|
|
|
ChannelSearch
|
2019-01-23 06:34:39 +00:00
|
|
|
Results []*storage.ChannelListItem
|
|
|
|
}
|
2019-01-25 10:02:31 +00:00
|
|
|
|
|
|
|
type ChannelForward struct {
|
|
|
|
Server string
|
|
|
|
Old string
|
|
|
|
New string
|
|
|
|
}
|
2020-05-06 02:19:55 +00:00
|
|
|
|
|
|
|
type Tab struct {
|
|
|
|
storage.Tab
|
|
|
|
}
|