forked from Zhuguoping/jackal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroster.go
66 lines (55 loc) · 2.94 KB
/
roster.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
package storage
import "github.com/ortuman/jackal/model/rostermodel"
// rosterStorage defines storage oprations for user's roster
type rosterStorage interface {
InsertOrUpdateRosterItem(ri *rostermodel.Item) (rostermodel.Version, error)
DeleteRosterItem(username, jid string) (rostermodel.Version, error)
FetchRosterItems(username string) ([]rostermodel.Item, rostermodel.Version, error)
FetchRosterItemsInGroups(username string, groups []string) ([]rostermodel.Item, rostermodel.Version, error)
FetchRosterItem(username, jid string) (*rostermodel.Item, error)
InsertOrUpdateRosterNotification(rn *rostermodel.Notification) error
DeleteRosterNotification(contact, jid string) error
FetchRosterNotification(contact string, jid string) (*rostermodel.Notification, error)
FetchRosterNotifications(contact string) ([]rostermodel.Notification, error)
}
// InsertOrUpdateRosterItem inserts a new roster item entity into storage,
// or updates it in case it's been previously inserted.
func InsertOrUpdateRosterItem(ri *rostermodel.Item) (rostermodel.Version, error) {
return instance().InsertOrUpdateRosterItem(ri)
}
// DeleteRosterItem deletes a roster item entity from storage.
func DeleteRosterItem(username, jid string) (rostermodel.Version, error) {
return instance().DeleteRosterItem(username, jid)
}
// FetchRosterItems retrieves from storage all roster item entities
// associated to a given user.
func FetchRosterItems(username string) ([]rostermodel.Item, rostermodel.Version, error) {
return instance().FetchRosterItems(username)
}
// FetchRosterItemsInGroups retrieves from storage all roster item entities
// associated to a given user and a set of groups.
func FetchRosterItemsInGroups(username string, groups []string) ([]rostermodel.Item, rostermodel.Version, error) {
return instance().FetchRosterItemsInGroups(username, groups)
}
// FetchRosterItem retrieves from storage a roster item entity.
func FetchRosterItem(username, jid string) (*rostermodel.Item, error) {
return instance().FetchRosterItem(username, jid)
}
// InsertOrUpdateRosterNotification inserts a new roster notification entity
// into storage, or updates it in case it's been previously inserted.
func InsertOrUpdateRosterNotification(rn *rostermodel.Notification) error {
return instance().InsertOrUpdateRosterNotification(rn)
}
// DeleteRosterNotification deletes a roster notification entity from storage.
func DeleteRosterNotification(contact, jid string) error {
return instance().DeleteRosterNotification(contact, jid)
}
// FetchRosterNotification retrieves from storage a roster notification entity.
func FetchRosterNotification(contact string, jid string) (*rostermodel.Notification, error) {
return instance().FetchRosterNotification(contact, jid)
}
// FetchRosterNotifications retrieves from storage all roster notifications
// associated to a given user.
func FetchRosterNotifications(contact string) ([]rostermodel.Notification, error) {
return instance().FetchRosterNotifications(contact)
}