Files
open-im-server/internal/rpc/friend/callback.go
T

30 lines
1.1 KiB
Go
Raw Normal View History

2022-02-28 17:57:03 +08:00
package friend
2022-10-19 21:06:48 +08:00
import (
2023-02-01 11:15:39 +08:00
"context"
2023-03-16 10:46:06 +08:00
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"
2023-06-05 17:35:41 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
2023-03-21 12:28:21 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
2023-03-16 10:46:06 +08:00
pbfriend "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
2022-10-19 21:06:48 +08:00
)
2023-02-15 15:50:52 +08:00
func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error {
2023-06-05 17:39:09 +08:00
log.ZInfo(ctx, "CallbackBeforeAddFriend", "in", req)
2022-10-19 21:06:48 +08:00
if !config.Config.Callback.CallbackBeforeAddFriend.Enable {
2023-02-15 15:50:52 +08:00
return nil
2022-10-19 21:06:48 +08:00
}
2023-02-15 15:50:52 +08:00
cbReq := &cbapi.CallbackBeforeAddFriendReq{
2022-10-19 21:06:48 +08:00
CallbackCommand: constant.CallbackBeforeAddFriendCommand,
2023-02-01 11:15:39 +08:00
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
2022-10-19 21:06:48 +08:00
ReqMsg: req.ReqMsg,
2023-03-21 12:28:21 +08:00
OperationID: mcontext.GetOperationID(ctx),
2022-10-19 21:06:48 +08:00
}
2023-02-15 15:50:52 +08:00
resp := &cbapi.CallbackBeforeAddFriendResp{}
2023-06-05 17:39:09 +08:00
defer log.ZInfo(ctx, "CallbackBeforeAddFriend", "out", &resp)
2023-06-05 17:35:41 +08:00
return http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend)
2022-10-19 21:06:48 +08:00
}