|
|
@ -118,7 +118,7 @@ func Start(config *config.GlobalConfig, client registry.SvcDiscoveryRegistry, se
|
|
|
|
// ok.
|
|
|
|
// ok.
|
|
|
|
func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) {
|
|
|
|
func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.ApplyToAddFriendReq) (resp *pbfriend.ApplyToAddFriendResp, err error) {
|
|
|
|
resp = &pbfriend.ApplyToAddFriendResp{}
|
|
|
|
resp = &pbfriend.ApplyToAddFriendResp{}
|
|
|
|
if err = authverify.CheckAccessV3(ctx, req.FromUserID, s.config); err != nil {
|
|
|
|
if accessErr := authverify.CheckAccessV3(ctx, req.FromUserID, s.config); accessErr != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if req.ToUserID == req.FromUserID {
|
|
|
|
if req.ToUserID == req.FromUserID {
|
|
|
@ -127,7 +127,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
|
|
|
|
if err = CallbackBeforeAddFriend(ctx, s.config, req); err != nil && err != errs.ErrCallbackContinue {
|
|
|
|
if err = CallbackBeforeAddFriend(ctx, s.config, req); err != nil && err != errs.ErrCallbackContinue {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if _, err := s.userRpcClient.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}); err != nil {
|
|
|
|
if _, getUserInfoErr := s.userRpcClient.GetUsersInfoMap(ctx, []string{req.ToUserID, req.FromUserID}); getUserInfoErr != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
in1, in2, err := s.friendDatabase.CheckIn(ctx, req.FromUserID, req.ToUserID)
|
|
|
|
in1, in2, err := s.friendDatabase.CheckIn(ctx, req.FromUserID, req.ToUserID)
|
|
|
@ -222,7 +222,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.Res
|
|
|
|
func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendReq) (resp *pbfriend.DeleteFriendResp, err error) {
|
|
|
|
func (s *friendServer) DeleteFriend(ctx context.Context, req *pbfriend.DeleteFriendReq) (resp *pbfriend.DeleteFriendResp, err error) {
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
resp = &pbfriend.DeleteFriendResp{}
|
|
|
|
resp = &pbfriend.DeleteFriendResp{}
|
|
|
|
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
|
|
|
|
if accessErr := s.userRpcClient.Access(ctx, req.OwnerUserID); accessErr != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_, err = s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID})
|
|
|
|
_, err = s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID})
|
|
|
@ -247,7 +247,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFri
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resp = &pbfriend.SetFriendRemarkResp{}
|
|
|
|
resp = &pbfriend.SetFriendRemarkResp{}
|
|
|
|
if err := s.userRpcClient.Access(ctx, req.OwnerUserID); err != nil {
|
|
|
|
if accessErr := s.userRpcClient.Access(ctx, req.OwnerUserID); accessErr != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_, err = s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID})
|
|
|
|
_, err = s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, []string{req.FriendUserID})
|
|
|
@ -298,7 +298,7 @@ func (s *friendServer) GetDesignatedFriendsApply(ctx context.Context,
|
|
|
|
// ok 获取接收到的好友申请(即别人主动申请的).
|
|
|
|
// ok 获取接收到的好友申请(即别人主动申请的).
|
|
|
|
func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyToReq) (resp *pbfriend.GetPaginationFriendsApplyToResp, err error) {
|
|
|
|
func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyToReq) (resp *pbfriend.GetPaginationFriendsApplyToResp, err error) {
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
|
|
|
|
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
total, friendRequests, err := s.friendDatabase.PageFriendRequestToMe(ctx, req.UserID, req.Pagination)
|
|
|
|
total, friendRequests, err := s.friendDatabase.PageFriendRequestToMe(ctx, req.UserID, req.Pagination)
|
|
|
@ -318,7 +318,7 @@ func (s *friendServer) GetPaginationFriendsApplyTo(ctx context.Context, req *pbf
|
|
|
|
func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyFromReq) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) {
|
|
|
|
func (s *friendServer) GetPaginationFriendsApplyFrom(ctx context.Context, req *pbfriend.GetPaginationFriendsApplyFromReq) (resp *pbfriend.GetPaginationFriendsApplyFromResp, err error) {
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
resp = &pbfriend.GetPaginationFriendsApplyFromResp{}
|
|
|
|
resp = &pbfriend.GetPaginationFriendsApplyFromResp{}
|
|
|
|
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
|
|
|
|
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
total, friendRequests, err := s.friendDatabase.PageFriendRequestFromMe(ctx, req.UserID, req.Pagination)
|
|
|
|
total, friendRequests, err := s.friendDatabase.PageFriendRequestFromMe(ctx, req.UserID, req.Pagination)
|
|
|
@ -346,7 +346,7 @@ func (s *friendServer) IsFriend(ctx context.Context, req *pbfriend.IsFriendReq)
|
|
|
|
|
|
|
|
|
|
|
|
func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.GetPaginationFriendsReq) (resp *pbfriend.GetPaginationFriendsResp, err error) {
|
|
|
|
func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.GetPaginationFriendsReq) (resp *pbfriend.GetPaginationFriendsResp, err error) {
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
|
|
|
|
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
total, friends, err := s.friendDatabase.PageOwnerFriends(ctx, req.UserID, req.Pagination)
|
|
|
|
total, friends, err := s.friendDatabase.PageOwnerFriends(ctx, req.UserID, req.Pagination)
|
|
|
@ -364,7 +364,7 @@ func (s *friendServer) GetPaginationFriends(ctx context.Context, req *pbfriend.G
|
|
|
|
|
|
|
|
|
|
|
|
func (s *friendServer) GetFriendIDs(ctx context.Context, req *pbfriend.GetFriendIDsReq) (resp *pbfriend.GetFriendIDsResp, err error) {
|
|
|
|
func (s *friendServer) GetFriendIDs(ctx context.Context, req *pbfriend.GetFriendIDsReq) (resp *pbfriend.GetFriendIDsResp, err error) {
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
defer log.ZInfo(ctx, utils.GetFuncName()+" Return")
|
|
|
|
if err := s.userRpcClient.Access(ctx, req.UserID); err != nil {
|
|
|
|
if accessErr := s.userRpcClient.Access(ctx, req.UserID); accessErr != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resp = &pbfriend.GetFriendIDsResp{}
|
|
|
|
resp = &pbfriend.GetFriendIDsResp{}
|
|
|
|