-
Notifications
You must be signed in to change notification settings - Fork 249
/
api.go
72 lines (54 loc) · 1.92 KB
/
api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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)
}
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) {
return a.db.RequestGaps(chatID)
}
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)
}
func (a *API) AddMailserverTopic(ctx context.Context, topic MailserverTopic) error {
return a.db.AddTopic(topic)
}
func (a *API) AddMailserverTopics(ctx context.Context, topics []MailserverTopic) error {
return a.db.AddTopics(topics)
}
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)
}
func (a *API) AddChatRequestRange(ctx context.Context, req ChatRequestRange) error {
return a.db.AddChatRequestRange(req)
}
func (a *API) AddChatRequestRanges(ctx context.Context, reqs []ChatRequestRange) error {
return a.db.AddChatRequestRanges(reqs)
}
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)
}