From 3281e2165eb1ab2c99f6c2a18b24eefda8ba8e86 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sat, 7 Jul 2018 12:10:25 +0200 Subject: [PATCH] Bugfix for undo boosts/likes --- activitypub.py | 8 ++++++++ templates/index.html | 16 +++++++++++++++- templates/liked.html | 11 +++++++++++ templates/stream.html | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/activitypub.py b/activitypub.py index b891674..b5ed7c9 100644 --- a/activitypub.py +++ b/activitypub.py @@ -180,6 +180,7 @@ class MicroblogPubBackend(Backend): {"box": Box.OUTBOX.value, "activity.object.id": obj.id}, {"$inc": {"meta.count_like": -1}}, ) + DB.activities.update_one({"remote_id": like.id}, {"$set": {"meta.undo": True}}) @ensure_it_is_me def outbox_like(self, as_actor: ap.Person, like: ap.Like) -> None: @@ -199,6 +200,7 @@ class MicroblogPubBackend(Backend): {"activity.object.id": obj.id}, {"$inc": {"meta.count_like": -1}, "$set": {"meta.liked": False}}, ) + DB.activities.update_one({"remote_id": like.id}, {"$set": {"meta.undo": True}}) @ensure_it_is_me def inbox_announce(self, as_actor: ap.Person, announce: ap.Announce) -> None: @@ -228,6 +230,9 @@ class MicroblogPubBackend(Backend): DB.activities.update_one( {"activity.object.id": obj.id}, {"$inc": {"meta.count_boost": -1}} ) + DB.activities.update_one( + {"remote_id": announce.id}, {"$set": {"meta.undo": True}} + ) @ensure_it_is_me def outbox_announce(self, as_actor: ap.Person, announce: ap.Announce) -> None: @@ -246,6 +251,9 @@ class MicroblogPubBackend(Backend): DB.activities.update_one( {"activity.object.id": obj.id}, {"$set": {"meta.boosted": False}} ) + DB.activities.update_one( + {"remote_id": announce.id}, {"$set": {"meta.undo": True}} + ) @ensure_it_is_me def inbox_delete(self, as_actor: ap.Person, delete: ap.Delete) -> None: diff --git a/templates/index.html b/templates/index.html index 115e65e..10ba52f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -25,7 +25,21 @@ {% if item | has_type('Announce') %} {% set boost_actor = item.activity.actor | get_actor %} -

{{ boost_actor.name }} boosted

+ {% if session.logged_in %} +
+ {{ boost_actor.name }} boosted +
+ + + + +
+
+ {% else %} +

+ {{ boost_actor.name }} boosted +

+ {% endif %} {% if item.meta.object %} {{ utils.display_note(item.meta.object, ui=False) }} {% endif %} diff --git a/templates/liked.html b/templates/liked.html index c8bf71e..8255fdf 100644 --- a/templates/liked.html +++ b/templates/liked.html @@ -8,6 +8,17 @@
{% for item in liked %} + {% if session.logged_in %} +
+
+ + + + +
+
+ + {% endif %} {% if item.meta.object %} {{ utils.display_note(item.meta.object) }} {% endif %} diff --git a/templates/stream.html b/templates/stream.html index 41ceecd..26fdc3b 100644 --- a/templates/stream.html +++ b/templates/stream.html @@ -9,7 +9,7 @@
{% for item in inbox_data %} {% if item | has_type('Create') %} - {{ utils.display_note(item.activity.object, ui=True) }} + {{ utils.display_note(item.activity.object, ui=True, meta=item.meta) }} {% else %} {% if item | has_type('Announce') %}