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

This commit is contained in:
wangchuxiao 2022-09-01 21:18:46 +08:00
commit ac2cc154b4
14 changed files with 217 additions and 199 deletions

View File

@ -5,7 +5,6 @@ import (
"Open_IM/pkg/common/config" "Open_IM/pkg/common/config"
"Open_IM/pkg/common/db" "Open_IM/pkg/common/db"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
"Open_IM/pkg/tools/splitter"
"context" "context"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -47,53 +46,68 @@ func newFcmClient() *Fcm {
return &Fcm{FcmMsgCli: fcmMsgClient} return &Fcm{FcmMsgCli: fcmMsgClient}
} }
func (f *Fcm) Push(accounts []string, alert, detailContent, operationID string, opts push.PushOpts) (string, error) { func (f *Fcm) Push(accounts []string, title, detailContent, operationID string, opts push.PushOpts) (string, error) {
// accounts->registrationToken // accounts->registrationToken
Tokens := make([]string, 0) allTokens := make(map[string][]string, 0)
for _, account := range accounts { for _, account := range accounts {
IosfcmToken, IosErr := db.DB.GetFcmToken(account, 1) var personTokens []string
AndroidfcmToken, AndroidErr := db.DB.GetFcmToken(account, 2) for _, v := range push.PushTerminal {
Token, err := db.DB.GetFcmToken(account, v)
if IosErr == nil { if err == nil {
Tokens = append(Tokens, IosfcmToken) personTokens = append(personTokens, Token)
} }
if AndroidErr == nil {
Tokens = append(Tokens, AndroidfcmToken)
} }
allTokens[account] = personTokens
} }
Success := 0 Success := 0
Fail := 0 Fail := 0
result := splitter.NewSplitter(SinglePushCountLimit, Tokens).GetSplitResult() notification := &messaging.Notification{}
Msg := new(messaging.MulticastMessage) notification.Body = detailContent
Msg.Notification = &messaging.Notification{} notification.Title = title
Msg.Notification.Body = detailContent var messages []*messaging.Message
Msg.Notification.Title = alert
Msg.APNS = &messaging.APNSConfig{Payload: &messaging.APNSPayload{Aps: &messaging.Aps{}}}
if opts.IOSBadgeCount {
i := 1
Msg.APNS.Payload.Aps.Badge = &i
}
if opts.IOSPushSound != "" {
Msg.APNS.Payload.Aps.Sound = opts.IOSPushSound
}
ctx := context.Background() ctx := context.Background()
for _, v := range result { apns := &messaging.APNSConfig{Payload: &messaging.APNSPayload{Aps: &messaging.Aps{Sound: opts.IOSPushSound}}}
Msg.Tokens = v.Item for uid, personTokens := range allTokens {
//SendMulticast sends the given multicast message to all the FCM registration tokens specified. messageCount := len(messages)
//The tokens array in MulticastMessage may contain up to 500 tokens. if messageCount >= SinglePushCountLimit {
//SendMulticast uses the `SendAll()` function to send the given message to all the target recipients. response, err := f.FcmMsgCli.SendAll(ctx, messages)
//The responses list obtained from the return value corresponds to the order of the input tokens.
//An error from SendMulticast indicates a total failure -- i.e.
//the message could not be sent to any of the recipients.
//Partial failures are indicated by a `BatchResponse` return value.
response, err := f.FcmMsgCli.SendMulticast(ctx, Msg)
if err != nil { if err != nil {
Fail = Fail + len(v.Item) Fail = Fail + messageCount
log.Info(operationID, "some token push err", err.Error(), len(v.Item)) log.Info(operationID, "some token push err", err.Error(), messageCount)
continue } else {
}
Success = Success + response.SuccessCount Success = Success + response.SuccessCount
Fail = Fail + response.FailureCount Fail = Fail + response.FailureCount
} }
messages = messages[0:0]
}
if opts.IOSBadgeCount {
unreadCountSum, err := db.DB.IncrUserBadgeUnreadCountSum(uid)
if err == nil {
apns.Payload.Aps.Badge = &unreadCountSum
} else {
continue
}
}
for _, token := range personTokens {
temp := &messaging.Message{
Token: token,
Notification: notification,
APNS: apns,
}
messages = append(messages, temp)
}
}
messageCount := len(messages)
if messageCount > 0 {
response, err := f.FcmMsgCli.SendAll(ctx, messages)
if err != nil {
Fail = Fail + messageCount
log.Info(operationID, "some token push err", err.Error(), messageCount)
} else {
Success = Success + response.SuccessCount
Fail = Fail + response.FailureCount
}
}
return strconv.Itoa(Success) + " Success," + strconv.Itoa(Fail) + " Fail", nil return strconv.Itoa(Success) + " Success," + strconv.Itoa(Fail) + " Fail", nil
} }

View File

@ -112,7 +112,7 @@ func newGetuiClient() *Getui {
return &Getui{} return &Getui{}
} }
func (g *Getui) Push(userIDList []string, alert, detailContent, operationID string, opts push.PushOpts) (resp string, err error) { func (g *Getui) Push(userIDList []string, title, detailContent, operationID string, opts push.PushOpts) (resp string, err error) {
token, err := db.DB.GetGetuiToken() token, err := db.DB.GetGetuiToken()
log.NewDebug(operationID, utils.GetSelfFuncName(), "token", token) log.NewDebug(operationID, utils.GetSelfFuncName(), "token", token)
if err != nil { if err != nil {
@ -132,18 +132,18 @@ func (g *Getui) Push(userIDList []string, alert, detailContent, operationID stri
}{Alias: []string{userIDList[0]}}, }{Alias: []string{userIDList[0]}},
} }
pushReq.PushMessage.Notification = Notification{ pushReq.PushMessage.Notification = Notification{
Title: alert, Title: title,
Body: detailContent, Body: detailContent,
ClickType: "startapp", ClickType: "startapp",
} }
pushReq.PushChannel.Ios.Aps.Sound = "default" pushReq.PushChannel.Ios.Aps.Sound = "default"
pushReq.PushChannel.Ios.Aps.Alert = Alert{ pushReq.PushChannel.Ios.Aps.Alert = Alert{
Title: alert, Title: title,
Body: alert, Body: title,
} }
pushReq.PushChannel.Android.Ups.Notification = Notification{ pushReq.PushChannel.Android.Ups.Notification = Notification{
Title: alert, Title: title,
Body: alert, Body: title,
ClickType: "startapp", ClickType: "startapp",
} }
pushReq.PushChannel.Android.Ups.Options = Options{ pushReq.PushChannel.Android.Ups.Options = Options{

View File

@ -33,7 +33,7 @@ func (j *JPush) SetAlias(cid, alias string) (resp string, err error) {
return resp, nil return resp, nil
} }
func (j *JPush) Push(accounts []string, alert, detailContent, operationID string, opts push.PushOpts) (string, error) { func (j *JPush) Push(accounts []string, title, detailContent, operationID string, opts push.PushOpts) (string, error) {
var pf requestBody.Platform var pf requestBody.Platform
pf.SetAll() pf.SetAll()
@ -47,7 +47,7 @@ func (j *JPush) Push(accounts []string, alert, detailContent, operationID string
} }
no.IOSEnableMutableContent() no.IOSEnableMutableContent()
no.SetExtras(extras) no.SetExtras(extras)
no.SetAlert(alert) no.SetAlert(title)
var me requestBody.Message var me requestBody.Message
me.SetMsgContent(detailContent) me.SetMsgContent(detailContent)
var o requestBody.Options var o requestBody.Options

View File

@ -12,7 +12,7 @@ import (
http2 "net/http" http2 "net/http"
) )
func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData, offlinePushUserIDList *[]string, offlineInfo *commonPb.OfflinePushInfo) cbApi.CommonCallbackResp { func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.MsgData, offlinePushUserIDList *[]string) cbApi.CommonCallbackResp {
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID} callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
if !config.Config.Callback.CallbackOfflinePush.Enable { if !config.Config.Callback.CallbackOfflinePush.Enable {
return callbackResp return callbackResp
@ -52,7 +52,7 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
*offlinePushUserIDList = resp.UserIDList *offlinePushUserIDList = resp.UserIDList
} }
if resp.OfflinePushInfo != nil { if resp.OfflinePushInfo != nil {
*offlineInfo = *resp.OfflinePushInfo msg.OfflinePushInfo = resp.OfflinePushInfo
} }
} }
log.NewDebug(operationID, utils.GetSelfFuncName(), offlinePushUserIDList, resp.UserIDList) log.NewDebug(operationID, utils.GetSelfFuncName(), offlinePushUserIDList, resp.UserIDList)

View File

@ -21,7 +21,6 @@ import (
var ( var (
rpcServer RPCServer rpcServer RPCServer
pushCh PushConsumerHandler pushCh PushConsumerHandler
pushTerminal []int32
producer *kafka.Producer producer *kafka.Producer
offlinePusher pusher.OfflinePusher offlinePusher pusher.OfflinePusher
successCount uint64 successCount uint64
@ -30,7 +29,6 @@ var (
func Init(rpcPort int) { func Init(rpcPort int) {
rpcServer.Init(rpcPort) rpcServer.Init(rpcPort)
pushCh.Init() pushCh.Init()
pushTerminal = []int32{constant.IOSPlatformID, constant.AndroidPlatformID}
} }
func init() { func init() {

View File

@ -17,10 +17,8 @@ import (
pbPush "Open_IM/pkg/proto/push" pbPush "Open_IM/pkg/proto/push"
pbRelay "Open_IM/pkg/proto/relay" pbRelay "Open_IM/pkg/proto/relay"
pbRtc "Open_IM/pkg/proto/rtc" pbRtc "Open_IM/pkg/proto/rtc"
commonPb "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"encoding/json"
"strings" "strings"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
@ -85,48 +83,8 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
return return
} }
} }
customContent := OpenIMContent{ var title, detailContent string
SessionType: int(pushMsg.MsgData.SessionType), callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{})
From: pushMsg.MsgData.SendID,
To: pushMsg.MsgData.RecvID,
Seq: pushMsg.MsgData.Seq,
}
bCustomContent, _ := json.Marshal(customContent)
jsonCustomContent := string(bCustomContent)
var content string
if pushMsg.MsgData.OfflinePushInfo != nil {
content = pushMsg.MsgData.OfflinePushInfo.Title
jsonCustomContent = pushMsg.MsgData.OfflinePushInfo.Desc
}
if content == "" {
switch pushMsg.MsgData.ContentType {
case constant.Text:
content = constant.ContentType2PushContent[constant.Text]
case constant.Picture:
content = constant.ContentType2PushContent[constant.Picture]
case constant.Voice:
content = constant.ContentType2PushContent[constant.Voice]
case constant.Video:
content = constant.ContentType2PushContent[constant.Video]
case constant.File:
content = constant.ContentType2PushContent[constant.File]
case constant.AtText:
a := AtContent{}
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
} else {
content = constant.ContentType2PushContent[constant.GroupMsg]
}
case constant.SignalingNotification:
content = constant.ContentType2PushContent[constant.SignalMsg]
default:
content = constant.ContentType2PushContent[constant.Common]
}
}
var offlineInfo commonPb.OfflinePushInfo
callbackResp := callbackOfflinePush(pushMsg.OperationID, UIDList, pushMsg.MsgData, &[]string{}, &offlineInfo)
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp") log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
if callbackResp.ErrCode != 0 { if callbackResp.ErrCode != 0 {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp) log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
@ -135,12 +93,11 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop") log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
return return
} }
if offlineInfo.Title != "" { if pushMsg.MsgData.OfflinePushInfo != nil {
content = offlineInfo.Title title = pushMsg.MsgData.OfflinePushInfo.Title
} detailContent = pushMsg.MsgData.OfflinePushInfo.Desc
if offlineInfo.Desc != "" {
jsonCustomContent = offlineInfo.Desc
} }
if offlinePusher == nil { if offlinePusher == nil {
return return
} }
@ -148,8 +105,36 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
if err != nil { if err != nil {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error()) log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
} }
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, content, jsonCustomContent, "opts:", opts) log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, title, detailContent, "opts:", opts)
pushResult, err := offlinePusher.Push(UIDList, content, jsonCustomContent, pushMsg.OperationID, opts) if title == "" {
switch pushMsg.MsgData.ContentType {
case constant.Text:
fallthrough
case constant.Picture:
fallthrough
case constant.Voice:
fallthrough
case constant.Video:
fallthrough
case constant.File:
title = constant.ContentType2PushContent[int64(pushMsg.MsgData.ContentType)]
case constant.AtText:
a := AtContent{}
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
title = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
} else {
title = constant.ContentType2PushContent[constant.GroupMsg]
}
case constant.SignalingNotification:
title = constant.ContentType2PushContent[constant.SignalMsg]
default:
title = constant.ContentType2PushContent[constant.Common]
}
detailContent = title
}
pushResult, err := offlinePusher.Push(UIDList, title, detailContent, pushMsg.OperationID, opts)
if err != nil { if err != nil {
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error()) log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
} else { } else {
@ -229,51 +214,11 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
} }
onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, pushToUserIDList) onlineFailedUserIDList := utils.DifferenceString(onlineSuccessUserIDList, pushToUserIDList)
//Use offline push messaging //Use offline push messaging
customContent := OpenIMContent{ var title, detailContent string
SessionType: int(pushMsg.MsgData.SessionType),
From: pushMsg.MsgData.SendID,
To: pushMsg.MsgData.RecvID,
Seq: pushMsg.MsgData.Seq,
}
bCustomContent, _ := json.Marshal(customContent)
jsonCustomContent := string(bCustomContent)
var content string
if pushMsg.MsgData.OfflinePushInfo != nil {
content = pushMsg.MsgData.OfflinePushInfo.Title
jsonCustomContent = pushMsg.MsgData.OfflinePushInfo.Desc
} else {
switch pushMsg.MsgData.ContentType {
case constant.Text:
content = constant.ContentType2PushContent[constant.Text]
case constant.Picture:
content = constant.ContentType2PushContent[constant.Picture]
case constant.Voice:
content = constant.ContentType2PushContent[constant.Voice]
case constant.Video:
content = constant.ContentType2PushContent[constant.Video]
case constant.File:
content = constant.ContentType2PushContent[constant.File]
case constant.AtText:
a := AtContent{}
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
content = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
} else {
content = constant.ContentType2PushContent[constant.GroupMsg]
}
case constant.SignalingNotification:
content = constant.ContentType2PushContent[constant.SignalMsg]
default:
content = constant.ContentType2PushContent[constant.Common]
}
}
if len(onlineFailedUserIDList) > 0 { if len(onlineFailedUserIDList) > 0 {
var offlinePushUserIDList []string var offlinePushUserIDList []string
var needOfflinePushUserIDList []string var needOfflinePushUserIDList []string
var offlineInfo commonPb.OfflinePushInfo callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData, &offlinePushUserIDList)
callbackResp := callbackOfflinePush(pushMsg.OperationID, onlineFailedUserIDList, pushMsg.MsgData, &offlinePushUserIDList, &offlineInfo)
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp") log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offline callback Resp")
if callbackResp.ErrCode != 0 { if callbackResp.ErrCode != 0 {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp) log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "callbackOfflinePush result: ", callbackResp)
@ -282,17 +227,16 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop") log.NewDebug(pushMsg.OperationID, utils.GetSelfFuncName(), "offlinePush stop")
return return
} }
if pushMsg.MsgData.OfflinePushInfo != nil {
title = pushMsg.MsgData.OfflinePushInfo.Title
detailContent = pushMsg.MsgData.OfflinePushInfo.Desc
}
if len(offlinePushUserIDList) > 0 { if len(offlinePushUserIDList) > 0 {
needOfflinePushUserIDList = offlinePushUserIDList needOfflinePushUserIDList = offlinePushUserIDList
} else { } else {
needOfflinePushUserIDList = onlineFailedUserIDList needOfflinePushUserIDList = onlineFailedUserIDList
} }
if offlineInfo.Title != "" {
content = offlineInfo.Title
}
if offlineInfo.Desc != "" {
jsonCustomContent = offlineInfo.Desc
}
if offlinePusher == nil { if offlinePusher == nil {
return return
} }
@ -300,8 +244,36 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
if err != nil { if err != nil {
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error()) log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetOfflinePushOpts failed", pushMsg, err.Error())
} }
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), onlineFailedUserIDList, content, jsonCustomContent, "opts:", opts) log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), onlineFailedUserIDList, title, detailContent, "opts:", opts)
pushResult, err := offlinePusher.Push(needOfflinePushUserIDList, content, jsonCustomContent, pushMsg.OperationID, opts) if title == "" {
switch pushMsg.MsgData.ContentType {
case constant.Text:
fallthrough
case constant.Picture:
fallthrough
case constant.Voice:
fallthrough
case constant.Video:
fallthrough
case constant.File:
title = constant.ContentType2PushContent[int64(pushMsg.MsgData.ContentType)]
case constant.AtText:
a := AtContent{}
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
title = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
} else {
title = constant.ContentType2PushContent[constant.GroupMsg]
}
case constant.SignalingNotification:
title = constant.ContentType2PushContent[constant.SignalMsg]
default:
title = constant.ContentType2PushContent[constant.Common]
}
detailContent = title
}
pushResult, err := offlinePusher.Push(needOfflinePushUserIDList, title, detailContent, pushMsg.OperationID, opts)
if err != nil { if err != nil {
log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error()) log.NewError(pushMsg.OperationID, "offline push error", pushMsg.String(), err.Error())
} else { } else {

View File

@ -1,7 +1,11 @@
package push package push
import "Open_IM/pkg/common/constant"
var PushTerminal = []int{constant.IOSPlatformID, constant.AndroidPlatformID}
type OfflinePusher interface { type OfflinePusher interface {
Push(userIDList []string, alert, detailContent, operationID string, opts PushOpts) (resp string, err error) Push(userIDList []string, title, detailContent, operationID string, opts PushOpts) (resp string, err error)
} }
type PushOpts struct { type PushOpts struct {

View File

@ -74,7 +74,15 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"attached_info": conversation.AttachedInfo}) err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"attached_info": conversation.AttachedInfo})
case constant.FieldUnread: case constant.FieldUnread:
isSyncConversation = false isSyncConversation = false
err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"update_unread_count_time": utils.GetCurrentTimestampByMill()}) err = imdb.UpdateColumnsConversations(haveUserID, req.Conversation.ConversationID, map[string]interface{}{"update_unread_count_time": conversation.UpdateUnreadCountTime})
for _, v := range req.UserIDList {
if err = db.DB.SetUserBadgeUnreadCountSum(v, int(req.BadgeUnreadCountSum)); err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetUserBadgeUnreadCountSum, rpc return", err.Error())
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
return resp, nil
}
}
} }
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateColumnsConversations error", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateColumnsConversations error", err.Error())
@ -83,7 +91,6 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
} }
for _, v := range utils.DifferenceString(haveUserID, req.UserIDList) { for _, v := range utils.DifferenceString(haveUserID, req.UserIDList) {
conversation.OwnerUserID = v conversation.OwnerUserID = v
conversation.UpdateUnreadCountTime = utils.GetCurrentTimestampByMill()
err = rocksCache.DelUserConversationIDListFromCache(v) err = rocksCache.DelUserConversationIDListFromCache(v)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), v, req.Conversation.ConversationID, err.Error())

View File

@ -18,7 +18,7 @@ type GroupMemberUserIDListHash struct {
UserIDList []string UserIDList []string
} }
var CacheGroupMemberUserIDList map[string]*GroupMemberUserIDListHash = make(map[string]*GroupMemberUserIDListHash, 0) var CacheGroupMemberUserIDList = make(map[string]*GroupMemberUserIDListHash, 0)
var CacheGroupMtx sync.RWMutex var CacheGroupMtx sync.RWMutex
func GetGroupMemberUserIDList(groupID string, operationID string) ([]string, error) { func GetGroupMemberUserIDList(groupID string, operationID string) ([]string, error) {

View File

@ -63,6 +63,7 @@ type ModifyConversationFieldReq struct {
Conversation Conversation
FieldType int32 `json:"fieldType" binding:"required"` FieldType int32 `json:"fieldType" binding:"required"`
UserIDList []string `json:"userIDList" binding:"required"` UserIDList []string `json:"userIDList" binding:"required"`
BadgeUnreadCountSum int32 `json:"badgeUnreadCountSum"`
OperationID string `json:"operationID" binding:"required"` OperationID string `json:"operationID" binding:"required"`
} }
type ModifyConversationFieldResp struct { type ModifyConversationFieldResp struct {

View File

@ -37,6 +37,7 @@ const (
groupMaxSeq = "GROUP_MAX_SEQ:" groupMaxSeq = "GROUP_MAX_SEQ:"
groupMinSeq = "GROUP_MIN_SEQ:" groupMinSeq = "GROUP_MIN_SEQ:"
sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:" sendMsgFailedFlag = "SEND_MSG_FAILED_FLAG:"
userBadgeUnreadCountSum = "USER_BADGE_UNREAD_COUNT_SUM:"
) )
func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) { func (d *DataBases) JudgeAccountEXISTS(account string) (bool, error) {
@ -411,3 +412,12 @@ func (d *DataBases) GetFcmToken(account string, platformid int) (string, error)
key := FcmToken + account + ":" + strconv.Itoa(platformid) key := FcmToken + account + ":" + strconv.Itoa(platformid)
return d.RDB.Get(context.Background(), key).Result() return d.RDB.Get(context.Background(), key).Result()
} }
func (d *DataBases) IncrUserBadgeUnreadCountSum(uid string) (int, error) {
key := userBadgeUnreadCountSum + uid
seq, err := d.RDB.Incr(context.Background(), key).Result()
return int(seq), err
}
func (d *DataBases) SetUserBadgeUnreadCountSum(uid string, value int) error {
key := userBadgeUnreadCountSum + uid
return d.RDB.Set(context.Background(), key, value, 0).Err()
}

View File

@ -35,6 +35,7 @@ func loggerInit(moduleName string) *Logger {
//All logs will be printed //All logs will be printed
logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel)) logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel))
//Close std console output //Close std console output
//os.O_WRONLY | os.O_CREATE | os.O_APPEND
src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend) src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// source: conversation/conversation.proto // source: conversation/conversation.proto
package conversation // import "./conversation" package conversation // import "Open_IM/pkg/proto/conversation"
import proto "github.com/golang/protobuf/proto" import proto "github.com/golang/protobuf/proto"
import fmt "fmt" import fmt "fmt"
@ -35,7 +35,7 @@ func (m *CommonResp) Reset() { *m = CommonResp{} }
func (m *CommonResp) String() string { return proto.CompactTextString(m) } func (m *CommonResp) String() string { return proto.CompactTextString(m) }
func (*CommonResp) ProtoMessage() {} func (*CommonResp) ProtoMessage() {}
func (*CommonResp) Descriptor() ([]byte, []int) { func (*CommonResp) Descriptor() ([]byte, []int) {
return fileDescriptor_conversation_ac55165355a1b6e6, []int{0} return fileDescriptor_conversation_f01d9caff8d16987, []int{0}
} }
func (m *CommonResp) XXX_Unmarshal(b []byte) error { func (m *CommonResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_CommonResp.Unmarshal(m, b) return xxx_messageInfo_CommonResp.Unmarshal(m, b)
@ -94,7 +94,7 @@ func (m *Conversation) Reset() { *m = Conversation{} }
func (m *Conversation) String() string { return proto.CompactTextString(m) } func (m *Conversation) String() string { return proto.CompactTextString(m) }
func (*Conversation) ProtoMessage() {} func (*Conversation) ProtoMessage() {}
func (*Conversation) Descriptor() ([]byte, []int) { func (*Conversation) Descriptor() ([]byte, []int) {
return fileDescriptor_conversation_ac55165355a1b6e6, []int{1} return fileDescriptor_conversation_f01d9caff8d16987, []int{1}
} }
func (m *Conversation) XXX_Unmarshal(b []byte) error { func (m *Conversation) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Conversation.Unmarshal(m, b) return xxx_messageInfo_Conversation.Unmarshal(m, b)
@ -224,6 +224,7 @@ type ModifyConversationFieldReq struct {
FieldType int32 `protobuf:"varint,2,opt,name=fieldType" json:"fieldType,omitempty"` FieldType int32 `protobuf:"varint,2,opt,name=fieldType" json:"fieldType,omitempty"`
UserIDList []string `protobuf:"bytes,3,rep,name=userIDList" json:"userIDList,omitempty"` UserIDList []string `protobuf:"bytes,3,rep,name=userIDList" json:"userIDList,omitempty"`
OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"` OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"`
BadgeUnreadCountSum int32 `protobuf:"varint,5,opt,name=badgeUnreadCountSum" json:"badgeUnreadCountSum,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -233,7 +234,7 @@ func (m *ModifyConversationFieldReq) Reset() { *m = ModifyConversationFi
func (m *ModifyConversationFieldReq) String() string { return proto.CompactTextString(m) } func (m *ModifyConversationFieldReq) String() string { return proto.CompactTextString(m) }
func (*ModifyConversationFieldReq) ProtoMessage() {} func (*ModifyConversationFieldReq) ProtoMessage() {}
func (*ModifyConversationFieldReq) Descriptor() ([]byte, []int) { func (*ModifyConversationFieldReq) Descriptor() ([]byte, []int) {
return fileDescriptor_conversation_ac55165355a1b6e6, []int{2} return fileDescriptor_conversation_f01d9caff8d16987, []int{2}
} }
func (m *ModifyConversationFieldReq) XXX_Unmarshal(b []byte) error { func (m *ModifyConversationFieldReq) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ModifyConversationFieldReq.Unmarshal(m, b) return xxx_messageInfo_ModifyConversationFieldReq.Unmarshal(m, b)
@ -281,6 +282,13 @@ func (m *ModifyConversationFieldReq) GetOperationID() string {
return "" return ""
} }
func (m *ModifyConversationFieldReq) GetBadgeUnreadCountSum() int32 {
if m != nil {
return m.BadgeUnreadCountSum
}
return 0
}
type ModifyConversationFieldResp struct { type ModifyConversationFieldResp struct {
CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"` CommonResp *CommonResp `protobuf:"bytes,1,opt,name=commonResp" json:"commonResp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
@ -292,7 +300,7 @@ func (m *ModifyConversationFieldResp) Reset() { *m = ModifyConversationF
func (m *ModifyConversationFieldResp) String() string { return proto.CompactTextString(m) } func (m *ModifyConversationFieldResp) String() string { return proto.CompactTextString(m) }
func (*ModifyConversationFieldResp) ProtoMessage() {} func (*ModifyConversationFieldResp) ProtoMessage() {}
func (*ModifyConversationFieldResp) Descriptor() ([]byte, []int) { func (*ModifyConversationFieldResp) Descriptor() ([]byte, []int) {
return fileDescriptor_conversation_ac55165355a1b6e6, []int{3} return fileDescriptor_conversation_f01d9caff8d16987, []int{3}
} }
func (m *ModifyConversationFieldResp) XXX_Unmarshal(b []byte) error { func (m *ModifyConversationFieldResp) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_ModifyConversationFieldResp.Unmarshal(m, b) return xxx_messageInfo_ModifyConversationFieldResp.Unmarshal(m, b)
@ -399,40 +407,42 @@ var _Conversation_serviceDesc = grpc.ServiceDesc{
} }
func init() { func init() {
proto.RegisterFile("conversation/conversation.proto", fileDescriptor_conversation_ac55165355a1b6e6) proto.RegisterFile("conversation/conversation.proto", fileDescriptor_conversation_f01d9caff8d16987)
} }
var fileDescriptor_conversation_ac55165355a1b6e6 = []byte{ var fileDescriptor_conversation_f01d9caff8d16987 = []byte{
// 494 bytes of a gzipped FileDescriptorProto // 513 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x5f, 0x8b, 0x13, 0x31, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x5d, 0x8b, 0x13, 0x3f,
0x14, 0xc5, 0x99, 0x6e, 0xb7, 0xdb, 0xde, 0x76, 0xab, 0x04, 0xd4, 0xd0, 0xf5, 0x4f, 0x19, 0x44, 0x18, 0xc5, 0x99, 0xbe, 0x6d, 0xfb, 0xb4, 0xdb, 0xff, 0x9f, 0x88, 0x1a, 0xba, 0xbe, 0x94, 0x22,
0x46, 0x1f, 0x2a, 0xac, 0x3e, 0x08, 0xc2, 0x82, 0x4e, 0x51, 0x06, 0xac, 0x2e, 0xa1, 0x8b, 0xe0, 0x32, 0x7a, 0x51, 0x65, 0xf5, 0x42, 0x10, 0x16, 0xb4, 0x45, 0x19, 0xb0, 0xba, 0xc4, 0x2e, 0x82,
0xdb, 0xd8, 0xb9, 0xed, 0x06, 0x6c, 0x32, 0x26, 0x99, 0xda, 0x7d, 0xf1, 0x33, 0xf8, 0x81, 0xfc, 0x77, 0xb3, 0x9d, 0xa7, 0xdd, 0x80, 0x4d, 0xc6, 0x24, 0x53, 0xbb, 0x37, 0x7e, 0x06, 0x3f, 0xa9,
0x70, 0x92, 0x4c, 0xbb, 0x4d, 0x56, 0x0b, 0x3e, 0xde, 0x5f, 0xee, 0x9c, 0x9c, 0x33, 0x3d,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b1, 0x74, 0xbd, 0xa9, 0xb3, 0x9b, 0x96, 0x06, 0x5f, 0xe0, 0x68, 0x6f, 0x5e, 0x9d, 0x93, 0x57,
0x02, 0xee, 0xed, 0xb9, 0x88, 0x24, 0xa1, 0xe0, 0xfe, 0xb7, 0x39, 0x78, 0xfa, 0x9f, 0x9b, 0xba, 0x00, 0xb3, 0xab, 0xbf, 0xd8, 0x26, 0x2e, 0xbd, 0x1e, 0x77, 0xbb, 0xce, 0xbc, 0xbd, 0xc7, 0x3f,
0x7c, 0xfb, 0xe0, 0xcb, 0xc9, 0x28, 0xf8, 0x20, 0xbc, 0xf6, 0x87, 0xaf, 0x2d, 0xf7, 0x79, 0x78, 0xc3, 0xab, 0x22, 0x02, 0xee, 0xee, 0x39, 0x88, 0xc4, 0xa1, 0xe0, 0xfe, 0xfb, 0xef, 0x3d, 0xf9,
0xf1, 0x27, 0x00, 0x00, 0xff, 0xff, 0x12, 0x56, 0xaa, 0x7b, 0x41, 0x04, 0x00, 0x00, 0xc7, 0x9d, 0x3a, 0x7f, 0x7b, 0xff, 0xeb, 0xd1, 0x30, 0x78, 0x42, 0x5e, 0xfb, 0xc3, 0x79, 0xc3,
0x3d, 0x28, 0x2f, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x9a, 0xf4, 0x2a, 0xa6, 0x73, 0x04, 0x00,
0x00,
} }

View File

@ -29,6 +29,7 @@ message ModifyConversationFieldReq{
int32 fieldType = 2; int32 fieldType = 2;
repeated string userIDList = 3; repeated string userIDList = 3;
string operationID = 4; string operationID = 4;
int32 badgeUnreadCountSum = 5;
} }
message ModifyConversationFieldResp{ message ModifyConversationFieldResp{