Merge pull request #273 from mouse-reeve/follow-reqest-dupe

Prevent creating follow requests when there's already a follow
This commit is contained in:
Mouse Reeve 2020-11-02 11:52:36 -08:00 committed by GitHub
commit 917c97daba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -82,6 +82,17 @@ class UserFollowRequest(UserRelationship):
''' following a user requires manual or automatic confirmation '''
status = 'follow_request'
def save(self, *args, **kwargs):
''' make sure the follow relationship doesn't already exist '''
try:
UserFollows.objects.get(
user_subject=self.user_subject,
user_object=self.user_object
)
return None
except UserFollows.DoesNotExist:
return super().save(*args, **kwargs)
class UserBlocks(UserRelationship):
''' prevent another user from following you and seeing your posts '''