From ed9066ca7b97508b88bdd8ff6c44dedffb9cb4a6 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 6 Apr 2024 23:23:29 +0800 Subject: [PATCH] :bug: Fix friend detection --- pkg/services/accounts.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/services/accounts.go b/pkg/services/accounts.go index 583a847..5503465 100644 --- a/pkg/services/accounts.go +++ b/pkg/services/accounts.go @@ -35,12 +35,21 @@ func GetAccountFollowed(user models.Account, target models.Account) (models.Acco } func GetAccountFriend(userId, relatedId uint, status int) (*proto.FriendshipResponse, error) { + var user models.Account + if err := database.C.Where("id = ?", userId).First(&user).Error; err != nil { + return nil, err + } + var related models.Account + if err := database.C.Where("id = ?", relatedId).First(&related).Error; err != nil { + return nil, err + } + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() return grpc.Friendships.GetFriendship(ctx, &proto.FriendshipTwoSideLookupRequest{ - AccountId: uint64(userId), - RelatedId: uint64(relatedId), + AccountId: uint64(user.ExternalID), + RelatedId: uint64(related.ExternalID), Status: uint32(status), }) }