2015-04-29 21:54:44 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
2018-05-31 21:24:59 +00:00
|
|
|
"github.com/khlieng/dispatch/pkg/session"
|
2015-04-29 21:54:44 +00:00
|
|
|
)
|
|
|
|
|
2018-05-31 21:24:59 +00:00
|
|
|
var Path directory
|
2015-04-29 21:54:44 +00:00
|
|
|
|
2016-01-07 22:59:38 +00:00
|
|
|
func Initialize(dir string) {
|
|
|
|
Path = directory(dir)
|
|
|
|
}
|
|
|
|
|
2018-05-31 21:24:59 +00:00
|
|
|
type Store interface {
|
|
|
|
GetUsers() ([]User, error)
|
|
|
|
SaveUser(*User) error
|
|
|
|
DeleteUser(*User) error
|
2015-04-29 21:54:44 +00:00
|
|
|
|
2018-05-31 21:24:59 +00:00
|
|
|
GetServers(*User) ([]Server, error)
|
|
|
|
AddServer(*User, *Server) error
|
|
|
|
RemoveServer(*User, string) error
|
|
|
|
SetNick(*User, string, string) error
|
|
|
|
SetServerName(*User, string, string) error
|
2015-04-29 21:54:44 +00:00
|
|
|
|
2018-05-31 21:24:59 +00:00
|
|
|
GetChannels(*User) ([]Channel, error)
|
|
|
|
AddChannel(*User, *Channel) error
|
|
|
|
RemoveChannel(*User, string, string) error
|
2015-04-29 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
2018-05-31 21:24:59 +00:00
|
|
|
type SessionStore interface {
|
|
|
|
GetSessions() ([]session.Session, error)
|
|
|
|
SaveSession(session *session.Session) error
|
|
|
|
DeleteSession(key string) error
|
2015-04-29 21:54:44 +00:00
|
|
|
}
|
2016-01-15 01:27:30 +00:00
|
|
|
|
2018-05-31 21:24:59 +00:00
|
|
|
type MessageStore interface {
|
|
|
|
LogMessage(message *Message) error
|
|
|
|
GetMessages(server, channel string, count int, fromID string) ([]Message, bool, error)
|
|
|
|
GetMessagesByID(server, channel string, ids []string) ([]Message, error)
|
|
|
|
Close()
|
2016-01-15 01:27:30 +00:00
|
|
|
}
|
|
|
|
|
2018-05-31 21:24:59 +00:00
|
|
|
type MessageSearchProvider interface {
|
|
|
|
SearchMessages(server, channel, q string) ([]string, error)
|
|
|
|
Index(id string, message *Message) error
|
|
|
|
Close()
|
2016-01-15 01:27:30 +00:00
|
|
|
}
|