-
Notifications
You must be signed in to change notification settings - Fork 0
/
push.go
77 lines (62 loc) · 1.63 KB
/
push.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 webhook
import (
"github.com/TangSengDaoDao/TangSengDaoDaoServerLib/common"
"github.com/TangSengDaoDao/TangSengDaoDaoServerLib/config"
"github.com/liyong2922/TangSengDaoDaoServer/modules/user"
)
// Payload 推送内容
type Payload interface {
GetTitle() string // 推送标题
GetContent() string // 推送正文
GetBadge() int // 推送红点
GetRTCPayload() RTCPayload // 获取rtc的payload
}
type RTCPayload interface {
GetCallType() common.RTCCallType // 音视频呼叫类型
GetOperation() string // 音视频操作 invite: 邀请音视频 cancel:取消邀请
GetFromUID() string // 发起人的uid
}
// BasePayload 基础负载
type BasePayload struct {
title string
content string
badge int
}
// GetTitle 推送标题
func (p *BasePayload) GetTitle() string {
return p.title
}
// GetContent 推送正文
func (p *BasePayload) GetContent() string {
return p.content
}
// GetBadge 推送红点
func (p *BasePayload) GetBadge() int {
return p.badge
}
func (p *BasePayload) GetRTCPayload() RTCPayload {
return nil
}
type BaseRTCPayload struct {
BasePayload
callType common.RTCCallType
operation string
fromUID string
}
func (b *BaseRTCPayload) GetCallType() common.RTCCallType {
return b.callType
}
func (b *BaseRTCPayload) GetOperation() string {
return b.operation
}
func (b *BaseRTCPayload) GetFromUID() string {
return b.fromUID
}
func (b *BaseRTCPayload) GetRTCPayload() RTCPayload {
return b
}
// Push Push
type Push interface {
GetPayload(msg msgOfflineNotify, ctx *config.Context, toUser *user.Resp) (Payload, error)
Push(deviceToken string, payload Payload) error
}