From a87c16de0d318f4054d33831c921d16095f7e1a0 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Tue, 2 Nov 2021 12:00:24 +0800 Subject: [PATCH] push fix --- src/push/logic/push_to_client.go | 58 +++++++++++--------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/src/push/logic/push_to_client.go b/src/push/logic/push_to_client.go index df125c5c1..09c4c36e8 100644 --- a/src/push/logic/push_to_client.go +++ b/src/push/logic/push_to_client.go @@ -31,7 +31,6 @@ type EChatContent struct { func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) { var wsResult []*pbRelay.SingleMsgToUser - isShouldOfflinePush := true MOptions := utils.JsonStringToMap(Options) //Control whether to push message to sender's other terminal //isSenderSync := utils.GetSwitchFromOptions(MOptions, "senderSync") isOfflinePush := utils.GetSwitchFromOptions(MOptions, "offlinePush") @@ -51,50 +50,31 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) { } log.InfoByKv("push_result", sendPbData.OperationID, "result", wsResult, "sendData", sendPbData) if isOfflinePush { - - for _, t := range pushTerminal { - for _, v := range wsResult { - if v.RecvPlatFormID == t && v.ResultCode == 0 { - isShouldOfflinePush = false - break - } + for _, v := range wsResult { + if v.ResultCode == 0 { + continue } - if isShouldOfflinePush { - //Use offline push messaging - var UIDList []string - UIDList = append(UIDList, sendPbData.RecvID) - customContent := EChatContent{ - SessionType: int(sendPbData.SessionType), - From: sendPbData.SendID, - To: sendPbData.RecvID, - Seq: sendPbData.RecvSeq, - } - bCustomContent, _ := json.Marshal(customContent) + //supported terminal + for _, t := range pushTerminal { + if v.RecvPlatFormID == t { + //Use offline push messaging + var UIDList []string + UIDList = append(UIDList, sendPbData.RecvID) + customContent := EChatContent{ + SessionType: int(sendPbData.SessionType), + From: sendPbData.SendID, + To: sendPbData.RecvID, + Seq: sendPbData.RecvSeq, + } + bCustomContent, _ := json.Marshal(customContent) + jsonCustomContent := string(bCustomContent) + push.JGAccountListPush(UIDList, jsonCustomContent, utils.PlatformIDToName(t)) - jsonCustomContent := string(bCustomContent) - //switch sendPbData.ContentType { - //case constant.Text: - // IOSAccountListPush(UIDList, sendPbData.SenderNickName, sendPbData.Content, jsonCustomContent) - //case constant.Picture: - // IOSAccountListPush(UIDList, sendPbData.SenderNickName, constant.ContentType2PushContent[constant.Picture], jsonCustomContent) - //case constant.Voice: - // IOSAccountListPush(UIDList, sendPbData.SenderNickName, constant.ContentType2PushContent[constant.Voice], jsonCustomContent) - //case constant.Video: - // IOSAccountListPush(UIDList, sendPbData.SenderNickName, constant.ContentType2PushContent[constant.Video], jsonCustomContent) - //case constant.File: - // IOSAccountListPush(UIDList, sendPbData.SenderNickName, constant.ContentType2PushContent[constant.File], jsonCustomContent) - //default: - // - //} - push.JGAccountListPush(UIDList, jsonCustomContent, utils.PlatformIDToName(t)) - - } else { - isShouldOfflinePush = true + } } } } - } func SendMsgByWS(m *pbChat.WSToMsgSvrChatMsg) {