From 40c4f4f5dec9505b308ad9b235cba7d1d72d54cb Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 18 Dec 2020 09:30:08 -0800 Subject: [PATCH 1/3] Disable boosting private statuses --- bookwyrm/models/status.py | 5 +++++ bookwyrm/outgoing.py | 6 +++++- bookwyrm/templates/snippets/boost_button.html | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index b358554c1..f346bc47e 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -59,6 +59,11 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): ''' expose the type of status for the ui using activity type ''' return self.activity_serializer.__name__ + @property + def boostable(self): + ''' you can't boost dms ''' + return self.privacy in ['unlisted', 'public'] + def to_replies(self, **kwargs): ''' helper function for loading AP serialized replies to a status ''' return self.to_ordered_collection( diff --git a/bookwyrm/outgoing.py b/bookwyrm/outgoing.py index 65a253e95..209b5858a 100644 --- a/bookwyrm/outgoing.py +++ b/bookwyrm/outgoing.py @@ -315,15 +315,19 @@ def handle_unfavorite(user, status): def handle_boost(user, status): ''' a user wishes to boost a status ''' + # is it boostable? + if not status.boostable: + return + if models.Boost.objects.filter( boosted_status=status, user=user).exists(): # you already boosted that. return boost = models.Boost.objects.create( boosted_status=status, + privacy=status.privacy, user=user, ) - boost.save() boost_activity = boost.to_activity() broadcast(user, boost_activity) diff --git a/bookwyrm/templates/snippets/boost_button.html b/bookwyrm/templates/snippets/boost_button.html index bf06cef73..02b557944 100644 --- a/bookwyrm/templates/snippets/boost_button.html +++ b/bookwyrm/templates/snippets/boost_button.html @@ -1,8 +1,9 @@ {% load bookwyrm_tags %} + {% with status.id|uuid as uuid %}
{% csrf_token %} -