mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-08 21:47:17 +08:00
fix: api send messages for notification conversation .
This commit is contained in:
parent
fa4c2d7d58
commit
5f8b2790d2
@ -57,6 +57,10 @@ func (m MessageApi) newUserSendMsgReq(c *gin.Context, params *apistruct.SendMsg)
|
||||
var newContent string
|
||||
options := make(map[string]bool, 5)
|
||||
switch params.ContentType {
|
||||
case constant.OANotification:
|
||||
notification := sdkws.NotificationElem{}
|
||||
notification.Detail = utils.StructToJsonString(params.Content)
|
||||
newContent = utils.StructToJsonString(¬ification)
|
||||
case constant.Text:
|
||||
fallthrough
|
||||
case constant.Picture:
|
||||
@ -69,10 +73,6 @@ func (m MessageApi) newUserSendMsgReq(c *gin.Context, params *apistruct.SendMsg)
|
||||
fallthrough
|
||||
case constant.File:
|
||||
fallthrough
|
||||
case constant.CustomNotTriggerConversation:
|
||||
fallthrough
|
||||
case constant.CustomOnlineOnly:
|
||||
fallthrough
|
||||
default:
|
||||
newContent = utils.StructToJsonString(params.Content)
|
||||
}
|
||||
@ -82,11 +82,6 @@ func (m MessageApi) newUserSendMsgReq(c *gin.Context, params *apistruct.SendMsg)
|
||||
if params.NotOfflinePush {
|
||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
||||
}
|
||||
if params.ContentType == constant.CustomOnlineOnly {
|
||||
m.SetOptions(options, false)
|
||||
} else if params.ContentType == constant.CustomNotTriggerConversation {
|
||||
utils.SetSwitchFromOptions(options, constant.IsConversationUpdate, false)
|
||||
}
|
||||
pbData := msg.SendMsgReq{
|
||||
MsgData: &sdkws.MsgData{
|
||||
SendID: params.SendID,
|
||||
@ -105,14 +100,6 @@ func (m MessageApi) newUserSendMsgReq(c *gin.Context, params *apistruct.SendMsg)
|
||||
OfflinePushInfo: params.OfflinePushInfo,
|
||||
},
|
||||
}
|
||||
//if params.ContentType == constant.OANotification {
|
||||
// var tips sdkws.TipsComm
|
||||
// tips.JsonDetail = utils.StructToJsonString(params.Content)
|
||||
// pbData.MsgData.Content, err = proto.Marshal(&tips)
|
||||
// if err != nil {
|
||||
// log.ZError(c, "Marshal failed ", err, "tips", tips.String())
|
||||
// }
|
||||
//}
|
||||
return &pbData
|
||||
}
|
||||
|
||||
@ -185,6 +172,9 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM
|
||||
case constant.OANotification:
|
||||
data = apistruct.OANotificationElem{}
|
||||
req.SessionType = constant.NotificationChatType
|
||||
if !authverify.IsManagerUserID(req.SendID) {
|
||||
return nil, errs.ErrNoPermission.Wrap("only app manager can send message")
|
||||
}
|
||||
case constant.CustomNotTriggerConversation:
|
||||
data = apistruct.CustomElem{}
|
||||
case constant.CustomOnlineOnly:
|
||||
@ -212,7 +202,6 @@ func (m *MessageApi) SendMessage(c *gin.Context) {
|
||||
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
|
||||
return
|
||||
}
|
||||
|
||||
sendMsgReq, err := m.getSendMsgReq(c, req.SendMsg)
|
||||
if err != nil {
|
||||
log.ZError(c, "decodeData failed", err)
|
||||
|
||||
@ -126,13 +126,11 @@ func (p *Pusher) Push2User(ctx context.Context, userIDs []string, msg *sdkws.Msg
|
||||
}
|
||||
|
||||
func (p *Pusher) UnmarshalNotificationElem(bytes []byte, t interface{}) error {
|
||||
var notificationElem struct {
|
||||
Detail string `json:"detail,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(bytes, ¬ificationElem); err != nil {
|
||||
var notification sdkws.NotificationElem
|
||||
if err := json.Unmarshal(bytes, ¬ification); err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal([]byte(notificationElem.Detail), t)
|
||||
return json.Unmarshal([]byte(notification.Detail), t)
|
||||
}
|
||||
|
||||
func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws.MsgData) (err error) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user