From 03fb7947c3877a771d6a66e18a80c14a1a6351d8 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Mon, 28 Mar 2022 16:57:08 +0800 Subject: [PATCH] add oa notification --- internal/api/manage/management_chat.go | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/internal/api/manage/management_chat.go b/internal/api/manage/management_chat.go index 368a2735e..802bb4207 100644 --- a/internal/api/manage/management_chat.go +++ b/internal/api/manage/management_chat.go @@ -20,6 +20,7 @@ import ( "context" "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" + "github.com/golang/protobuf/proto" "github.com/mitchellh/mapstructure" "net/http" "strings" @@ -29,6 +30,7 @@ var validate *validator.Validate func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq { var newContent string + var err error switch params.ContentType { case constant.Text: newContent = params.Content["text"].(string) @@ -42,6 +44,7 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq { newContent = utils.StructToJsonString(params.Content) case constant.Revoke: newContent = params.Content["revokeMsgClientID"].(string) + default: } var options map[string]bool @@ -72,6 +75,14 @@ func newUserSendMsgReq(params *ManagementSendMsgReq) *pbChat.SendMsgReq { OfflinePushInfo: params.OfflinePushInfo, }, } + if params.ContentType == constant.OANotification { + var tips open_im_sdk.TipsComm + tips.JsonDetail = utils.StructToJsonString(params.Content) + pbData.MsgData.Content, err = proto.Marshal(&tips) + if err != nil { + log.Error(params.OperationID, "Marshal failed ", err.Error(), tips.String()) + } + } return &pbData } func init() { @@ -107,6 +118,9 @@ func ManagementSendMsg(c *gin.Context) { data = CustomElem{} case constant.Revoke: data = RevokeElem{} + case constant.OANotification: + data = OANotificationElem{} + params.SessionType = constant.NotificationChatType //case constant.HasReadReceipt: //case constant.Typing: //case constant.Quote: @@ -267,3 +281,26 @@ type TextElem struct { type RevokeElem struct { RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"` } +type OANotificationElem struct { + NotificationName string `mapstructure:"notificationName" validate:"required"` + NotificationFaceURL string `mapstructure:"notificationFaceURL" validate:"required"` + NotificationType int32 `mapstructure:"notificationType" validate:"required"` + Text string `mapstructure:"text" validate:"required"` + Url string `mapstructure:"url"` + MixType int32 `mapstructure:"mixType"` + Image struct { + SourceUrl string `mapstructure:"sourceUrl"` + SnapshotUrl string `mapstructure:"snapshotUrl"` + } `mapstructure:"image"` + Video struct { + SourceUrl string `mapstructure:"sourceUrl"` + SnapshotUrl string `mapstructure:"snapshotUrl"` + Duration int64 `mapstructure:"duration"` + } `mapstructure:"video"` + File struct { + SourceUrl string `mapstructure:"sourceUrl"` + FileName string `mapstructure:"fileName"` + FileSize int64 `mapstructure:"fileSize"` + } `mapstructure:"file"` + Ex string `mapstructure:"ex"` +}