Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release

pull/258/head
wenxu12345 2 years ago
commit efe727ec71

@ -39,7 +39,7 @@ func FcmUpdateToken(c *gin.Context) {
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), req, UserId)
//逻辑处理开始
err := db.DB.SetFcmToken(UserId, int(req.Platform), req.FcmToken, 0)
err := db.DB.SetFcmToken(UserId, req.Platform, req.FcmToken, 0)
if err != nil {
errMsg := req.OperationID + " " + "SetFcmToken failed " + err.Error() + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)

@ -50,6 +50,7 @@ func (f *Fcm) Push(accounts []string, alert, detailContent, operationID string,
for _, account := range accounts {
IosfcmToken, IosErr := db.DB.GetFcmToken(account, 1)
AndroidfcmToken, AndroidErr := db.DB.GetFcmToken(account, 2)
if IosErr == nil {
Tokens = append(Tokens, IosfcmToken)
}

@ -0,0 +1,15 @@
package fcm
import (
"Open_IM/internal/push"
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
func Test_Push(t *testing.T) {
offlinePusher := NewFcm()
resp, err := offlinePusher.Push([]string{"test_uid"}, "哈哈", "嘿嘿", "12321", push.PushOpts{})
assert.Nil(t, err)
fmt.Println(resp)
}

@ -35,7 +35,7 @@ func Test_GetKeyTTL(t *testing.T) {
ctx := context.Background()
key := flag.String("key", "key", "key value")
flag.Parse()
ttl, err := DB.rdb.TTL(ctx, *key).Result()
ttl, err := DB.RDB.TTL(ctx, *key).Result()
assert.Nil(t, err)
fmt.Println(ttl)
}
@ -43,7 +43,7 @@ func Test_HGetAll(t *testing.T) {
ctx := context.Background()
key := flag.String("key", "key", "key value")
flag.Parse()
ttl, err := DB.rdb.TTL(ctx, *key).Result()
ttl, err := DB.RDB.TTL(ctx, *key).Result()
assert.Nil(t, err)
fmt.Println(ttl)
}
@ -119,9 +119,17 @@ func Test_GetAccountCode(t *testing.T) {
assert.Nil(t, err)
fmt.Println(code)
}
func Test_GetGroupMemberList(t *testing.T) {
groupID := "3791742301"
list, err := DB.GetGroupMemberIDListFromCache(groupID)
func Test_SetFcmToken(t *testing.T) {
uid := "test_uid"
token := "dfnWBtOjSj-XIZnUvDlegv:APA91bG09XTtiXfpE6U7gUVMOhnKcUkNCv4WHn0UZr2clUi-tS1jEH-HiCEW8GIAhjLIGcfUJ6NIKteC023ZxDH7J0PJ5sTxoup3fHDUPLU7KgQoZS4tPyFqCbZ6bRB7esDPEnD1n_s0"
platformID := 2
err := DB.SetFcmToken(uid, platformID, token, 0)
assert.Nil(t, err)
fmt.Println(list)
}
//func Test_GetGroupMemberList(t *testing.T) {
// groupID := "3791742301"
// list, err := DB.GetGroupMemberIDListFromCache(groupID)
// assert.Nil(t, err)
// fmt.Println(list)
//}

Loading…
Cancel
Save