Follow and Following

This commit is contained in:
2024-02-03 20:44:16 +08:00
parent 6c52a862a5
commit df60a112ae
5 changed files with 66 additions and 10 deletions

View File

@ -3,8 +3,6 @@ package services
import (
"code.smartsheep.studio/hydrogen/interactive/pkg/database"
"code.smartsheep.studio/hydrogen/interactive/pkg/models"
"errors"
"gorm.io/gorm"
)
func FollowAccount(followerId, followingId uint) error {
@ -26,7 +24,7 @@ func GetAccountFollowed(user models.Account, target models.Account) (models.Acco
var relationship models.AccountMembership
err := database.C.Model(&models.AccountMembership{}).
Where(&models.AccountMembership{FollowerID: user.ID, FollowingID: target.ID}).
Find(&relationship).
First(&relationship).
Error
return relationship, !errors.Is(err, gorm.ErrRecordNotFound)
return relationship, err == nil
}