You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/rpc/friend/callback.go

27 lines
1001 B

3 years ago
package friend
import (
"context"
2 years ago
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"
2 years ago
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/mcontext"
2 years ago
pbfriend "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/friend"
)
2 years ago
func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error {
if !config.Config.Callback.CallbackBeforeAddFriend.Enable {
2 years ago
return nil
}
2 years ago
cbReq := &cbapi.CallbackBeforeAddFriendReq{
CallbackCommand: constant.CallbackBeforeAddFriendCommand,
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
ReqMsg: req.ReqMsg,
2 years ago
OperationID: mcontext.GetOperationID(ctx),
}
2 years ago
resp := &cbapi.CallbackBeforeAddFriendResp{}
return http.CallBackPostReturn(config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend)
}