Merge branch 'v2.3.0release' of github.com:OpenIMSDK/Open-IM-Server into v2.3.0release

pull/351/head
wangchuxiao 2 years ago
commit 2cad8a879d

@ -6,6 +6,7 @@ import (
"Open_IM/pkg/common/db" "Open_IM/pkg/common/db"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"context" "context"
go_redis "github.com/go-redis/redis/v8"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -85,6 +86,20 @@ func (f *Fcm) Push(accounts []string, title, detailContent, operationID string,
if err == nil { if err == nil {
apns.Payload.Aps.Badge = &unreadCountSum apns.Payload.Aps.Badge = &unreadCountSum
} else { } else {
log.Error(operationID, "IncrUserBadgeUnreadCountSum redis err", err.Error(), uid)
Fail++
continue
}
} else {
unreadCountSum, err := db.DB.GetUserBadgeUnreadCountSum(uid)
if err == nil && unreadCountSum != 0 {
apns.Payload.Aps.Badge = &unreadCountSum
} else if err == go_redis.Nil || unreadCountSum == 0 {
zero := 1
apns.Payload.Aps.Badge = &zero
} else {
log.Error(operationID, "GetUserBadgeUnreadCountSum redis err", err.Error(), uid)
Fail++
continue continue
} }
} }

@ -429,3 +429,8 @@ func (d *DataBases) SetUserBadgeUnreadCountSum(uid string, value int) error {
key := userBadgeUnreadCountSum + uid key := userBadgeUnreadCountSum + uid
return d.RDB.Set(context.Background(), key, value, 0).Err() return d.RDB.Set(context.Background(), key, value, 0).Err()
} }
func (d *DataBases) GetUserBadgeUnreadCountSum(uid string) (int, error) {
key := userBadgeUnreadCountSum + uid
seq, err := d.RDB.Get(context.Background(), key).Result()
return utils.StringToInt(seq), err
}

Loading…
Cancel
Save