mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-22 16:16:39 +00:00
Don't create duplicate boosts.
This commit is contained in:
parent
acffb36f46
commit
a4c257a8d2
1 changed files with 8 additions and 9 deletions
|
@ -293,16 +293,15 @@ def handle_unfavorite(user, status):
|
|||
|
||||
def handle_boost(user, status):
|
||||
''' a user wishes to boost a status '''
|
||||
try:
|
||||
boost = models.Boost.objects.create(
|
||||
boosted_status=status,
|
||||
user=user,
|
||||
)
|
||||
boost.save()
|
||||
except IntegrityError:
|
||||
# you already boosted that
|
||||
# TODO - doesn't work because unique constraint isn't enforcable.
|
||||
if models.Boost.objects.filter(
|
||||
boosted_status=status, user=user).exists():
|
||||
# you already boosted that.
|
||||
return
|
||||
boost = models.Boost.objects.create(
|
||||
boosted_status=status,
|
||||
user=user,
|
||||
)
|
||||
boost.save()
|
||||
|
||||
boost_activity = activitypub.get_boost(boost)
|
||||
recipients = get_recipients(user, 'public')
|
||||
|
|
Loading…
Reference in a new issue