-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
39 lines (36 loc) · 1.12 KB
/
account.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
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/chat"
"github.com/0RAJA/chat_app/src/model/chat/server"
)
// UpdateAccount 更新账号信息通知
// 参数: 账号ID,更新后的账号信息
func UpdateAccount(accessToken string, accountID int64, name, gender, signature string) func() {
return func() {
global.ChatMap.Send(accountID, chat.ServerUpdateAccount, server.UpdateAccount{
EnToken: utils.EncodeMD5(accessToken),
Name: name,
Signature: signature,
Gender: gender,
})
}
}
// UpdateEmail 更新邮箱通知用户的每个账号
func UpdateEmail(accessToken string, userID int64, email string) func() {
return func() {
ctx, cancel := global.DefaultContextWithTimeOut()
defer cancel()
accountIDs, err := dao.Group.DB.GetAccountIDsByUserID(ctx, userID)
if err != nil {
global.Logger.Error(err.Error())
return
}
global.ChatMap.SendMany(accountIDs, chat.ServerUpdateEmail, server.UpdateEmail{
EnToken: utils.EncodeMD5(accessToken),
Email: email,
})
}
}