Merge remote-tracking branch 'origin/v2.3.0release' into v2.3.0release

This commit is contained in:
Gordon 2022-10-27 11:46:13 +08:00
commit 59b625b7c0
16 changed files with 240 additions and 56 deletions

View File

@ -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:

View File

@ -28,7 +28,7 @@ func callbackUserOnline(operationID, userID string, platformID int, token string
Seq: int(time.Now().UnixNano() / 1e6), Seq: int(time.Now().UnixNano() / 1e6),
} }
callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: callbackResp} callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: callbackResp}
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil { if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
} }
@ -53,7 +53,7 @@ func callbackUserOffline(operationID, userID string, platformID int) cbApi.Commo
Seq: int(time.Now().UnixNano() / 1e6), Seq: int(time.Now().UnixNano() / 1e6),
} }
callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: callbackResp} callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: callbackResp}
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
} }
@ -78,7 +78,7 @@ func callbackUserKickOff(operationID string, userID string, platformID int) cbAp
Seq: int(time.Now().UnixNano() / 1e6), Seq: int(time.Now().UnixNano() / 1e6),
} }
callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: callbackResp} callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: callbackResp}
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserKickOffCommand, callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
} }

View File

@ -36,8 +36,8 @@ 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.PostReturn(config.Config.Callback.CallbackUrl, 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()
if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue { if !config.Config.Callback.CallbackOfflinePush.CallbackFailedContinue {
@ -84,8 +84,8 @@ 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.PostReturn(config.Config.Callback.CallbackUrl, 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()
if !config.Config.Callback.CallbackOnlinePush.CallbackFailedContinue { if !config.Config.Callback.CallbackOnlinePush.CallbackFailedContinue {
@ -126,8 +126,8 @@ 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.PostReturn(config.Config.Callback.CallbackUrl, 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()
if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackFailedContinue { if !config.Config.Callback.CallbackBeforeSuperGroupOnlinePush.CallbackFailedContinue {

View File

@ -26,11 +26,11 @@ 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)
if err := http.PostReturn(config.Config.Callback.CallbackUrl, commonCallbackReq, resp, config.Config.Callback.CallbackBeforeAddFriend.CallbackTimeOut); err != nil { if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeAddFriendCommand, commonCallbackReq, resp, config.Config.Callback.CallbackBeforeAddFriend.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
if !config.Config.Callback.CallbackBeforeAddFriend.CallbackFailedContinue { if !config.Config.Callback.CallbackBeforeAddFriend.CallbackFailedContinue {

View File

@ -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
} }

View File

@ -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 == "" {

View File

@ -47,11 +47,11 @@ 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)
if err := http.PostReturn(config.Config.Callback.CallbackUrl, req, resp, config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackTimeOut); err != nil { if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackBeforeSendSingleMsgCommand, req, resp, config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
if !config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackFailedContinue { if !config.Config.Callback.CallbackBeforeSendSingleMsg.CallbackFailedContinue {
@ -77,9 +77,9 @@ 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.PostReturn(config.Config.Callback.CallbackUrl, 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
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
return callbackResp return callbackResp
@ -99,9 +99,9 @@ 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.PostReturn(config.Config.Callback.CallbackUrl, 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
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
if !config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue { if !config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue {
@ -127,9 +127,9 @@ 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.PostReturn(config.Config.Callback.CallbackUrl, 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
callbackResp.ErrMsg = err.Error() callbackResp.ErrMsg = err.Error()
return callbackResp return callbackResp
@ -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.PostReturn(config.Config.Callback.CallbackUrl, 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

View File

@ -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 {

View File

@ -9,5 +9,5 @@ type CallbackBeforeAddFriendReq struct {
} }
type CallbackBeforeAddFriendResp struct { type CallbackBeforeAddFriendResp struct {
*CommonCallbackResp CommonCallbackResp
} }

View File

@ -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"`
}

View File

@ -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"`
} }

View File

@ -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"`
} }

View File

@ -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/////////////////////////////

View File

@ -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

View File

@ -370,6 +370,9 @@ func (d *DataBases) GetMsgBySeqListMongo2(uid string, seqList []uint32, operatio
} }
} }
} }
if len(hasSeqList) == 0 {
return nil, errors.New("pull message is null")
}
if len(hasSeqList) != len(seqList) { if len(hasSeqList) != len(seqList) {
var diff []uint32 var diff []uint32
diff = utils.Difference(hasSeqList, seqList) diff = utils.Difference(hasSeqList, seqList)

View File

@ -11,6 +11,7 @@ import (
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
urlLib "net/url"
"time" "time"
) )
@ -34,6 +35,7 @@ func Post(url string, data interface{}, timeOutSecond int) (content []byte, err
if err != nil { if err != nil {
return nil, err return nil, err
} }
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr)) req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
if err != nil { if err != nil {
return nil, err return nil, err
@ -54,7 +56,10 @@ func Post(url string, data interface{}, timeOutSecond int) (content []byte, err
return result, nil return result, nil
} }
func PostReturn(url string, input, output interface{}, timeOut int) error { func CallBackPostReturn(url, callbackCommand string, input, output interface{}, timeOut int) error {
v := urlLib.Values{}
v.Set("callbackCommand", callbackCommand)
url = url + "?" + v.Encode()
b, err := Post(url, input, timeOut) b, err := Post(url, input, timeOut)
if err != nil { if err != nil {
return err return err