|
|
@ -94,7 +94,22 @@ func (*MessageApi) SetOptions(options map[string]bool, value bool) {
|
|
|
|
datautil.SetSwitchFromOptions(options, constant.IsConversationUpdate, value)
|
|
|
|
datautil.SetSwitchFromOptions(options, constant.IsConversationUpdate, value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (m *MessageApi) newUserSendMsgReq(_ *gin.Context, params *apistruct.SendMsg) *msg.SendMsgReq {
|
|
|
|
func (m *MessageApi) newUserSendMsgReq(_ *gin.Context, params *apistruct.SendMsg, data any) *msg.SendMsgReq {
|
|
|
|
|
|
|
|
msgData := &sdkws.MsgData{
|
|
|
|
|
|
|
|
SendID: params.SendID,
|
|
|
|
|
|
|
|
GroupID: params.GroupID,
|
|
|
|
|
|
|
|
ClientMsgID: idutil.GetMsgIDByMD5(params.SendID),
|
|
|
|
|
|
|
|
SenderPlatformID: params.SenderPlatformID,
|
|
|
|
|
|
|
|
SenderNickname: params.SenderNickname,
|
|
|
|
|
|
|
|
SenderFaceURL: params.SenderFaceURL,
|
|
|
|
|
|
|
|
SessionType: params.SessionType,
|
|
|
|
|
|
|
|
MsgFrom: constant.SysMsgType,
|
|
|
|
|
|
|
|
ContentType: params.ContentType,
|
|
|
|
|
|
|
|
CreateTime: timeutil.GetCurrentTimestampByMill(),
|
|
|
|
|
|
|
|
SendTime: params.SendTime,
|
|
|
|
|
|
|
|
OfflinePushInfo: params.OfflinePushInfo,
|
|
|
|
|
|
|
|
Ex: params.Ex,
|
|
|
|
|
|
|
|
}
|
|
|
|
var newContent string
|
|
|
|
var newContent string
|
|
|
|
options := make(map[string]bool, 5)
|
|
|
|
options := make(map[string]bool, 5)
|
|
|
|
switch params.ContentType {
|
|
|
|
switch params.ContentType {
|
|
|
@ -104,6 +119,11 @@ func (m *MessageApi) newUserSendMsgReq(_ *gin.Context, params *apistruct.SendMsg
|
|
|
|
newContent = jsonutil.StructToJsonString(¬ification)
|
|
|
|
newContent = jsonutil.StructToJsonString(¬ification)
|
|
|
|
case constant.Text:
|
|
|
|
case constant.Text:
|
|
|
|
fallthrough
|
|
|
|
fallthrough
|
|
|
|
|
|
|
|
case constant.AtText:
|
|
|
|
|
|
|
|
if atElem, ok := data.(*apistruct.AtElem); ok {
|
|
|
|
|
|
|
|
msgData.AtUserIDList = atElem.AtUserList
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fallthrough
|
|
|
|
case constant.Picture:
|
|
|
|
case constant.Picture:
|
|
|
|
fallthrough
|
|
|
|
fallthrough
|
|
|
|
case constant.Custom:
|
|
|
|
case constant.Custom:
|
|
|
@ -123,24 +143,10 @@ func (m *MessageApi) newUserSendMsgReq(_ *gin.Context, params *apistruct.SendMsg
|
|
|
|
if params.NotOfflinePush {
|
|
|
|
if params.NotOfflinePush {
|
|
|
|
datautil.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
|
|
|
datautil.SetSwitchFromOptions(options, constant.IsOfflinePush, false)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msgData.Content = []byte(newContent)
|
|
|
|
|
|
|
|
msgData.Options = options
|
|
|
|
pbData := msg.SendMsgReq{
|
|
|
|
pbData := msg.SendMsgReq{
|
|
|
|
MsgData: &sdkws.MsgData{
|
|
|
|
MsgData: msgData,
|
|
|
|
SendID: params.SendID,
|
|
|
|
|
|
|
|
GroupID: params.GroupID,
|
|
|
|
|
|
|
|
ClientMsgID: idutil.GetMsgIDByMD5(params.SendID),
|
|
|
|
|
|
|
|
SenderPlatformID: params.SenderPlatformID,
|
|
|
|
|
|
|
|
SenderNickname: params.SenderNickname,
|
|
|
|
|
|
|
|
SenderFaceURL: params.SenderFaceURL,
|
|
|
|
|
|
|
|
SessionType: params.SessionType,
|
|
|
|
|
|
|
|
MsgFrom: constant.SysMsgType,
|
|
|
|
|
|
|
|
ContentType: params.ContentType,
|
|
|
|
|
|
|
|
Content: []byte(newContent),
|
|
|
|
|
|
|
|
CreateTime: timeutil.GetCurrentTimestampByMill(),
|
|
|
|
|
|
|
|
SendTime: params.SendTime,
|
|
|
|
|
|
|
|
Options: options,
|
|
|
|
|
|
|
|
OfflinePushInfo: params.OfflinePushInfo,
|
|
|
|
|
|
|
|
Ex: params.Ex,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return &pbData
|
|
|
|
return &pbData
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -198,23 +204,23 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM
|
|
|
|
log.ZDebug(c, "getSendMsgReq", "req", req.Content)
|
|
|
|
log.ZDebug(c, "getSendMsgReq", "req", req.Content)
|
|
|
|
switch req.ContentType {
|
|
|
|
switch req.ContentType {
|
|
|
|
case constant.Text:
|
|
|
|
case constant.Text:
|
|
|
|
data = apistruct.TextElem{}
|
|
|
|
data = &apistruct.TextElem{}
|
|
|
|
case constant.Picture:
|
|
|
|
case constant.Picture:
|
|
|
|
data = apistruct.PictureElem{}
|
|
|
|
data = &apistruct.PictureElem{}
|
|
|
|
case constant.Voice:
|
|
|
|
case constant.Voice:
|
|
|
|
data = apistruct.SoundElem{}
|
|
|
|
data = &apistruct.SoundElem{}
|
|
|
|
case constant.Video:
|
|
|
|
case constant.Video:
|
|
|
|
data = apistruct.VideoElem{}
|
|
|
|
data = &apistruct.VideoElem{}
|
|
|
|
case constant.File:
|
|
|
|
case constant.File:
|
|
|
|
data = apistruct.FileElem{}
|
|
|
|
data = &apistruct.FileElem{}
|
|
|
|
case constant.AtText:
|
|
|
|
case constant.AtText:
|
|
|
|
data = apistruct.AtElem{}
|
|
|
|
data = &apistruct.AtElem{}
|
|
|
|
case constant.Custom:
|
|
|
|
case constant.Custom:
|
|
|
|
data = apistruct.CustomElem{}
|
|
|
|
data = &apistruct.CustomElem{}
|
|
|
|
case constant.MarkdownText:
|
|
|
|
case constant.MarkdownText:
|
|
|
|
data = apistruct.MarkdownTextElem{}
|
|
|
|
data = &apistruct.MarkdownTextElem{}
|
|
|
|
case constant.OANotification:
|
|
|
|
case constant.OANotification:
|
|
|
|
data = apistruct.OANotificationElem{}
|
|
|
|
data = &apistruct.OANotificationElem{}
|
|
|
|
req.SessionType = constant.NotificationChatType
|
|
|
|
req.SessionType = constant.NotificationChatType
|
|
|
|
if err = m.userClient.GetNotificationByID(c, req.SendID); err != nil {
|
|
|
|
if err = m.userClient.GetNotificationByID(c, req.SendID); err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
@ -222,14 +228,14 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return nil, errs.WrapMsg(errs.ErrArgs, "unsupported content type", "contentType", req.ContentType)
|
|
|
|
return nil, errs.WrapMsg(errs.ErrArgs, "unsupported content type", "contentType", req.ContentType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if err := mapstructure.WeakDecode(req.Content, &data); err != nil {
|
|
|
|
if err := mapstructure.WeakDecode(req.Content, data); err != nil {
|
|
|
|
return nil, errs.WrapMsg(err, "failed to decode message content")
|
|
|
|
return nil, errs.WrapMsg(err, "failed to decode message content")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.ZDebug(c, "getSendMsgReq", "decodedContent", data)
|
|
|
|
log.ZDebug(c, "getSendMsgReq", "decodedContent", data)
|
|
|
|
if err := m.validate.Struct(data); err != nil {
|
|
|
|
if err := m.validate.Struct(data); err != nil {
|
|
|
|
return nil, errs.WrapMsg(err, "validation error")
|
|
|
|
return nil, errs.WrapMsg(err, "validation error")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return m.newUserSendMsgReq(c, &req), nil
|
|
|
|
return m.newUserSendMsgReq(c, &req, data), nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (m *MessageApi) getModifyFields(req, respModify *sdkws.MsgData) map[string]any {
|
|
|
|
func (m *MessageApi) getModifyFields(req, respModify *sdkws.MsgData) map[string]any {
|
|
|
|