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
|
var newContent string
|
||||||
options := make(map[string]bool, 5)
|
options := make(map[string]bool, 5)
|
||||||
switch params.ContentType {
|
switch params.ContentType {
|
||||||
|
case constant.OANotification:
|
||||||
|
notification := sdkws.NotificationElem{}
|
||||||
|
notification.Detail = utils.StructToJsonString(params.Content)
|
||||||
|
newContent = utils.StructToJsonString(¬ification)
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
fallthrough
|
fallthrough
|
||||||
case constant.Picture:
|
case constant.Picture:
|
||||||
@ -69,10 +73,6 @@ func (m MessageApi) newUserSendMsgReq(c *gin.Context, params *apistruct.SendMsg)
|
|||||||
fallthrough
|
fallthrough
|
||||||
case constant.File:
|
case constant.File:
|
||||||
fallthrough
|
fallthrough
|
||||||
case constant.CustomNotTriggerConversation:
|
|
||||||
fallthrough
|
|
||||||
case constant.CustomOnlineOnly:
|
|
||||||
fallthrough
|
|
||||||
default:
|
default:
|
||||||
newContent = utils.StructToJsonString(params.Content)
|
newContent = utils.StructToJsonString(params.Content)
|
||||||
}
|
}
|
||||||
@ -82,11 +82,6 @@ func (m MessageApi) newUserSendMsgReq(c *gin.Context, params *apistruct.SendMsg)
|
|||||||
if params.NotOfflinePush {
|
if params.NotOfflinePush {
|
||||||
utils.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
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{
|
pbData := msg.SendMsgReq{
|
||||||
MsgData: &sdkws.MsgData{
|
MsgData: &sdkws.MsgData{
|
||||||
SendID: params.SendID,
|
SendID: params.SendID,
|
||||||
@ -105,14 +100,6 @@ func (m MessageApi) newUserSendMsgReq(c *gin.Context, params *apistruct.SendMsg)
|
|||||||
OfflinePushInfo: params.OfflinePushInfo,
|
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
|
return &pbData
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +172,9 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM
|
|||||||
case constant.OANotification:
|
case constant.OANotification:
|
||||||
data = apistruct.OANotificationElem{}
|
data = apistruct.OANotificationElem{}
|
||||||
req.SessionType = constant.NotificationChatType
|
req.SessionType = constant.NotificationChatType
|
||||||
|
if !authverify.IsManagerUserID(req.SendID) {
|
||||||
|
return nil, errs.ErrNoPermission.Wrap("only app manager can send message")
|
||||||
|
}
|
||||||
case constant.CustomNotTriggerConversation:
|
case constant.CustomNotTriggerConversation:
|
||||||
data = apistruct.CustomElem{}
|
data = apistruct.CustomElem{}
|
||||||
case constant.CustomOnlineOnly:
|
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"))
|
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMsgReq, err := m.getSendMsgReq(c, req.SendMsg)
|
sendMsgReq, err := m.getSendMsgReq(c, req.SendMsg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(c, "decodeData failed", err)
|
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 {
|
func (p *Pusher) UnmarshalNotificationElem(bytes []byte, t interface{}) error {
|
||||||
var notificationElem struct {
|
var notification sdkws.NotificationElem
|
||||||
Detail string `json:"detail,omitempty"`
|
if err := json.Unmarshal(bytes, ¬ification); err != nil {
|
||||||
}
|
|
||||||
if err := json.Unmarshal(bytes, ¬ificationElem); err != nil {
|
|
||||||
return err
|
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) {
|
func (p *Pusher) Push2SuperGroup(ctx context.Context, groupID string, msg *sdkws.MsgData) (err error) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user