|
|
|
package friend
|
|
|
|
|
|
|
|
import (
|
|
|
|
cbapi "Open_IM/pkg/callbackstruct"
|
|
|
|
"Open_IM/pkg/common/config"
|
|
|
|
"Open_IM/pkg/common/constant"
|
|
|
|
"Open_IM/pkg/common/http"
|
|
|
|
"Open_IM/pkg/common/tracelog"
|
|
|
|
pbfriend "Open_IM/pkg/proto/friend"
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error {
|
|
|
|
if !config.Config.Callback.CallbackBeforeAddFriend.Enable {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
cbReq := &cbapi.CallbackBeforeAddFriendReq{
|
|
|
|
CallbackCommand: constant.CallbackBeforeAddFriendCommand,
|
|
|
|
FromUserID: req.FromUserID,
|
|
|
|
ToUserID: req.ToUserID,
|
|
|
|
ReqMsg: req.ReqMsg,
|
|
|
|
OperationID: tracelog.GetOperationID(ctx),
|
|
|
|
}
|
|
|
|
resp := &cbapi.CallbackBeforeAddFriendResp{}
|
|
|
|
return http.CallBackPostReturn(config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend)
|
|
|
|
}
|