🐛 Fix friend detection
This commit is contained in:
parent
49363c801a
commit
ed9066ca7b
@ -35,12 +35,21 @@ func GetAccountFollowed(user models.Account, target models.Account) (models.Acco
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetAccountFriend(userId, relatedId uint, status int) (*proto.FriendshipResponse, error) {
|
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)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
return grpc.Friendships.GetFriendship(ctx, &proto.FriendshipTwoSideLookupRequest{
|
return grpc.Friendships.GetFriendship(ctx, &proto.FriendshipTwoSideLookupRequest{
|
||||||
AccountId: uint64(userId),
|
AccountId: uint64(user.ExternalID),
|
||||||
RelatedId: uint64(relatedId),
|
RelatedId: uint64(related.ExternalID),
|
||||||
Status: uint32(status),
|
Status: uint32(status),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user