diff --git a/internal/api/third/fcm_update_token.go b/internal/api/third/fcm_update_token.go index a5a3a9d42..d9c5f03ff 100644 --- a/internal/api/third/fcm_update_token.go +++ b/internal/api/third/fcm_update_token.go @@ -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) diff --git a/internal/push/fcm/push.go b/internal/push/fcm/push.go index 3f0552d62..ac485a708 100644 --- a/internal/push/fcm/push.go +++ b/internal/push/fcm/push.go @@ -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) } diff --git a/internal/push/fcm/push_test.go b/internal/push/fcm/push_test.go new file mode 100644 index 000000000..caf09d947 --- /dev/null +++ b/internal/push/fcm/push_test.go @@ -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) +} diff --git a/pkg/common/db/redisModel_test.go b/pkg/common/db/redisModel_test.go index 66025f6ab..2f14b7fc2 100644 --- a/pkg/common/db/redisModel_test.go +++ b/pkg/common/db/redisModel_test.go @@ -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) +//}