From 67586614b8b28e4220a6fb8602ec29646e58fffe Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Thu, 9 Jan 2025 16:54:17 +0800 Subject: [PATCH] feat: SendBusinessNotification supported configuration parameters --- internal/api/msg.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/internal/api/msg.go b/internal/api/msg.go index fc235354c..2fdbd7483 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -248,16 +248,21 @@ func (m *MessageApi) SendMessage(c *gin.Context) { func (m *MessageApi) SendBusinessNotification(c *gin.Context) { req := struct { - Key string `json:"key"` - Data string `json:"data"` - SendUserID string `json:"sendUserID" binding:"required"` - RecvUserID string `json:"recvUserID" binding:"required"` + Key string `json:"key"` + Data string `json:"data"` + SendUserID string `json:"sendUserID" binding:"required"` + RecvUserID string `json:"recvUserID" binding:"required"` + SendMsg bool `json:"sendMsg"` + ReliabilityLevel *int `json:"reliabilityLevel"` + UnreadCount bool `json:"unreadCount"` }{} if err := c.BindJSON(&req); err != nil { apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap()) return } - + if req.ReliabilityLevel == nil { + req.ReliabilityLevel = datautil.ToPtr(1) + } if !authverify.IsAppManagerUid(c, m.imAdminUserID) { apiresp.GinError(c, errs.ErrNoPermission.WrapMsg("only app manager can send message")) return @@ -278,9 +283,9 @@ func (m *MessageApi) SendBusinessNotification(c *gin.Context) { CreateTime: timeutil.GetCurrentTimestampByMill(), ClientMsgID: idutil.GetMsgIDByMD5(mcontext.GetOpUserID(c)), Options: config.GetOptionsByNotification(config.NotificationConfig{ - IsSendMsg: false, - ReliabilityLevel: 1, - UnreadCount: false, + IsSendMsg: req.SendMsg, + ReliabilityLevel: *req.ReliabilityLevel, + UnreadCount: req.UnreadCount, }), }, }