You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/rpc/msg/extend_msg_callback.go

89 lines
3.8 KiB

package msg
import (
2 years ago
"context"
2 years ago
cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
)
2 years ago
func CallbackSetMessageReactionExtensions(ctx context.Context, setReq *msg.SetMessageReactionExtensionsReq) error {
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
return nil
}
req := &cbapi.CallbackBeforeSetMessageReactionExtReq{
2 years ago
OperationID: mcontext.GetOperationID(ctx),
CallbackCommand: constant.CallbackBeforeSetMessageReactionExtensionCommand,
ConversationID: setReq.ConversationID,
2 years ago
OpUserID: mcontext.GetOpUserID(ctx),
SessionType: setReq.SessionType,
2 years ago
ReactionExtensionList: setReq.ReactionExtensions,
ClientMsgID: setReq.ClientMsgID,
IsReact: setReq.IsReact,
IsExternalExtensions: setReq.IsExternalExtensions,
MsgFirstModifyTime: setReq.MsgFirstModifyTime,
}
2 years ago
resp := &cbapi.CallbackBeforeSetMessageReactionExtResp{}
2 years ago
if err := http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg); err != nil {
return err
}
setReq.MsgFirstModifyTime = resp.MsgFirstModifyTime
return nil
}
2 years ago
func CallbackDeleteMessageReactionExtensions(setReq *msg.DeleteMessagesReactionExtensionsReq) error {
2 years ago
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
return nil
}
req := &cbapi.CallbackDeleteMessageReactionExtReq{
OperationID: setReq.OperationID,
CallbackCommand: constant.CallbackBeforeDeleteMessageReactionExtensionsCommand,
ConversationID: setReq.ConversationID,
OpUserID: setReq.OpUserID,
SessionType: setReq.SessionType,
2 years ago
ReactionExtensionList: setReq.ReactionExtensions,
ClientMsgID: setReq.ClientMsgID,
IsExternalExtensions: setReq.IsExternalExtensions,
MsgFirstModifyTime: setReq.MsgFirstModifyTime,
}
2 years ago
resp := &cbapi.CallbackDeleteMessageReactionExtResp{}
2 years ago
return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
}
2 years ago
func CallbackGetMessageListReactionExtensions(ctx context.Context, getReq *msg.GetMessagesReactionExtensionsReq) error {
2 years ago
if !config.Config.Callback.CallbackAfterSendGroupMsg.Enable {
return nil
}
2 years ago
req := &cbapi.CallbackGetMessageListReactionExtReq{
2 years ago
OperationID: mcontext.GetOperationID(ctx),
2 years ago
CallbackCommand: constant.CallbackGetMessageListReactionExtensionsCommand,
ConversationID: getReq.ConversationID,
2 years ago
OpUserID: mcontext.GetOperationID(ctx),
2 years ago
SessionType: getReq.SessionType,
2 years ago
TypeKeyList: getReq.TypeKeys,
2 years ago
}
2 years ago
resp := &cbapi.CallbackGetMessageListReactionExtResp{}
return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
2 years ago
}
2 years ago
func CallbackAddMessageReactionExtensions(ctx context.Context, setReq *msg.ModifyMessageReactionExtensionsReq) error {
2 years ago
req := &cbapi.CallbackAddMessageReactionExtReq{
2 years ago
OperationID: mcontext.GetOperationID(ctx),
2 years ago
CallbackCommand: constant.CallbackAddMessageListReactionExtensionsCommand,
ConversationID: setReq.ConversationID,
2 years ago
OpUserID: mcontext.GetOperationID(ctx),
2 years ago
SessionType: setReq.SessionType,
2 years ago
ReactionExtensionList: setReq.ReactionExtensions,
2 years ago
ClientMsgID: setReq.ClientMsgID,
IsReact: setReq.IsReact,
IsExternalExtensions: setReq.IsExternalExtensions,
MsgFirstModifyTime: setReq.MsgFirstModifyTime,
}
2 years ago
resp := &cbapi.CallbackAddMessageReactionExtResp{}
return http.CallBackPostReturn(cbURL(), req, resp, config.Config.Callback.CallbackAfterSendGroupMsg)
2 years ago
}