forked from mirrors/bookwyrm
Disable boosting private statuses
This commit is contained in:
parent
ee8e46ca52
commit
40c4f4f5de
3 changed files with 12 additions and 2 deletions
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{% load bookwyrm_tags %}
|
||||
|
||||
{% with status.id|uuid as uuid %}
|
||||
<form name="boost" action="/boost/{{ status.id }}" method="post" onsubmit="return interact(event)" class="boost-{{ status.id }}-{{ uuid }} {% if request.user|boosted:status %}hidden{% endif %}" data-id="boost-{{ status.id }}-{{ uuid }}">
|
||||
{% csrf_token %}
|
||||
<button class="button is-small" type="submit">
|
||||
<button class="button is-small" type="submit" {% if not status.boostable %}disabled{% endif %}>
|
||||
<span class="icon icon-boost">
|
||||
<span class="is-sr-only">Boost status</span>
|
||||
</span>
|
||||
|
|
Loading…
Reference in a new issue