diff --git a/pkg/internal/services/relationships.go b/pkg/internal/services/relationships.go index 66741cd..3db8c61 100644 --- a/pkg/internal/services/relationships.go +++ b/pkg/internal/services/relationships.go @@ -1,8 +1,8 @@ package services import ( - "errors" "fmt" + "git.solsynth.dev/hypernet/passport/pkg/authkit/models" "git.solsynth.dev/hypernet/passport/pkg/internal/database" @@ -112,6 +112,10 @@ func NewFriend(userA models.Account, userB models.Account, skipPending ...bool) Status: models.RelationshipPending, } + if userA.ID == userB.ID { + return relA, fmt.Errorf("unable to make relationship with yourself") + } + var dupeCount int if rel, err := GetRelationWithTwoNode(userA.ID, userB.ID, true); err == nil { relA = rel @@ -131,12 +135,6 @@ func NewFriend(userA models.Account, userB models.Account, skipPending ...bool) relB.Status = models.RelationshipFriend } - if userA.ID == userB.ID { - return relA, fmt.Errorf("unable to make relationship with yourself") - } else if _, err := GetRelationWithTwoNode(userA.ID, userB.ID, true); err == nil || !errors.Is(err, gorm.ErrRecordNotFound) { - return relA, fmt.Errorf("unable to recreate a relationship with that user") - } - if err := database.C.Save(&relA).Error; err != nil { return relA, err } else if err = database.C.Save(&relB).Error; err != nil {