diff --git a/src/api/chat/send_msg.go b/src/api/chat/send_msg.go index ede81abdd..0ba888f29 100644 --- a/src/api/chat/send_msg.go +++ b/src/api/chat/send_msg.go @@ -67,7 +67,7 @@ func UserSendMsg(c *gin.Context) { token := c.Request.Header.Get("token") - log.InfoByKv("Ws call success to sendMsgReq", params.OperationID, "Parameters", params) + log.InfoByKv("api call success to sendMsgReq", params.OperationID, "Parameters", params) pbData := newUserSendMsgReq(token, ¶ms) log.Info("", "", "api UserSendMsg call start..., [data: %s]", pbData.String()) diff --git a/src/common/constant/constant.go b/src/common/constant/constant.go index 2d3d0d799..6f176cd51 100644 --- a/src/common/constant/constant.go +++ b/src/common/constant/constant.go @@ -26,15 +26,16 @@ const ( ///ContentType //UserRelated - Text = 101 - Picture = 102 - Voice = 103 - Video = 104 - File = 105 - AtText = 106 - Custom = 110 + Text = 101 + Picture = 102 + Voice = 103 + Video = 104 + File = 105 + AtText = 106 + Custom = 110 + HasReadReceipt = 112 + Typing = 113 - SyncSenderMsg = 108 //SysRelated AcceptFriendApplicationTip = 201 AddFriendTip = 202 diff --git a/src/push/logic/push_to_client.go b/src/push/logic/push_to_client.go index b424d6acb..dc28b2b21 100644 --- a/src/push/logic/push_to_client.go +++ b/src/push/logic/push_to_client.go @@ -14,13 +14,15 @@ import ( pbChat "Open_IM/src/proto/chat" pbGroup "Open_IM/src/proto/group" pbRelay "Open_IM/src/proto/relay" + push "Open_IM/src/push/jpush" rpcChat "Open_IM/src/rpc/chat/chat" "Open_IM/src/utils" "context" + "encoding/json" "strings" ) -type EChatContent struct { +type OpenIMContent struct { SessionType int `json:"chatType"` From string `json:"from"` To string `json:"to"` @@ -47,37 +49,40 @@ func MsgToUser(sendPbData *pbRelay.MsgToUserReq, OfflineInfo, Options string) { } } log.InfoByKv("push_result", sendPbData.OperationID, "result", wsResult, "sendData", sendPbData) - if isOfflinePush { - for _, v := range wsResult { - if v.ResultCode == 0 { - continue - } - //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) - //pushResult, err := push.JGAccountListPush(UIDList, jsonCustomContent, utils.PlatformIDToName(t)) - //if err != nil { - // log.NewError(sendPbData.OperationID, "offline push error", sendPbData.String(), err.Error(), t) - //} else { - // log.NewDebug(sendPbData.OperationID, "offline push return result is ", string(pushResult), sendPbData, t) - //} + if sendPbData.ContentType != constant.Typing && sendPbData.ContentType != constant.HasReadReceipt { + if isOfflinePush { + for _, v := range wsResult { + if v.ResultCode == 0 { + continue + } + //supported terminal + for _, t := range pushTerminal { + if v.RecvPlatFormID == t { + //Use offline push messaging + var UIDList []string + UIDList = append(UIDList, sendPbData.RecvID) + customContent := OpenIMContent{ + SessionType: int(sendPbData.SessionType), + From: sendPbData.SendID, + To: sendPbData.RecvID, + Seq: sendPbData.RecvSeq, + } + bCustomContent, _ := json.Marshal(customContent) + jsonCustomContent := string(bCustomContent) + pushResult, err := push.JGAccountListPush(UIDList, jsonCustomContent, utils.PlatformIDToName(t)) + if err != nil { + log.NewError(sendPbData.OperationID, "offline push error", sendPbData.String(), err.Error(), t) + } else { + log.NewDebug(sendPbData.OperationID, "offline push return result is ", string(pushResult), sendPbData, t) + } + } } } - } + } } + } func SendMsgByWS(m *pbChat.WSToMsgSvrChatMsg) {