mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
callback update
This commit is contained in:
parent
942afd7fec
commit
16b3ea8b7e
@ -311,7 +311,7 @@ callback:
|
|||||||
callbackAfterSendGroupMsg:
|
callbackAfterSendGroupMsg:
|
||||||
enable: false
|
enable: false
|
||||||
callbackTimeOut: 2
|
callbackTimeOut: 2
|
||||||
callbackWordFilter:
|
callbackMsgModify:
|
||||||
enable: false
|
enable: false
|
||||||
callbackTimeOut: 2
|
callbackTimeOut: 2
|
||||||
callbackFailedContinue: true
|
callbackFailedContinue: true
|
||||||
@ -340,6 +340,10 @@ callback:
|
|||||||
enable: false
|
enable: false
|
||||||
callbackTimeOut: 2
|
callbackTimeOut: 2
|
||||||
callbackFailedContinue: true # 回调超时是否继续
|
callbackFailedContinue: true # 回调超时是否继续
|
||||||
|
callbackBeforeCreateGroup:
|
||||||
|
enable: false
|
||||||
|
callbackTimeOut: 2
|
||||||
|
callbackFailedContinue: true # 回调超时是否继续
|
||||||
|
|
||||||
notification:
|
notification:
|
||||||
groupCreated:
|
groupCreated:
|
||||||
|
@ -36,7 +36,7 @@ func callbackOfflinePush(operationID string, userIDList []string, msg *commonPb.
|
|||||||
AtUserIDList: msg.AtUserIDList,
|
AtUserIDList: msg.AtUserIDList,
|
||||||
Content: callback.GetContent(msg),
|
Content: callback.GetContent(msg),
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: callbackResp}
|
||||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOfflinePushCommand, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOfflinePushCommand, req, resp, config.Config.Callback.CallbackOfflinePush.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
callbackResp.ErrMsg = err.Error()
|
callbackResp.ErrMsg = err.Error()
|
||||||
@ -84,7 +84,7 @@ func callbackOnlinePush(operationID string, userIDList []string, msg *commonPb.M
|
|||||||
AtUserIDList: msg.AtUserIDList,
|
AtUserIDList: msg.AtUserIDList,
|
||||||
Content: callback.GetContent(msg),
|
Content: callback.GetContent(msg),
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackBeforePushResp{CommonCallbackResp: callbackResp}
|
||||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOnlinePushCommand, req, resp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut); err != nil {
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackOnlinePushCommand, req, resp, config.Config.Callback.CallbackOnlinePush.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
callbackResp.ErrMsg = err.Error()
|
callbackResp.ErrMsg = err.Error()
|
||||||
@ -126,7 +126,7 @@ func callbackBeforeSuperGroupOnlinePush(operationID string, groupID string, msg
|
|||||||
AtUserIDList: msg.AtUserIDList,
|
AtUserIDList: msg.AtUserIDList,
|
||||||
Content: callback.GetContent(msg),
|
Content: callback.GetContent(msg),
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackBeforeSuperGroupOnlinePushResp{CommonCallbackResp: callbackResp}
|
||||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackSuperGroupOnlinePushCommand, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil {
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackSuperGroupOnlinePushCommand, req, resp, config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
callbackResp.ErrMsg = err.Error()
|
callbackResp.ErrMsg = err.Error()
|
||||||
|
@ -26,7 +26,7 @@ func callbackBeforeAddFriend(req *pbFriend.AddFriendReq) cbApi.CommonCallbackRes
|
|||||||
OperationID: req.CommID.OperationID,
|
OperationID: req.CommID.OperationID,
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforeAddFriendResp{
|
resp := &cbApi.CallbackBeforeAddFriendResp{
|
||||||
CommonCallbackResp: &callbackResp,
|
CommonCallbackResp: callbackResp,
|
||||||
}
|
}
|
||||||
//utils.CopyStructFields(req, msg.MsgData)
|
//utils.CopyStructFields(req, msg.MsgData)
|
||||||
defer log.NewDebug(req.CommID.OperationID, utils.GetSelfFuncName(), commonCallbackReq, *resp)
|
defer log.NewDebug(req.CommID.OperationID, utils.GetSelfFuncName(), commonCallbackReq, *resp)
|
||||||
|
@ -1,13 +1,78 @@
|
|||||||
package group
|
package group
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
cbApi "Open_IM/pkg/call_back_struct"
|
||||||
|
"Open_IM/pkg/common/config"
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
"Open_IM/pkg/common/http"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
pbGroup "Open_IM/pkg/proto/group"
|
pbGroup "Open_IM/pkg/proto/group"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
http2 "net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) (bool, error) {
|
func callbackBeforeCreateGroup(req *pbGroup.CreateGroupReq) cbApi.CommonCallbackResp {
|
||||||
return true, nil
|
callbackResp := cbApi.CommonCallbackResp{OperationID: req.OperationID}
|
||||||
}
|
if !config.Config.Callback.CallbackBeforeCreateGroup.Enable {
|
||||||
|
return callbackResp
|
||||||
func callbackAfterCreateGroup(req *pbGroup.CreateGroupReq) {
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), req.String())
|
||||||
|
commonCallbackReq := &cbApi.CallbackBeforeCreateGroupReq{
|
||||||
|
CallbackCommand: constant.CallbackBeforeCreateGroupCommand,
|
||||||
|
}
|
||||||
|
resp := &cbApi.CallbackBeforeCreateGroupResp{
|
||||||
|
CommonCallbackResp: callbackResp,
|
||||||
|
}
|
||||||
|
//utils.CopyStructFields(req, msg.MsgData)
|
||||||
|
defer log.NewDebug(req.OperationID, utils.GetSelfFuncName(), commonCallbackReq, *resp)
|
||||||
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeCreateGroupCommand, commonCallbackReq, resp, config.Config.Callback.CallbackBeforeCreateGroup.CallbackTimeOut); err != nil {
|
||||||
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
|
callbackResp.ErrMsg = err.Error()
|
||||||
|
if !config.Config.Callback.CallbackBeforeCreateGroup.CallbackFailedContinue {
|
||||||
|
callbackResp.ActionCode = constant.ActionForbidden
|
||||||
|
return callbackResp
|
||||||
|
} else {
|
||||||
|
callbackResp.ActionCode = constant.ActionAllow
|
||||||
|
return callbackResp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow {
|
||||||
|
if resp.GroupID != nil {
|
||||||
|
req.GroupInfo.GroupID = *resp.GroupID
|
||||||
|
}
|
||||||
|
if resp.GroupName != nil {
|
||||||
|
req.GroupInfo.GroupName = *resp.GroupID
|
||||||
|
}
|
||||||
|
if resp.Notification != nil {
|
||||||
|
req.GroupInfo.Notification = *resp.Notification
|
||||||
|
}
|
||||||
|
if resp.Introduction != nil {
|
||||||
|
req.GroupInfo.Introduction = *resp.Introduction
|
||||||
|
}
|
||||||
|
if resp.FaceURL != nil {
|
||||||
|
req.GroupInfo.FaceURL = *resp.FaceURL
|
||||||
|
}
|
||||||
|
if resp.OwnerUserID != nil {
|
||||||
|
req.GroupInfo.OwnerUserID = *resp.OwnerUserID
|
||||||
|
}
|
||||||
|
if resp.Ex != nil {
|
||||||
|
req.GroupInfo.Ex = *resp.Ex
|
||||||
|
}
|
||||||
|
if resp.Status != nil {
|
||||||
|
req.GroupInfo.Status = *resp.Status
|
||||||
|
}
|
||||||
|
if resp.CreatorUserID != nil {
|
||||||
|
req.GroupInfo.CreatorUserID = *resp.CreatorUserID
|
||||||
|
}
|
||||||
|
if resp.GroupType != nil {
|
||||||
|
req.GroupInfo.GroupType = *resp.GroupType
|
||||||
|
}
|
||||||
|
if resp.NeedVerification != nil {
|
||||||
|
req.GroupInfo.NeedVerification = *resp.GroupType
|
||||||
|
}
|
||||||
|
if resp.LookMemberInfo != nil {
|
||||||
|
req.GroupInfo.LookMemberInfo = *resp.LookMemberInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return callbackResp
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,20 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR
|
|||||||
log.NewError(req.OperationID, "CheckAccess false ", req.OpUserID, req.OwnerUserID)
|
log.NewError(req.OperationID, "CheckAccess false ", req.OpUserID, req.OwnerUserID)
|
||||||
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
return &pbGroup.CreateGroupResp{ErrCode: constant.ErrAccess.ErrCode, ErrMsg: constant.ErrAccess.ErrMsg}, nil
|
||||||
}
|
}
|
||||||
|
callbackResp := callbackBeforeCreateGroup(req)
|
||||||
|
if callbackResp.ErrCode != 0 {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg resp: ", callbackResp)
|
||||||
|
}
|
||||||
|
if callbackResp.ActionCode != constant.ActionAllow {
|
||||||
|
if callbackResp.ErrCode == 0 {
|
||||||
|
callbackResp.ErrCode = 201
|
||||||
|
}
|
||||||
|
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "callbackBeforeSendSingleMsg result", "end rpc and return", callbackResp)
|
||||||
|
return &pbGroup.CreateGroupResp{
|
||||||
|
ErrCode: int32(callbackResp.ErrCode),
|
||||||
|
ErrMsg: callbackResp.ErrMsg,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
groupId := req.GroupInfo.GroupID
|
groupId := req.GroupInfo.GroupID
|
||||||
if groupId == "" {
|
if groupId == "" {
|
||||||
|
@ -47,7 +47,7 @@ func callbackBeforeSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackRes
|
|||||||
RecvID: msg.MsgData.RecvID,
|
RecvID: msg.MsgData.RecvID,
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforeSendSingleMsgResp{
|
resp := &cbApi.CallbackBeforeSendSingleMsgResp{
|
||||||
CommonCallbackResp: &callbackResp,
|
CommonCallbackResp: callbackResp,
|
||||||
}
|
}
|
||||||
//utils.CopyStructFields(req, msg.MsgData)
|
//utils.CopyStructFields(req, msg.MsgData)
|
||||||
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||||
@ -77,7 +77,7 @@ func callbackAfterSendSingleMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
|
|||||||
CommonCallbackReq: commonCallbackReq,
|
CommonCallbackReq: commonCallbackReq,
|
||||||
RecvID: msg.MsgData.RecvID,
|
RecvID: msg.MsgData.RecvID,
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackAfterSendSingleMsgResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackAfterSendSingleMsgResp{CommonCallbackResp: callbackResp}
|
||||||
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterSendSingleMsgCommand, req, resp, config.Config.Callback.CallbackAfterSendSingleMsg.CallbackTimeOut); err != nil {
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterSendSingleMsgCommand, req, resp, config.Config.Callback.CallbackAfterSendSingleMsg.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
@ -99,7 +99,7 @@ func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
|
|||||||
CommonCallbackReq: commonCallbackReq,
|
CommonCallbackReq: commonCallbackReq,
|
||||||
GroupID: msg.MsgData.GroupID,
|
GroupID: msg.MsgData.GroupID,
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackBeforeSendGroupMsgResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackBeforeSendGroupMsgResp{CommonCallbackResp: callbackResp}
|
||||||
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSendGroupMsgCommand, req, resp, config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackTimeOut); err != nil {
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSendGroupMsgCommand, req, resp, config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
@ -127,7 +127,7 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
|
|||||||
CommonCallbackReq: commonCallbackReq,
|
CommonCallbackReq: commonCallbackReq,
|
||||||
GroupID: msg.MsgData.GroupID,
|
GroupID: msg.MsgData.GroupID,
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackAfterSendGroupMsgResp{CommonCallbackResp: callbackResp}
|
||||||
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterSendGroupMsgCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil {
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackAfterSendGroupMsgCommand, req, resp, config.Config.Callback.CallbackAfterSendGroupMsg.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
@ -137,23 +137,23 @@ func callbackAfterSendGroupMsg(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp
|
|||||||
return callbackResp
|
return callbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
func callbackWordFilter(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
func callbackMsgModify(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
||||||
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), msg)
|
||||||
callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID}
|
callbackResp := cbApi.CommonCallbackResp{OperationID: msg.OperationID}
|
||||||
if !config.Config.Callback.CallbackWordFilter.Enable || msg.MsgData.ContentType != constant.Text {
|
if !config.Config.Callback.CallbackMsgModify.Enable || msg.MsgData.ContentType != constant.Text {
|
||||||
return callbackResp
|
return callbackResp
|
||||||
}
|
}
|
||||||
commonCallbackReq := copyCallbackCommonReqStruct(msg)
|
commonCallbackReq := copyCallbackCommonReqStruct(msg)
|
||||||
commonCallbackReq.CallbackCommand = constant.CallbackWordFilterCommand
|
commonCallbackReq.CallbackCommand = constant.CallbackMsgModifyCommand
|
||||||
req := cbApi.CallbackWordFilterReq{
|
req := cbApi.CallbackMsgModifyCommandReq{
|
||||||
CommonCallbackReq: commonCallbackReq,
|
CommonCallbackReq: commonCallbackReq,
|
||||||
}
|
}
|
||||||
resp := &cbApi.CallbackWordFilterResp{CommonCallbackResp: &callbackResp}
|
resp := &cbApi.CallbackMsgModifyCommandResp{CommonCallbackResp: callbackResp}
|
||||||
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, *resp)
|
||||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackWordFilterCommand, req, resp, config.Config.Callback.CallbackWordFilter.CallbackTimeOut); err != nil {
|
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackMsgModifyCommand, req, resp, config.Config.Callback.CallbackMsgModify.CallbackTimeOut); err != nil {
|
||||||
callbackResp.ErrCode = http2.StatusInternalServerError
|
callbackResp.ErrCode = http2.StatusInternalServerError
|
||||||
callbackResp.ErrMsg = err.Error()
|
callbackResp.ErrMsg = err.Error()
|
||||||
if !config.Config.Callback.CallbackWordFilter.CallbackFailedContinue {
|
if !config.Config.Callback.CallbackMsgModify.CallbackFailedContinue {
|
||||||
callbackResp.ActionCode = constant.ActionForbidden
|
callbackResp.ActionCode = constant.ActionForbidden
|
||||||
return callbackResp
|
return callbackResp
|
||||||
} else {
|
} else {
|
||||||
@ -161,8 +161,62 @@ func callbackWordFilter(msg *pbChat.SendMsgReq) cbApi.CommonCallbackResp {
|
|||||||
return callbackResp
|
return callbackResp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow && resp.Content != "" {
|
if resp.ErrCode == constant.CallbackHandleSuccess && resp.ActionCode == constant.ActionAllow {
|
||||||
msg.MsgData.Content = []byte(resp.Content)
|
if resp.Content != nil {
|
||||||
|
msg.MsgData.Content = []byte(*resp.Content)
|
||||||
|
}
|
||||||
|
if resp.RecvID != nil {
|
||||||
|
msg.MsgData.RecvID = *resp.RecvID
|
||||||
|
}
|
||||||
|
if resp.GroupID != nil {
|
||||||
|
msg.MsgData.GroupID = *resp.GroupID
|
||||||
|
}
|
||||||
|
if resp.ClientMsgID != nil {
|
||||||
|
msg.MsgData.ClientMsgID = *resp.ClientMsgID
|
||||||
|
}
|
||||||
|
if resp.ServerMsgID != nil {
|
||||||
|
msg.MsgData.ServerMsgID = *resp.ServerMsgID
|
||||||
|
}
|
||||||
|
if resp.SenderPlatformID != nil {
|
||||||
|
msg.MsgData.SenderPlatformID = *resp.SenderPlatformID
|
||||||
|
}
|
||||||
|
if resp.SenderNickname != nil {
|
||||||
|
msg.MsgData.SenderNickname = *resp.SenderNickname
|
||||||
|
}
|
||||||
|
if resp.SenderFaceURL != nil {
|
||||||
|
msg.MsgData.SenderFaceURL = *resp.SenderFaceURL
|
||||||
|
}
|
||||||
|
if resp.SessionType != nil {
|
||||||
|
msg.MsgData.SessionType = *resp.SessionType
|
||||||
|
}
|
||||||
|
if resp.MsgFrom != nil {
|
||||||
|
msg.MsgData.MsgFrom = *resp.MsgFrom
|
||||||
|
}
|
||||||
|
if resp.ContentType != nil {
|
||||||
|
msg.MsgData.ContentType = *resp.ContentType
|
||||||
|
}
|
||||||
|
if resp.Status != nil {
|
||||||
|
msg.MsgData.Status = *resp.Status
|
||||||
|
}
|
||||||
|
if resp.Options != nil {
|
||||||
|
msg.MsgData.Options = *resp.Options
|
||||||
|
}
|
||||||
|
if resp.OfflinePushInfo != nil {
|
||||||
|
msg.MsgData.OfflinePushInfo = resp.OfflinePushInfo
|
||||||
|
}
|
||||||
|
if resp.AtUserIDList != nil {
|
||||||
|
msg.MsgData.AtUserIDList = *resp.AtUserIDList
|
||||||
|
}
|
||||||
|
if resp.MsgDataList != nil {
|
||||||
|
msg.MsgData.MsgDataList = *resp.MsgDataList
|
||||||
|
}
|
||||||
|
if resp.AttachedInfo != nil {
|
||||||
|
msg.MsgData.AttachedInfo = *resp.AttachedInfo
|
||||||
|
}
|
||||||
|
if resp.Ex != nil {
|
||||||
|
msg.MsgData.Ex = *resp.Ex
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), string(msg.MsgData.Content))
|
log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), string(msg.MsgData.Content))
|
||||||
return callbackResp
|
return callbackResp
|
||||||
|
@ -290,17 +290,17 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
msgToMQSingle := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData}
|
msgToMQSingle := pbChat.MsgDataToMQ{Token: pb.Token, OperationID: pb.OperationID, MsgData: pb.MsgData}
|
||||||
// callback
|
// callback
|
||||||
t1 = time.Now()
|
t1 = time.Now()
|
||||||
callbackResp := callbackWordFilter(pb)
|
callbackResp := callbackMsgModify(pb)
|
||||||
log.Debug(pb.OperationID, "callbackWordFilter ", callbackResp, "cost time: ", time.Since(t1))
|
log.Debug(pb.OperationID, "callbackMsgModify ", callbackResp, "cost time: ", time.Since(t1))
|
||||||
if callbackResp.ErrCode != 0 {
|
if callbackResp.ErrCode != 0 {
|
||||||
log.Error(pb.OperationID, utils.GetSelfFuncName(), "callbackWordFilter resp: ", callbackResp)
|
log.Error(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify resp: ", callbackResp)
|
||||||
}
|
}
|
||||||
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackResp: ", callbackResp)
|
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackResp: ", callbackResp)
|
||||||
if callbackResp.ActionCode != constant.ActionAllow {
|
if callbackResp.ActionCode != constant.ActionAllow {
|
||||||
if callbackResp.ErrCode == 0 {
|
if callbackResp.ErrCode == 0 {
|
||||||
callbackResp.ErrCode = 201
|
callbackResp.ErrCode = 201
|
||||||
}
|
}
|
||||||
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackWordFilter result", "end rpc and return", pb.MsgData)
|
log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callbackMsgModify result", "end rpc and return", pb.MsgData)
|
||||||
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0)
|
return returnMsg(&replay, pb, int32(callbackResp.ErrCode), callbackResp.ErrMsg, "", 0)
|
||||||
}
|
}
|
||||||
switch pb.MsgData.SessionType {
|
switch pb.MsgData.SessionType {
|
||||||
|
@ -9,5 +9,5 @@ type CallbackBeforeAddFriendReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeAddFriendResp struct {
|
type CallbackBeforeAddFriendResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,27 @@
|
|||||||
package call_back_struct
|
package call_back_struct
|
||||||
|
|
||||||
|
import (
|
||||||
|
commonPb "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
)
|
||||||
|
|
||||||
type CallbackBeforeCreateGroupReq struct {
|
type CallbackBeforeCreateGroupReq struct {
|
||||||
CommonCallbackReq
|
CallbackCommand string `json:"callbackCommand"`
|
||||||
|
commonPb.GroupInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterCreateGroupResp struct {
|
type CallbackBeforeCreateGroupResp struct {
|
||||||
CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
GroupID *string `json:"groupID"`
|
||||||
|
GroupName *string `json:"groupName"`
|
||||||
|
Notification *string `json:"notification"`
|
||||||
|
Introduction *string `json:"introduction"`
|
||||||
|
FaceURL *string `json:"faceURL"`
|
||||||
|
OwnerUserID *string `json:"ownerUserID"`
|
||||||
|
Ex *string `json:"ex"`
|
||||||
|
Status *int32 `json:"status"`
|
||||||
|
CreatorUserID *string `json:"creatorUserID"`
|
||||||
|
GroupType *int32 `json:"groupType"`
|
||||||
|
NeedVerification *int32 `json:"needVerification"`
|
||||||
|
LookMemberInfo *int32 `json:"lookMemberInfo"`
|
||||||
|
ApplyMemberFriend *int32 `json:"applyMemberFriend"`
|
||||||
|
}
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package call_back_struct
|
package call_back_struct
|
||||||
|
|
||||||
|
import sdk_ws "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
|
||||||
type CallbackBeforeSendSingleMsgReq struct {
|
type CallbackBeforeSendSingleMsgReq struct {
|
||||||
CommonCallbackReq
|
CommonCallbackReq
|
||||||
RecvID string `json:"recvID"`
|
RecvID string `json:"recvID"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSendSingleMsgResp struct {
|
type CallbackBeforeSendSingleMsgResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterSendSingleMsgReq struct {
|
type CallbackAfterSendSingleMsgReq struct {
|
||||||
@ -15,7 +17,7 @@ type CallbackAfterSendSingleMsgReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterSendSingleMsgResp struct {
|
type CallbackAfterSendSingleMsgResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSendGroupMsgReq struct {
|
type CallbackBeforeSendGroupMsgReq struct {
|
||||||
@ -24,7 +26,7 @@ type CallbackBeforeSendGroupMsgReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSendGroupMsgResp struct {
|
type CallbackBeforeSendGroupMsgResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterSendGroupMsgReq struct {
|
type CallbackAfterSendGroupMsgReq struct {
|
||||||
@ -33,14 +35,31 @@ type CallbackAfterSendGroupMsgReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackAfterSendGroupMsgResp struct {
|
type CallbackAfterSendGroupMsgResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackWordFilterReq struct {
|
type CallbackMsgModifyCommandReq struct {
|
||||||
CommonCallbackReq
|
CommonCallbackReq
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackWordFilterResp struct {
|
type CallbackMsgModifyCommandResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
Content string `json:"content"`
|
Content *string `json:"content"`
|
||||||
|
RecvID *string `json:"recvID"`
|
||||||
|
GroupID *string `json:"groupID"`
|
||||||
|
ClientMsgID *string `json:"clientMsgID"`
|
||||||
|
ServerMsgID *string `json:"serverMsgID"`
|
||||||
|
SenderPlatformID *int32 `json:"senderPlatformID"`
|
||||||
|
SenderNickname *string `json:"senderNickname"`
|
||||||
|
SenderFaceURL *string `json:"senderFaceURL"`
|
||||||
|
SessionType *int32 `json:"sessionType"`
|
||||||
|
MsgFrom *int32 `json:"msgFrom"`
|
||||||
|
ContentType *int32 `json:"contentType"`
|
||||||
|
Status *int32 `json:"status"`
|
||||||
|
Options *map[string]bool `json:"options"`
|
||||||
|
OfflinePushInfo *sdk_ws.OfflinePushInfo `json:"offlinePushInfo"`
|
||||||
|
AtUserIDList *[]string `json:"atUserIDList"`
|
||||||
|
MsgDataList *[]byte `json:"msgDataList"`
|
||||||
|
AttachedInfo *string `json:"attachedInfo"`
|
||||||
|
Ex *string `json:"ex"`
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ type CallbackBeforePushReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforePushResp struct {
|
type CallbackBeforePushResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
UserIDList []string `json:"userIDList"`
|
UserIDList []string `json:"userIDList"`
|
||||||
OfflinePushInfo *commonPb.OfflinePushInfo `json:"offlinePushInfo"`
|
OfflinePushInfo *commonPb.OfflinePushInfo `json:"offlinePushInfo"`
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ type CallbackBeforeSuperGroupOnlinePushReq struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CallbackBeforeSuperGroupOnlinePushResp struct {
|
type CallbackBeforeSuperGroupOnlinePushResp struct {
|
||||||
*CommonCallbackResp
|
CommonCallbackResp
|
||||||
UserIDList []string `json:"userIDList"`
|
UserIDList []string `json:"userIDList"`
|
||||||
OfflinePushInfo *commonPb.OfflinePushInfo `json:"offlinePushInfo"`
|
OfflinePushInfo *commonPb.OfflinePushInfo `json:"offlinePushInfo"`
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ type config struct {
|
|||||||
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
CallbackAfterSendSingleMsg callBackConfig `yaml:"callbackAfterSendSingleMsg"`
|
||||||
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
CallbackBeforeSendGroupMsg callBackConfig `yaml:"callbackBeforeSendGroupMsg"`
|
||||||
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
CallbackAfterSendGroupMsg callBackConfig `yaml:"callbackAfterSendGroupMsg"`
|
||||||
CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"`
|
CallbackMsgModify callBackConfig `yaml:"callbackMsgModify"`
|
||||||
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
|
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
|
||||||
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
|
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
|
||||||
CallbackUserKickOff callBackConfig `yaml:"callbackUserKickOff"`
|
CallbackUserKickOff callBackConfig `yaml:"callbackUserKickOff"`
|
||||||
@ -290,6 +290,7 @@ type config struct {
|
|||||||
CallbackOnlinePush callBackConfig `yaml:"callbackOnlinePush"`
|
CallbackOnlinePush callBackConfig `yaml:"callbackOnlinePush"`
|
||||||
CallbackBeforeSuperGroupOnlinePush callBackConfig `yaml:"callbackSuperGroupOnlinePush"`
|
CallbackBeforeSuperGroupOnlinePush callBackConfig `yaml:"callbackSuperGroupOnlinePush"`
|
||||||
CallbackBeforeAddFriend callBackConfig `yaml:"callbackBeforeAddFriend"`
|
CallbackBeforeAddFriend callBackConfig `yaml:"callbackBeforeAddFriend"`
|
||||||
|
CallbackBeforeCreateGroup callBackConfig `yaml:"callbackBeforeCreateGroup"`
|
||||||
} `yaml:"callback"`
|
} `yaml:"callback"`
|
||||||
Notification struct {
|
Notification struct {
|
||||||
///////////////////////group/////////////////////////////
|
///////////////////////group/////////////////////////////
|
||||||
|
@ -200,7 +200,7 @@ const (
|
|||||||
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
CallbackAfterSendSingleMsgCommand = "callbackAfterSendSingleMsgCommand"
|
||||||
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
CallbackBeforeSendGroupMsgCommand = "callbackBeforeSendGroupMsgCommand"
|
||||||
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
CallbackAfterSendGroupMsgCommand = "callbackAfterSendGroupMsgCommand"
|
||||||
CallbackWordFilterCommand = "callbackWordFilterCommand"
|
CallbackMsgModifyCommand = "callbackMsgModifyCommand"
|
||||||
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
|
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
|
||||||
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
|
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
|
||||||
CallbackUserKickOffCommand = "callbackUserKickOffCommand"
|
CallbackUserKickOffCommand = "callbackUserKickOffCommand"
|
||||||
@ -208,6 +208,7 @@ const (
|
|||||||
CallbackOnlinePushCommand = "callbackOnlinePushCommand"
|
CallbackOnlinePushCommand = "callbackOnlinePushCommand"
|
||||||
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"
|
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"
|
||||||
CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand"
|
CallbackBeforeAddFriendCommand = "callbackBeforeAddFriendCommand"
|
||||||
|
CallbackBeforeCreateGroupCommand = "callbackBeforeCreateGroup"
|
||||||
|
|
||||||
//callback actionCode
|
//callback actionCode
|
||||||
ActionAllow = 0
|
ActionAllow = 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user