mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-03 01:52:17 +08:00
feat add afterSendFilters mock
This commit is contained in:
parent
7a6568a4fe
commit
f1229be04c
@ -37,3 +37,16 @@ func MockBeforeSendFilter2(ctx *rpcChat.SendContext, pb *pbChat.SendMsgReq) (*pb
|
||||
|
||||
return nil, true, nil
|
||||
}
|
||||
|
||||
// MockAfterSendFilter is a mock handle that handles custom logic after send msg.
|
||||
func MockAfterSendFilter(ctx *rpcChat.SendContext, pb *pbChat.SendMsgReq, res *pbChat.SendMsgResp) (*pbChat.SendMsgResp, bool, error) {
|
||||
ctxKey := "test_key"
|
||||
v, ok := ctx.Value(ctxKey).(bool)
|
||||
if ok {
|
||||
fmt.Printf("MockAfterSendFilter:%s selected from ctx,value is :%v\n", ctxKey, v)
|
||||
}
|
||||
|
||||
fmt.Printf("MockAfterSendFilter trigger,contentType:%d\n", pb.MsgData.GetContentType())
|
||||
|
||||
return res, true, nil
|
||||
}
|
||||
|
||||
@ -15,6 +15,8 @@ func main() {
|
||||
// mock 注册发送前的拦截器
|
||||
rpcServer.UseBeforSendFilters(filters.MockBeforeSendFilter1, filters.MockBeforeSendFilter2)
|
||||
|
||||
rpcServer.UseAfterSendFilters(filters.MockAfterSendFilter)
|
||||
|
||||
//
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user