新增 firebase cloud message 消息推送 (#236)

* 新增 firebase cloud message 消息推送

新增 api接口  /third/fcm_update_token 用于更新客户端获取到 FCM token 同步到服务器

* mongodb授权缺少授权数据库

windows下面的编译+启动
This commit is contained in:
欧阳氏
2022-07-25 17:07:47 +08:00
committed by GitHub
parent c94fb80cb0
commit 84c068783d
12 changed files with 602 additions and 7 deletions
+11
View File
@@ -35,6 +35,7 @@ const (
SignalCache = "SIGNAL_CACHE:"
SignalListCache = "SIGNAL_LIST_CACHE:"
GlobalMsgRecvOpt = "GLOBAL_MSG_RECV_OPT"
FcmToken = "FCM_TOKEN:"
)
@@ -427,3 +428,13 @@ func (d *DataBases) GetUserInfoFromCache(userID string) (*pbCommon.UserInfo, err
err = json.Unmarshal(bytes, userInfo)
return userInfo, err
}
func (d *DataBases) SetFcmToken(account string, platformid int, fcmToken string, expireTime int64) (err error) {
key := FcmToken + account + ":" + strconv.Itoa(platformid)
return d.rdb.Set(context.Background(), key, fcmToken, time.Duration(expireTime)*time.Second).Err()
}
func (d *DataBases) GetFcmToken(account string, platformid int) (string, error) {
key := FcmToken + account + ":" + strconv.Itoa(platformid)
return d.rdb.Get(context.Background(), key).Result()
}