forked from mirrors/bookwyrm
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):
|
def handle_boost(user, status):
|
||||||
''' a user wishes to boost a status '''
|
''' a user wishes to boost a status '''
|
||||||
try:
|
if models.Boost.objects.filter(
|
||||||
boost = models.Boost.objects.create(
|
boosted_status=status, user=user).exists():
|
||||||
boosted_status=status,
|
# you already boosted that.
|
||||||
user=user,
|
|
||||||
)
|
|
||||||
boost.save()
|
|
||||||
except IntegrityError:
|
|
||||||
# you already boosted that
|
|
||||||
# TODO - doesn't work because unique constraint isn't enforcable.
|
|
||||||
return
|
return
|
||||||
|
boost = models.Boost.objects.create(
|
||||||
|
boosted_status=status,
|
||||||
|
user=user,
|
||||||
|
)
|
||||||
|
boost.save()
|
||||||
|
|
||||||
boost_activity = activitypub.get_boost(boost)
|
boost_activity = activitypub.get_boost(boost)
|
||||||
recipients = get_recipients(user, 'public')
|
recipients = get_recipients(user, 'public')
|
||||||
|
|
Loading…
Reference in a new issue