update callback enable

pull/1499/head
AndrewZuo01 2 years ago
parent 4c96187c1f
commit 1789a8e73f

@ -33,6 +33,7 @@ func CallbackBeforeAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriend
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
ReqMsg: req.ReqMsg,
Ex: req.Ex,
}
resp := &cbapi.CallbackBeforeAddFriendResp{}
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, cbReq, resp, config.Config.Callback.CallbackBeforeAddFriend); err != nil {
@ -91,7 +92,6 @@ func CallbackBeforeAddBlack(ctx context.Context, req *pbfriend.AddBlackReq) erro
}
return err
}
utils.StructFieldNotNilReplace(req, resp)
return nil
}
func CallbackAfterAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) error {
@ -111,7 +111,7 @@ func CallbackAfterAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendR
}
return err
}
utils.StructFieldNotNilReplace(req, resp)
return nil
}
func CallbackBeforeAddFriendAgree(ctx context.Context, req *pbfriend.RespondFriendApplyReq) error {
@ -132,7 +132,6 @@ func CallbackBeforeAddFriendAgree(ctx context.Context, req *pbfriend.RespondFrie
}
return err
}
utils.StructFieldNotNilReplace(req, resp)
return nil
}
func CallbackAfterDeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendReq) error {
@ -151,7 +150,6 @@ func CallbackAfterDeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendRe
}
return err
}
utils.StructFieldNotNilReplace(req, resp)
return nil
}
func CallbackBeforeImportFriends(ctx context.Context, req *pbfriend.ImportFriendReq) error {
@ -170,7 +168,9 @@ func CallbackBeforeImportFriends(ctx context.Context, req *pbfriend.ImportFriend
}
return err
}
utils.StructFieldNotNilReplace(req, resp)
if len(resp.FriendUserIDs) != 0 {
req.FriendUserIDs = resp.FriendUserIDs
}
return nil
}
func CallbackAfterImportFriends(ctx context.Context, req *pbfriend.ImportFriendReq) error {
@ -189,7 +189,6 @@ func CallbackAfterImportFriends(ctx context.Context, req *pbfriend.ImportFriendR
}
return err
}
utils.StructFieldNotNilReplace(req, resp)
return nil
}
@ -209,6 +208,5 @@ func CallbackAfterRemoveBlack(ctx context.Context, req *pbfriend.RemoveBlackReq)
}
return err
}
utils.StructFieldNotNilReplace(req, resp)
return nil
}

@ -103,7 +103,7 @@ func (s *friendServer) ApplyToAddFriend(
if req.ToUserID == req.FromUserID {
return nil, errs.ErrCanNotAddYourself.Wrap()
}
if err := CallbackBeforeAddFriend(ctx, req); err != nil && err != errs.ErrCallbackContinue {
if err = CallbackBeforeAddFriend(ctx, req); err != nil && err != errs.ErrCallbackContinue {
return nil, err
}
if _, err := s.userRpcClient.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}); err != nil {
@ -120,7 +120,7 @@ func (s *friendServer) ApplyToAddFriend(
return nil, err
}
s.notificationSender.FriendApplicationAddNotification(ctx, req)
if err := CallbackAfterAddFriend(ctx, req); err != nil && err != errs.ErrCallbackContinue {
if err = CallbackAfterAddFriend(ctx, req); err != nil && err != errs.ErrCallbackContinue {
return nil, err
}
return resp, nil

@ -19,6 +19,7 @@ type CallbackBeforeAddFriendReq struct {
FromUserID string `json:"fromUserID" `
ToUserID string `json:"toUserID"`
ReqMsg string `json:"reqMsg"`
Ex string `json:"ex"`
}
type CallbackBeforeAddFriendResp struct {
@ -105,6 +106,7 @@ type CallbackBeforeImportFriendsReq struct {
}
type CallbackBeforeImportFriendsResp struct {
CommonCallbackResp
FriendUserIDs []string `json:"friendUserIDs"`
}
type CallbackAfterImportFriendsReq struct {
CallbackCommand `json:"callbackCommand"`

Loading…
Cancel
Save