From 7d37b8e0152f98fb359427411c143cff15f7890a Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Wed, 30 Nov 2022 19:15:02 +0800 Subject: [PATCH] update --- internal/logic/domain/friend/friend_service.go | 9 +++++++++ pkg/gerrors/define.go | 1 + 2 files changed, 10 insertions(+) diff --git a/internal/logic/domain/friend/friend_service.go b/internal/logic/domain/friend/friend_service.go index a841eea..227892a 100644 --- a/internal/logic/domain/friend/friend_service.go +++ b/internal/logic/domain/friend/friend_service.go @@ -153,6 +153,15 @@ func (*friendService) AgreeAddFriend(ctx context.Context, userId, friendId int64 // SendToFriend 消息发送至好友 func (*friendService) SendToFriend(ctx context.Context, sender *pb.Sender, req *pb.SendMessageReq) (int64, error) { + //TODO::判断是否为好友 + friend, err := FriendRepo.Get(sender.SenderId, req.ReceiverId) + if err != nil { + return 0, err + } + if friend == nil || friend.Status != FriendStatusAgree { + return 0, gerrors.ErrNotIsFriend + } + // 发给发送者 seq, err := proxy.MessageProxy.SendToUser(ctx, sender, sender.SenderId, req) if err != nil { diff --git a/pkg/gerrors/define.go b/pkg/gerrors/define.go index 54990c3..c9f8c62 100644 --- a/pkg/gerrors/define.go +++ b/pkg/gerrors/define.go @@ -16,6 +16,7 @@ var ( ErrDeviceNotExist = newError(10014, "设备不存在") ErrAlreadyIsFriend = newError(10015, "对方已经是好友了") ErrUserNotFound = newError(10016, "用户找不到") + ErrNotIsFriend = newError(10017, "对方暂不是好友") ) func newError(code int, message string) error {