push modify

pull/103/head
Gordon 3 years ago
parent 4b4dce80cf
commit 817d2b11a5

@ -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, &params)
log.Info("", "", "api UserSendMsg call start..., [data: %s]", pbData.String())

@ -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

@ -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) {

Loading…
Cancel
Save