mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
feat: SendBusinessNotification supported configuration parameters
This commit is contained in:
parent
67586614b8
commit
05528afbbb
@ -251,7 +251,8 @@ func (m *MessageApi) SendBusinessNotification(c *gin.Context) {
|
|||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Data string `json:"data"`
|
Data string `json:"data"`
|
||||||
SendUserID string `json:"sendUserID" binding:"required"`
|
SendUserID string `json:"sendUserID" binding:"required"`
|
||||||
RecvUserID string `json:"recvUserID" binding:"required"`
|
RecvUserID string `json:"recvUserID"`
|
||||||
|
RecvGroupID string `json:"recvGroupID"`
|
||||||
SendMsg bool `json:"sendMsg"`
|
SendMsg bool `json:"sendMsg"`
|
||||||
ReliabilityLevel *int `json:"reliabilityLevel"`
|
ReliabilityLevel *int `json:"reliabilityLevel"`
|
||||||
UnreadCount bool `json:"unreadCount"`
|
UnreadCount bool `json:"unreadCount"`
|
||||||
@ -260,6 +261,20 @@ func (m *MessageApi) SendBusinessNotification(c *gin.Context) {
|
|||||||
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if req.RecvUserID == "" && req.RecvGroupID == "" {
|
||||||
|
apiresp.GinError(c, errs.ErrArgs.WrapMsg("recvUserID and recvGroupID cannot be empty at the same time"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.RecvUserID != "" && req.RecvGroupID != "" {
|
||||||
|
apiresp.GinError(c, errs.ErrArgs.WrapMsg("recvUserID and recvGroupID cannot be set at the same time"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var sessionType int32
|
||||||
|
if req.RecvUserID != "" {
|
||||||
|
sessionType = constant.SingleChatType
|
||||||
|
} else {
|
||||||
|
sessionType = constant.ReadGroupChatType
|
||||||
|
}
|
||||||
if req.ReliabilityLevel == nil {
|
if req.ReliabilityLevel == nil {
|
||||||
req.ReliabilityLevel = datautil.ToPtr(1)
|
req.ReliabilityLevel = datautil.ToPtr(1)
|
||||||
}
|
}
|
||||||
@ -271,6 +286,7 @@ func (m *MessageApi) SendBusinessNotification(c *gin.Context) {
|
|||||||
MsgData: &sdkws.MsgData{
|
MsgData: &sdkws.MsgData{
|
||||||
SendID: req.SendUserID,
|
SendID: req.SendUserID,
|
||||||
RecvID: req.RecvUserID,
|
RecvID: req.RecvUserID,
|
||||||
|
GroupID: req.RecvGroupID,
|
||||||
Content: []byte(jsonutil.StructToJsonString(&sdkws.NotificationElem{
|
Content: []byte(jsonutil.StructToJsonString(&sdkws.NotificationElem{
|
||||||
Detail: jsonutil.StructToJsonString(&struct {
|
Detail: jsonutil.StructToJsonString(&struct {
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
@ -279,7 +295,7 @@ func (m *MessageApi) SendBusinessNotification(c *gin.Context) {
|
|||||||
})),
|
})),
|
||||||
MsgFrom: constant.SysMsgType,
|
MsgFrom: constant.SysMsgType,
|
||||||
ContentType: constant.BusinessNotification,
|
ContentType: constant.BusinessNotification,
|
||||||
SessionType: constant.SingleChatType,
|
SessionType: sessionType,
|
||||||
CreateTime: timeutil.GetCurrentTimestampByMill(),
|
CreateTime: timeutil.GetCurrentTimestampByMill(),
|
||||||
ClientMsgID: idutil.GetMsgIDByMD5(mcontext.GetOpUserID(c)),
|
ClientMsgID: idutil.GetMsgIDByMD5(mcontext.GetOpUserID(c)),
|
||||||
Options: config.GetOptionsByNotification(config.NotificationConfig{
|
Options: config.GetOptionsByNotification(config.NotificationConfig{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user