From e6d46878fb691d7d24b7ddeb7d0c9de53f9238d0 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Sat, 7 Nov 2020 18:18:44 -0800 Subject: [PATCH] Fixes like/unlike statuses --- bookwyrm/incoming.py | 7 ++++++- bookwyrm/outgoing.py | 3 ++- bookwyrm/templates/snippets/boost_button.html | 4 ++-- bookwyrm/templates/snippets/create_status_form.html | 2 +- bookwyrm/templates/snippets/fav_button.html | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/bookwyrm/incoming.py b/bookwyrm/incoming.py index a7823f43..ad44fd97 100644 --- a/bookwyrm/incoming.py +++ b/bookwyrm/incoming.py @@ -269,7 +269,12 @@ def handle_favorite(activity): @app.task def handle_unfavorite(activity): ''' approval of your good good post ''' - like = activitypub.Like(**activity['object']).to_model(models.Favorite) + try: + like = models.Favorite.objects.filter( + remote_id=activity['object']['id'] + ).first() + except models.Favorite.DoesNotExist: + return like.delete() diff --git a/bookwyrm/outgoing.py b/bookwyrm/outgoing.py index 1b21603e..7a21048b 100644 --- a/bookwyrm/outgoing.py +++ b/bookwyrm/outgoing.py @@ -299,7 +299,8 @@ def handle_unfavorite(user, status): # can't find that status, idk return - fav_activity = activitypub.Undo(actor=user, object=favorite) + fav_activity = favorite.to_undo_activity(user) + favorite.delete() broadcast(user, fav_activity, direct_recipients=[status.user]) diff --git a/bookwyrm/templates/snippets/boost_button.html b/bookwyrm/templates/snippets/boost_button.html index 7133e818..2c747fe2 100644 --- a/bookwyrm/templates/snippets/boost_button.html +++ b/bookwyrm/templates/snippets/boost_button.html @@ -1,6 +1,6 @@ {% load fr_display %} {% with activity.id|uuid as uuid %} -
+ {% csrf_token %}
-
+ {% csrf_token %}
-
+ {% csrf_token %}