This commit is contained in:
wangchuxiao
2023-06-09 19:44:45 +08:00
parent 3c02880098
commit 931991f926
5 changed files with 60 additions and 11 deletions
+9 -4
View File
@@ -2,17 +2,17 @@ package friend
import (
"context"
cbapi "github.com/OpenIMSDK/Open-IM-Server/pkg/callbackstruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/http"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
pbfriend "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
)
func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error {
log.ZInfo(ctx, "CallbackBeforeAddFriend", "in", req)
if !config.Config.Callback.CallbackBeforeAddFriend.Enable {
return nil
}
@@ -24,6 +24,11 @@ func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriend
OperationID: mcontext.GetOperationID(ctx),
}
resp := &cbapi.CallbackBeforeAddFriendResp{}
defer log.ZInfo(ctx, "CallbackBeforeAddFriend", "out", &resp)
return http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend)
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend); err != nil {
if err == errs.ErrCallbackContinue {
return nil
}
return err
}
return nil
}