2019-09-04 06:25:33 +00:00
|
|
|
package mailservers
|
|
|
|
|
|
|
|
import "context"
|
|
|
|
|
|
|
|
func NewAPI(db *Database) *API {
|
|
|
|
return &API{db}
|
|
|
|
}
|
|
|
|
|
|
|
|
// API is class with methods available over RPC.
|
|
|
|
type API struct {
|
|
|
|
db *Database
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) AddMailserver(ctx context.Context, m Mailserver) error {
|
|
|
|
return a.db.Add(m)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) GetMailservers(ctx context.Context) ([]Mailserver, error) {
|
|
|
|
return a.db.Mailservers()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) DeleteMailserver(ctx context.Context, id string) error {
|
|
|
|
return a.db.Delete(id)
|
|
|
|
}
|
2019-09-04 10:04:17 +00:00
|
|
|
|
|
|
|
func (a *API) AddMailserverRequestGaps(ctx context.Context, gaps []MailserverRequestGap) error {
|
|
|
|
return a.db.AddGaps(gaps)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) GetMailserverRequestGaps(ctx context.Context, chatID string) ([]MailserverRequestGap, error) {
|
2019-09-04 18:23:17 +00:00
|
|
|
return a.db.RequestGaps(chatID)
|
2019-09-04 10:04:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) DeleteMailserverRequestGaps(ctx context.Context, ids []string) error {
|
|
|
|
return a.db.DeleteGaps(ids)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) DeleteMailserverRequestGapsByChatID(ctx context.Context, chatID string) error {
|
|
|
|
return a.db.DeleteGapsByChatID(chatID)
|
|
|
|
}
|
2019-09-04 18:23:17 +00:00
|
|
|
|
|
|
|
func (a *API) AddMailserverTopic(ctx context.Context, topic MailserverTopic) error {
|
|
|
|
return a.db.AddTopic(topic)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) GetMailserverTopics(ctx context.Context) ([]MailserverTopic, error) {
|
|
|
|
return a.db.Topics()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) DeleteMailserverTopic(ctx context.Context, topic string) error {
|
|
|
|
return a.db.DeleteTopic(topic)
|
|
|
|
}
|
2019-09-06 13:02:31 +00:00
|
|
|
|
|
|
|
func (a *API) AddChatRequestRange(ctx context.Context, req ChatRequestRange) error {
|
|
|
|
return a.db.AddChatRequestRange(req)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) GetChatRequestRanges(ctx context.Context) ([]ChatRequestRange, error) {
|
|
|
|
return a.db.ChatRequestRanges()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *API) DeleteChatRequestRange(ctx context.Context, chatID string) error {
|
|
|
|
return a.db.DeleteChatRequestRange(chatID)
|
|
|
|
}
|