-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify.go
45 lines (43 loc) · 1.38 KB
/
notify.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
package task
import (
"github.com/0RAJA/Rutils/pkg/utils"
"github.com/0RAJA/chat_app/src/dao"
"github.com/0RAJA/chat_app/src/global"
"github.com/0RAJA/chat_app/src/model"
"github.com/0RAJA/chat_app/src/model/chat"
"github.com/0RAJA/chat_app/src/model/chat/server"
)
func CreateNotify(accessToken string, accountID, relationID int64, msgContent string, msgExtend *model.MsgExtend) func() {
ctx, cancel := global.DefaultContextWithTimeOut()
defer cancel()
members, err := dao.Group.DB.GetGroupMembers(ctx, relationID)
if err != nil {
global.Logger.Error(err.Error())
}
return func() {
global.ChatMap.SendMany(members, chat.ServerCreateNotify, server.CreateNotify{
EnToken: utils.EncodeMD5(accessToken),
AccountID: accountID,
RelationID: relationID,
MsgContent: msgContent,
MsgExtent: msgExtend,
})
}
}
func UpdateNotify(accessToken string, accountID, relationID int64, msgContent string, msgExtend *model.MsgExtend) func() {
ctx, cancel := global.DefaultContextWithTimeOut()
defer cancel()
members, err := dao.Group.DB.GetGroupMembers(ctx, relationID)
if err != nil {
global.Logger.Error(err.Error())
}
return func() {
global.ChatMap.SendMany(members, chat.ServerUpdateNotify, server.CreateNotify{
EnToken: utils.EncodeMD5(accessToken),
AccountID: accountID,
RelationID: relationID,
MsgContent: msgContent,
MsgExtent: msgExtend,
})
}
}