Disable boosting private statuses
This commit is contained in:
parent
ee8e46ca52
commit
40c4f4f5de
|
@ -59,6 +59,11 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
||||||
''' expose the type of status for the ui using activity type '''
|
''' expose the type of status for the ui using activity type '''
|
||||||
return self.activity_serializer.__name__
|
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):
|
def to_replies(self, **kwargs):
|
||||||
''' helper function for loading AP serialized replies to a status '''
|
''' helper function for loading AP serialized replies to a status '''
|
||||||
return self.to_ordered_collection(
|
return self.to_ordered_collection(
|
||||||
|
|
|
@ -315,15 +315,19 @@ 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 '''
|
||||||
|
# is it boostable?
|
||||||
|
if not status.boostable:
|
||||||
|
return
|
||||||
|
|
||||||
if models.Boost.objects.filter(
|
if models.Boost.objects.filter(
|
||||||
boosted_status=status, user=user).exists():
|
boosted_status=status, user=user).exists():
|
||||||
# you already boosted that.
|
# you already boosted that.
|
||||||
return
|
return
|
||||||
boost = models.Boost.objects.create(
|
boost = models.Boost.objects.create(
|
||||||
boosted_status=status,
|
boosted_status=status,
|
||||||
|
privacy=status.privacy,
|
||||||
user=user,
|
user=user,
|
||||||
)
|
)
|
||||||
boost.save()
|
|
||||||
|
|
||||||
boost_activity = boost.to_activity()
|
boost_activity = boost.to_activity()
|
||||||
broadcast(user, boost_activity)
|
broadcast(user, boost_activity)
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{% load bookwyrm_tags %}
|
{% load bookwyrm_tags %}
|
||||||
|
|
||||||
{% with status.id|uuid as uuid %}
|
{% 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 }}">
|
<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 %}
|
{% 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="icon icon-boost">
|
||||||
<span class="is-sr-only">Boost status</span>
|
<span class="is-sr-only">Boost status</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in New Issue