mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-30 16:02:17 +08:00
add callback
This commit is contained in:
parent
60e29cc894
commit
f1c11ac114
@ -202,7 +202,6 @@ callback:
|
|||||||
callbackAfterSendSingleMsg:
|
callbackAfterSendSingleMsg:
|
||||||
enable: true
|
enable: true
|
||||||
callbackTimeOut: 5
|
callbackTimeOut: 5
|
||||||
CallbackFailedContinue: true
|
|
||||||
callbackBeforeSendGroupMsg:
|
callbackBeforeSendGroupMsg:
|
||||||
enable: true
|
enable: true
|
||||||
callbackTimeOut: 5
|
callbackTimeOut: 5
|
||||||
@ -210,7 +209,6 @@ callback:
|
|||||||
callbackAfterSendGroupMsg:
|
callbackAfterSendGroupMsg:
|
||||||
enable: true
|
enable: true
|
||||||
callbackTimeOut: 5
|
callbackTimeOut: 5
|
||||||
CallbackFailedContinue: true
|
|
||||||
callbackWordFilter:
|
callbackWordFilter:
|
||||||
enable: true
|
enable: true
|
||||||
callbackTimeOut: 5
|
callbackTimeOut: 5
|
||||||
|
|||||||
@ -62,9 +62,10 @@ func callbackBeforeSendGroupMsg(msg *pbChat.SendMsgReq) (canSend bool, err error
|
|||||||
if !config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue {
|
if !config.Config.Callback.CallbackBeforeSendGroupMsg.CallbackFailedContinue {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
if resp.ActionCode == constant.ActionForbidden {
|
if resp.ActionCode == constant.ActionForbidden {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
@ -94,15 +95,17 @@ func callBackWordFilter(msg *pbChat.SendMsgReq) (canSend bool, err error) {
|
|||||||
resp := &cbApi.CallbackWordFilterResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
|
resp := &cbApi.CallbackWordFilterResp{CommonCallbackResp: cbApi.CommonCallbackResp{}}
|
||||||
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, resp)
|
defer log.NewDebug(msg.OperationID, utils.GetSelfFuncName(), req, resp)
|
||||||
utils.CopyStructFields(&req, msg.MsgData)
|
utils.CopyStructFields(&req, msg.MsgData)
|
||||||
|
req.Content = string(msg.MsgData.Content)
|
||||||
if err := http.PostReturn(msg.OperationID, req, resp, config.Config.Callback.CallbackWordFilter.CallbackTimeOut); err != nil {
|
if err := http.PostReturn(msg.OperationID, req, resp, config.Config.Callback.CallbackWordFilter.CallbackTimeOut); err != nil {
|
||||||
if !config.Config.Callback.CallbackWordFilter.CallbackFailedContinue {
|
if !config.Config.Callback.CallbackWordFilter.CallbackFailedContinue {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
msg.MsgData.Content = []byte(resp.Content)
|
||||||
|
if resp.ActionCode == constant.ActionForbidden {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if resp.ActionCode == constant.ActionForbidden {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
msg.MsgData.Content = resp.Content
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,7 +5,7 @@ type msg struct {
|
|||||||
ClientMsgID string `json:"clientMsgID"`
|
ClientMsgID string `json:"clientMsgID"`
|
||||||
ServerMsgID string `json:"serverMsgId"`
|
ServerMsgID string `json:"serverMsgId"`
|
||||||
CreateTime int64 `json:"createTime"`
|
CreateTime int64 `json:"createTime"`
|
||||||
Content []byte `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type singleMsg struct {
|
type singleMsg struct {
|
||||||
@ -58,10 +58,10 @@ type CallbackAfterSendGroupMsgResp struct {
|
|||||||
|
|
||||||
type CallbackWordFilterReq struct {
|
type CallbackWordFilterReq struct {
|
||||||
CommonCallbackReq
|
CommonCallbackReq
|
||||||
Content []byte `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CallbackWordFilterResp struct {
|
type CallbackWordFilterResp struct {
|
||||||
CommonCallbackResp
|
CommonCallbackResp
|
||||||
Content []byte `json:"content"`
|
Content string `json:"content"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user