mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-01 21:08:42 +00:00
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:
commit
917c97daba
1 changed files with 11 additions and 0 deletions
|
@ -82,6 +82,17 @@ class UserFollowRequest(UserRelationship):
|
||||||
''' following a user requires manual or automatic confirmation '''
|
''' following a user requires manual or automatic confirmation '''
|
||||||
status = 'follow_request'
|
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):
|
class UserBlocks(UserRelationship):
|
||||||
''' prevent another user from following you and seeing your posts '''
|
''' prevent another user from following you and seeing your posts '''
|
||||||
|
|
Loading…
Reference in a new issue