Don't create duplicate boosts.

This commit is contained in:
Adam Kelly 2020-03-30 16:39:53 +01:00
parent acffb36f46
commit a4c257a8d2

View file

@ -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')