diff --git a/cmd/rpc/open_im_msg/filters/mock.go b/cmd/rpc/open_im_msg/filters/mock.go index 950cf6124..6c6994009 100644 --- a/cmd/rpc/open_im_msg/filters/mock.go +++ b/cmd/rpc/open_im_msg/filters/mock.go @@ -47,9 +47,10 @@ func MockBeforeSendFilter2(ctx *rpcChat.SendContext, pb *pbChat.SendMsgReq) (*pb } fmt.Printf("MockBeforeSendFilter2 trigger,contentType:%d\n", pb.MsgData.GetContentType()) + msg := string(pb.MsgData.Content) + fmt.Printf("msg content:%s\n", msg) if pb.MsgData.ContentType == constant.Text { msg := string(pb.MsgData.Content) - // fmt.Printf("text msg:%s\n", msg) if msg == "this is a m..m..mock msg" { fmt.Println(".==>msg had banned") return nil, false, errors.New("BANG! This msg has been banned by MockBeforeSendHandler") diff --git a/internal/rpc/msg/context.go b/internal/rpc/msg/context.go index 5206ae347..c8c8f77c7 100644 --- a/internal/rpc/msg/context.go +++ b/internal/rpc/msg/context.go @@ -45,17 +45,21 @@ func (c *SendContext) doBeforeFilters(pb *pbChat.SendMsgReq) (*pbChat.SendMsgRes // doAfterFilters executes the pending filters in the chain inside the calling handler. func (c *SendContext) doAfterFilters(req *pbChat.SendMsgReq, res *pbChat.SendMsgResp) (*pbChat.SendMsgResp, bool, error) { + var ( + ok bool + err error + ) for _, handler := range c.afterSenders { - res, ok, err := handler(c, req, res) + res, ok, err = handler(c, req, res) if err != nil { - return nil, false, err + return res, false, err } if !ok { return res, ok, nil } } - return nil, true, nil + return res, true, nil } func (c *SendContext) SendMsg(pb *pbChat.SendMsgReq) (*pbChat.SendMsgResp, error) {