pull/329/head
wangchuxiao 2 years ago
parent 53cd4205e8
commit 4d56dfdfa2

@ -163,6 +163,11 @@ func main() {
chatGroup.POST("/batch_send_msg", manage.ManagementBatchSendMsg)
chatGroup.POST("/check_msg_is_send_success", manage.CheckMsgIsSendSuccess)
chatGroup.POST("/set_msg_min_seq", apiChat.SetMsgMinSeq)
chatGroup.POST("/set_message_reaction_extensions", apiChat.SetMessageReactionExtensions)
chatGroup.POST("/get_message_list_reaction_extensions", apiChat.GetMessageListReactionExtensions)
chatGroup.POST("/add_message_reaction_extensions", apiChat.AddMessageReactionExtensions)
chatGroup.POST("/delete_message_reaction_extensions", apiChat.DeleteMessageReactionExtensions)
}
//Conversation
conversationGroup := r.Group("/conversation")

@ -345,11 +345,12 @@ callback:
enable: false
callbackTimeOut: 2
callbackFailedContinue: true # 回调超时是否继续
callbackBeforeExtendMsgModify:
callbackSetMessageReactionExtensions:
enable: false
callbackTimeOut: 2
callbackFailedContinue: true # 回调超时是否继续
notification:
groupCreated:
conversation:

@ -0,0 +1,206 @@
package msg
import (
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
"Open_IM/pkg/grpc-etcdv3/getcdv3"
rpc "Open_IM/pkg/proto/msg"
"Open_IM/pkg/utils"
"context"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func SetMessageReactionExtensions(c *gin.Context) {
var (
req api.SetMessageReactionExtensionsCallbackReq
resp api.SetMessageReactionExtensionsCallbackResp
reqPb rpc.ModifyMessageReactionExtensionsReq
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
}
var ok bool
var errInfo string
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
if grpcConn == nil {
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
msgClient := rpc.NewMsgClient(grpcConn)
respPb, err := msgClient.SetMessageReactionExtensions(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
return
}
resp.ErrCode = respPb.ErrCode
resp.ErrMsg = respPb.ErrMsg
resp.FailedList = respPb.FailedList
resp.SuccessList = respPb.SuccessList
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}
func GetMessageListReactionExtensions(c *gin.Context) {
var (
req api.GetMessageListReactionExtensionsReq
resp api.GetMessageListReactionExtensionsResp
reqPb rpc.OperateMessageListReactionExtensionsReq
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
}
var ok bool
var errInfo string
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
if grpcConn == nil {
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
msgClient := rpc.NewMsgClient(grpcConn)
respPb, err := msgClient.GetMessageListReactionExtensions(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
return
}
resp.ErrCode = respPb.ErrCode
resp.ErrMsg = respPb.ErrMsg
resp.FailedList = respPb.FailedList
resp.SuccessList = respPb.SuccessList
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}
func AddMessageReactionExtensions(c *gin.Context) {
var (
req api.AddMessageReactionExtensionsReq
resp api.AddMessageReactionExtensionsResp
reqPb rpc.ModifyMessageReactionExtensionsReq
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
}
var ok bool
var errInfo string
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
if grpcConn == nil {
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
msgClient := rpc.NewMsgClient(grpcConn)
respPb, err := msgClient.AddMessageReactionExtensions(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
return
}
resp.ErrCode = respPb.ErrCode
resp.ErrMsg = respPb.ErrMsg
resp.FailedList = respPb.FailedList
resp.SuccessList = respPb.SuccessList
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}
func DeleteMessageReactionExtensions(c *gin.Context) {
var (
req api.DeleteMessageReactionExtensionsReq
resp api.DeleteMessageReactionExtensionsResp
reqPb rpc.OperateMessageListReactionExtensionsReq
)
if err := c.BindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
return
}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req:", req)
if err := utils.CopyStructFields(&reqPb, &req); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields", err.Error())
}
var ok bool
var errInfo string
ok, reqPb.OpUserID, errInfo = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"), req.OperationID)
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
grpcConn := getcdv3.GetDefaultConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImMsgName, req.OperationID)
if grpcConn == nil {
errMsg := req.OperationID + " getcdv3.GetDefaultConn == nil"
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
msgClient := rpc.NewMsgClient(grpcConn)
respPb, err := msgClient.DeleteMessageReactionExtensions(context.Background(), &reqPb)
if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "DelMsgList failed", err.Error(), reqPb)
c.JSON(http.StatusOK, gin.H{"errCode": constant.ErrServer.ErrCode, "errMsg": constant.ErrServer.ErrMsg + err.Error()})
return
}
resp.ErrCode = respPb.ErrCode
resp.ErrMsg = respPb.ErrMsg
resp.FailedList = respPb.FailedList
resp.SuccessList = respPb.SuccessList
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), resp)
c.JSON(http.StatusOK, resp)
}

@ -221,9 +221,3 @@ func callbackMsgModify(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), string(msg.MsgData.Content))
return callbackResp
}
func CallbackBeforeExtendMsgModify() cbApi.CommonCallbackResp {
callbackResp := cbApi.CommonCallbackResp{OperationID: ""}
return callbackResp
}

@ -0,0 +1,9 @@
package msg
func callbackSetMessageReactionExtensions() {
}
func callbackDeleteMessageReactionExtensions() {
}

@ -1,5 +1,10 @@
package base_info
import (
"Open_IM/pkg/proto/msg"
sdk_ws "Open_IM/pkg/proto/sdk_ws"
)
type DelMsgReq struct {
UserID string `json:"userID,omitempty" binding:"required"`
SeqList []uint32 `json:"seqList,omitempty" binding:"required"`
@ -18,6 +23,7 @@ type CleanUpMsgReq struct {
type CleanUpMsgResp struct {
CommResp
}
type DelSuperGroupMsgReq struct {
UserID string `json:"userID" binding:"required"`
GroupID string `json:"groupID" binding:"required"`
@ -29,23 +35,68 @@ type DelSuperGroupMsgReq struct {
type DelSuperGroupMsgResp struct {
CommResp
}
type MsgDeleteNotificationElem struct {
GroupID string `json:"groupID"`
IsAllDelete bool `json:"isAllDelete"`
SeqList []uint32 `json:"seqList"`
}
//UserID string `protobuf:"bytes,1,opt,name=userID" json:"userID,omitempty"`
// GroupID string `protobuf:"bytes,2,opt,name=groupID" json:"groupID,omitempty"`
// MinSeq uint32 `protobuf:"varint,3,opt,name=minSeq" json:"minSeq,omitempty"`
// OperationID string `protobuf:"bytes,4,opt,name=operationID" json:"operationID,omitempty"`
// OpUserID string `protobuf:"bytes,5,opt,name=opUserID" json:"opUserID,omitempty"`
type SetMsgMinSeqReq struct {
UserID string `json:"userID" binding:"required"`
GroupID string `json:"groupID"`
MinSeq uint32 `json:"minSeq" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type SetMsgMinSeqResp struct {
CommResp
}
type ModifyMessageReactionExtensionsReq struct {
OperationID string `json:"operationID" binding:"required"`
SourceID string `json:"sourceID" binding:"required"`
SessionType int32 `json:"sessionType" binding:"required"`
ReactionExtensionList map[string]*sdk_ws.KeyValue `json:"reactionExtensionList,omitempty" binding:"required"`
ClientMsgID string `json:"clientMsgID" binding:"required"`
Ex *string `json:"ex"`
AttachedInfo *string `json:"attachedInfo"`
IsReact bool `json:"isReact"`
IsExternalExtensions bool `json:"isExternalExtensions"`
MsgFirstModifyTime int64 `json:"msgFirstModifyTime"`
}
type ModifyMessageReactionExtensionsResp struct {
CommResp
SuccessList []*sdk_ws.ExtendMsg `json:"successList"`
FailedList []*sdk_ws.ExtendMsg `json:"failedList"`
}
type OperateMessageListReactionExtensionsReq struct {
OperationID string `json:"operationID" binding:"required"`
SourceID string `json:"sourceID" binding:"required"`
SessionType string `json:"sessionType" binding:"required"`
MessageReactionKeyList []*msg.OperateMessageListReactionExtensionsReq_MessageReactionKey `json:"messageReactionKeyList" binding:"required"`
}
type OperateMessageListReactionExtensionsResp struct {
CommResp
SuccessList []*sdk_ws.ExtendMsg `json:"successList"`
FailedList []*sdk_ws.ExtendMsg `json:"failedList"`
}
type SetMessageReactionExtensionsCallbackReq ModifyMessageReactionExtensionsReq
type SetMessageReactionExtensionsCallbackResp ModifyMessageReactionExtensionsResp
type GetMessageListReactionExtensionsReq OperateMessageListReactionExtensionsReq
type GetMessageListReactionExtensionsResp OperateMessageListReactionExtensionsResp
type AddMessageReactionExtensionsReq ModifyMessageReactionExtensionsReq
type AddMessageReactionExtensionsResp ModifyMessageReactionExtensionsResp
type DeleteMessageReactionExtensionsReq OperateMessageListReactionExtensionsReq
type DeleteMessageReactionExtensionsResp OperateMessageListReactionExtensionsResp

Loading…
Cancel
Save