This repository has been archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotification.go
77 lines (64 loc) · 2.18 KB
/
notification.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
73
74
75
76
77
package twocloud
import (
"errors"
"time"
)
type Notification struct {
ID uint64 `json:"id,omitempty"`
Nature string `json:"nature,omitempty"`
Body string `json:"body,omitempty"`
Unread bool `json:"unread,omitempty"`
ReadBy uint64 `json:"read_by,omitempty"`
TimeRead time.Time `json:"time_read,omitempty"`
Sent time.Time `json:"sent,omitempty"`
Destination uint64 `json:"owner,omitempty"`
DestinationType string `json:"owner_type,omitempty"`
}
type BroadcastFilter struct {
Targets string `json:"targets,omitempty"`
ClientType []string `json:"client_type,omitempty"`
}
func (b *BroadcastFilter) IsValid() bool {
if b.Targets != "devices" && b.Targets != "users" {
return false
}
for _, t := range b.ClientType {
for _, clientType := range validClientTypes {
if t == clientType {
continue
}
}
return false
}
return true
}
var InvalidBroadcastFilter = errors.New("Invalid broadcast filter.")
func (r *RequestBundle) GetNotificationsByDevice(device Device, before, after uint64, count int) ([]Notification, error) {
return []Notification{}, nil
}
func (r *RequestBundle) GetNotificationsByUser(user User, before, after uint64, count int) ([]Notification, error) {
return []Notification{}, nil
}
func (r *RequestBundle) GetNotification(id uint64) (Notification, error) {
return Notification{}, nil
}
func (r *RequestBundle) SendNotificationsToUser(user User, notification []Notification) ([]Notification, error) {
return []Notification{}, nil
}
func (r *RequestBundle) SendNotificationsToDevice(device Device, notification []Notification) ([]Notification, error) {
return []Notification{}, nil
}
func (r *RequestBundle) BroadcastNotifications(notifications []Notification, filter *BroadcastFilter) ([]Notification, error) {
if filter != nil {
if !filter.IsValid() {
return []Notification{}, InvalidBroadcastFilter
}
}
return []Notification{}, nil
}
func (r *RequestBundle) MarkNotificationRead(notification Notification) (Notification, error) {
return Notification{}, nil
}
func (r *RequestBundle) DeleteNotification(notification Notification) error {
return nil
}