Update push_to_client.go

推送消息:修改detailContent内容这text、[图片]等,title修改为pushMsg.MsgData.SenderNickname 消息发送人
pull/329/head
sanmingting 3 years ago committed by GitHub
parent 64edd9b7ea
commit 50f3b9b42a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,6 +13,7 @@ import (
"Open_IM/pkg/common/constant" "Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db" "Open_IM/pkg/common/db"
"Open_IM/pkg/common/log" "Open_IM/pkg/common/log"
promePkg "Open_IM/pkg/common/prometheus"
"Open_IM/pkg/grpc-etcdv3/getcdv3" "Open_IM/pkg/grpc-etcdv3/getcdv3"
pbPush "Open_IM/pkg/proto/push" pbPush "Open_IM/pkg/proto/push"
pbRelay "Open_IM/pkg/proto/relay" pbRelay "Open_IM/pkg/proto/relay"
@ -20,8 +21,7 @@ import (
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"context" "context"
"strings" "strings"
"unsafe"
promePkg "Open_IM/pkg/common/prometheus"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
) )
@ -103,7 +103,7 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
return return
} }
if pushMsg.MsgData.OfflinePushInfo != nil { if pushMsg.MsgData.OfflinePushInfo != nil {
title = pushMsg.MsgData.OfflinePushInfo.Title title = pushMsg.MsgData.SenderNickname //pushMsg.MsgData.OfflinePushInfo.Title
detailContent = pushMsg.MsgData.OfflinePushInfo.Desc detailContent = pushMsg.MsgData.OfflinePushInfo.Desc
} }
@ -116,35 +116,35 @@ func MsgToUser(pushMsg *pbPush.PushMsgReq) {
} }
log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, title, detailContent, "opts:", opts) log.NewInfo(pushMsg.OperationID, utils.GetSelfFuncName(), UIDList, title, detailContent, "opts:", opts)
if title == "" { if title == "" {
title = pushMsg.MsgData.SenderNickname
}
if detailContent == "" {
switch pushMsg.MsgData.ContentType { switch pushMsg.MsgData.ContentType {
case constant.Text: case constant.Text:
fallthrough detailContent = *(*string)(unsafe.Pointer(&pushMsg.MsgData.Content))
case constant.Picture: case constant.Picture:
fallthrough detailContent = constant.ContentType2PushContent[constant.Picture]
case constant.Voice: case constant.Voice:
fallthrough detailContent = constant.ContentType2PushContent[constant.Voice]
case constant.Video: case constant.Video:
fallthrough detailContent = constant.ContentType2PushContent[constant.Voice]
case constant.File: case constant.File:
title = constant.ContentType2PushContent[int64(pushMsg.MsgData.ContentType)] detailContent = constant.ContentType2PushContent[constant.File]
case constant.AtText: case constant.AtText:
a := AtContent{} a := AtContent{}
_ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a) _ = utils.JsonStringToStruct(string(pushMsg.MsgData.Content), &a)
if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) { if utils.IsContain(pushMsg.PushToUserID, a.AtUserList) {
title = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common] detailContent = constant.ContentType2PushContent[constant.AtText] + constant.ContentType2PushContent[constant.Common]
} else { } else {
title = constant.ContentType2PushContent[constant.GroupMsg] detailContent = constant.ContentType2PushContent[constant.GroupMsg]
} }
case constant.SignalingNotification: case constant.SignalingNotification:
title = constant.ContentType2PushContent[constant.SignalMsg] detailContent = constant.ContentType2PushContent[constant.SignalMsg]
default: default:
title = constant.ContentType2PushContent[constant.Common] detailContent = constant.ContentType2PushContent[constant.Common]
} }
// detailContent = title //detailContent = *(*string)(unsafe.Pointer(&pushMsg.MsgData.Content))
}
if detailContent == "" {
detailContent = title
} }
pushResult, err := offlinePusher.Push(UIDList, title, detailContent, pushMsg.OperationID, opts) pushResult, err := offlinePusher.Push(UIDList, title, detailContent, pushMsg.OperationID, opts)
if err != nil { if err != nil {

Loading…
Cancel
Save