From f365784f93a967bd2eae47abf274d82e791e627f Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 26 Jun 2022 10:55:53 +0200 Subject: [PATCH] Tweak notifications --- app/boxes.py | 8 ++++++++ app/models.py | 1 + app/templates/notifications.html | 21 +++++++++++++-------- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/boxes.py b/app/boxes.py index b879f8e..6c26385 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -617,6 +617,14 @@ def save_to_inbox(db: Session, raw_object: ap.RawObject) -> None: "Received an Accept for an unsupported activity: " f"{relates_to_outbox_object.ap_type}" ) + elif ra.ap_type == "EmojiReact": + if not relates_to_outbox_object: + logger.info( + f"Received a like for an unknown activity: {ra.activity_object_ap_id}" + ) + else: + # TODO(ts): support reactions + pass elif ra.ap_type == "Like": if not relates_to_outbox_object: logger.info( diff --git a/app/models.py b/app/models.py index c4aefb2..89fb6c7 100644 --- a/app/models.py +++ b/app/models.py @@ -150,6 +150,7 @@ class OutboxObject(Base, BaseObject): likes_count = Column(Integer, nullable=False, default=0) announces_count = Column(Integer, nullable=False, default=0) replies_count = Column(Integer, nullable=False, default=0) + # reactions: Mapped[list[dict[str, Any]] | None] = Column(JSON, nullable=True) webmentions = Column(JSON, nullable=True) diff --git a/app/templates/notifications.html b/app/templates/notifications.html index 7aa29a8..76b4e5c 100644 --- a/app/templates/notifications.html +++ b/app/templates/notifications.html @@ -7,37 +7,42 @@
{%- if notif.notification_type.value == "new_follower" %}
- {{ notif.actor.name or notif.actor.preferred_username }} followed you + {{ notif.actor.display_name }} followed you
{{ utils.display_actor(notif.actor, actors_metadata) }} {% elif notif.notification_type.value == "unfollow" %}
- {{ notif.actor.name or notif.actor.preferred_username }} unfollowed you + {{ notif.actor.display_name }} unfollowed you
{{ utils.display_actor(notif.actor, actors_metadata) }} {% elif notif.notification_type.value == "like" %}
- {{ notif.actor.name or notif.actor.preferred_username }} liked a post + {{ notif.actor.display_name }} liked a post
{{ utils.display_object(notif.outbox_object) }} {% elif notif.notification_type.value == "undo_like" %}
- {{ notif.actor.name or notif.actor.preferred_username }} un-liked a post + {{ notif.actor.display_name }} un-liked a post
{{ utils.display_object(notif.outbox_object) }} {% elif notif.notification_type.value == "announce" %}
- {{ notif.actor.name or notif.actor.preferred_username }} boosted a post + {{ notif.actor.display_name }} boosted a post
{{ utils.display_object(notif.outbox_object) }} {% elif notif.notification_type.value == "undo_announce" %}
- {{ notif.actor.name or notif.actor.preferred_username }} un-boosted a post + {{ notif.actor.display_name }} un-boosted a post
{{ utils.display_object(notif.outbox_object) }} - + {% elif notif.notification_type.value == "mention" %} +
+ {{ notif.actor.display_name }} mentioned you +
+ {{ utils.display_object(notif.inbox_object) }} + {% else %} - {{ notif }} + Implement {{ notif.notification_type }} {%- endif %}
{%- endfor %}