Outgoing unboost

This commit is contained in:
Mouse Reeve 2020-11-07 18:31:01 -08:00
parent e6d46878fb
commit c58538539a
3 changed files with 20 additions and 0 deletions

View file

@ -320,6 +320,16 @@ def handle_boost(user, status):
broadcast(user, boost_activity) broadcast(user, boost_activity)
def handle_unboost(user, status):
''' a user regrets boosting a status '''
boost = models.Boost.objects.filter(
boosted_status=status, user=user).first()
activity = boost.to_undo_activity(user)
status_builder.delete_status(boost)
broadcast(user, activity)
def handle_update_book(user, book): def handle_update_book(user, book):
''' broadcast the news about our book ''' ''' broadcast the news about our book '''
broadcast(user, book.to_update_activity(user)) broadcast(user, book.to_update_activity(user))

View file

@ -116,6 +116,7 @@ urlpatterns = [
re_path(r'^favorite/(?P<status_id>\d+)/?$', actions.favorite), re_path(r'^favorite/(?P<status_id>\d+)/?$', actions.favorite),
re_path(r'^unfavorite/(?P<status_id>\d+)/?$', actions.unfavorite), re_path(r'^unfavorite/(?P<status_id>\d+)/?$', actions.unfavorite),
re_path(r'^boost/(?P<status_id>\d+)/?$', actions.boost), re_path(r'^boost/(?P<status_id>\d+)/?$', actions.boost),
re_path(r'^unboost/(?P<status_id>\d+)/?$', actions.boost),
re_path(r'^delete-status/?$', actions.delete_status), re_path(r'^delete-status/?$', actions.delete_status),

View file

@ -508,6 +508,7 @@ def unfavorite(request, status_id):
outgoing.handle_unfavorite(request.user, status) outgoing.handle_unfavorite(request.user, status)
return redirect(request.headers.get('Referer', '/')) return redirect(request.headers.get('Referer', '/'))
@login_required @login_required
def boost(request, status_id): def boost(request, status_id):
''' boost a status ''' ''' boost a status '''
@ -516,6 +517,14 @@ def boost(request, status_id):
return redirect(request.headers.get('Referer', '/')) return redirect(request.headers.get('Referer', '/'))
@login_required
def unboost(request, status_id):
''' boost a status '''
status = models.Status.objects.get(id=status_id)
outgoing.handle_unboost(request.user, status)
return redirect(request.headers.get('Referer', '/'))
@login_required @login_required
def delete_status(request): def delete_status(request):
''' delete and tombstone a status ''' ''' delete and tombstone a status '''