diff --git a/pkg/server/friendships_api.go b/pkg/server/friendships_api.go index 8fd9307..aac0b6a 100644 --- a/pkg/server/friendships_api.go +++ b/pkg/server/friendships_api.go @@ -87,6 +87,8 @@ func editFriendship(c *fiber.Ctx) error { } } + friendship.Status = models.FriendshipStatus(data.Status) + if friendship, err := services.EditFriend(friendship); err != nil { return fiber.NewError(fiber.StatusBadRequest, err.Error()) } else { diff --git a/pkg/services/friendships.go b/pkg/services/friendships.go index 1f63c50..e21a12d 100644 --- a/pkg/services/friendships.go +++ b/pkg/services/friendships.go @@ -11,9 +11,8 @@ import ( func ListFriend(anyside models.Account, status models.FriendshipStatus) ([]models.AccountFriendship, error) { var relationships []models.AccountFriendship if err := database.C. - Where(&models.AccountFriendship{Status: status}). - Where(&models.AccountFriendship{AccountID: anyside.ID}). - Or(&models.AccountFriendship{RelatedID: anyside.ID}). + Where(&models.AccountFriendship{AccountID: anyside.ID, Status: status}). + Or(&models.AccountFriendship{RelatedID: anyside.ID, Status: status}). Preload("Account"). Preload("Related"). Find(&relationships).Error; err != nil {