Tweak notifications

main
Thomas Sileo 2022-06-26 10:55:53 +02:00
parent 6700984117
commit f365784f93
3 changed files with 22 additions and 8 deletions

View File

@ -617,6 +617,14 @@ def save_to_inbox(db: Session, raw_object: ap.RawObject) -> None:
"Received an Accept for an unsupported activity: " "Received an Accept for an unsupported activity: "
f"{relates_to_outbox_object.ap_type}" 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": elif ra.ap_type == "Like":
if not relates_to_outbox_object: if not relates_to_outbox_object:
logger.info( logger.info(

View File

@ -150,6 +150,7 @@ class OutboxObject(Base, BaseObject):
likes_count = Column(Integer, nullable=False, default=0) likes_count = Column(Integer, nullable=False, default=0)
announces_count = Column(Integer, nullable=False, default=0) announces_count = Column(Integer, nullable=False, default=0)
replies_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) webmentions = Column(JSON, nullable=True)

View File

@ -7,37 +7,42 @@
<div> <div>
{%- if notif.notification_type.value == "new_follower" %} {%- if notif.notification_type.value == "new_follower" %}
<div title="{{ notif.created_at.isoformat() }}"> <div title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.name or notif.actor.preferred_username }}</a> followed you <a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> followed you
</div> </div>
{{ utils.display_actor(notif.actor, actors_metadata) }} {{ utils.display_actor(notif.actor, actors_metadata) }}
{% elif notif.notification_type.value == "unfollow" %} {% elif notif.notification_type.value == "unfollow" %}
<div title="{{ notif.created_at.isoformat() }}"> <div title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.name or notif.actor.preferred_username }}</a> unfollowed you <a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> unfollowed you
</div> </div>
{{ utils.display_actor(notif.actor, actors_metadata) }} {{ utils.display_actor(notif.actor, actors_metadata) }}
{% elif notif.notification_type.value == "like" %} {% elif notif.notification_type.value == "like" %}
<div title="{{ notif.created_at.isoformat() }}"> <div title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.name or notif.actor.preferred_username }}</a> liked a post <a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> liked a post
</div> </div>
{{ utils.display_object(notif.outbox_object) }} {{ utils.display_object(notif.outbox_object) }}
{% elif notif.notification_type.value == "undo_like" %} {% elif notif.notification_type.value == "undo_like" %}
<div title="{{ notif.created_at.isoformat() }}"> <div title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.name or notif.actor.preferred_username }}</a> un-liked a post <a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> un-liked a post
</div> </div>
{{ utils.display_object(notif.outbox_object) }} {{ utils.display_object(notif.outbox_object) }}
{% elif notif.notification_type.value == "announce" %} {% elif notif.notification_type.value == "announce" %}
<div title="{{ notif.created_at.isoformat() }}"> <div title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.name or notif.actor.preferred_username }}</a> boosted a post <a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> boosted a post
</div> </div>
{{ utils.display_object(notif.outbox_object) }} {{ utils.display_object(notif.outbox_object) }}
{% elif notif.notification_type.value == "undo_announce" %} {% elif notif.notification_type.value == "undo_announce" %}
<div title="{{ notif.created_at.isoformat() }}"> <div title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.name or notif.actor.preferred_username }}</a> un-boosted a post <a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> un-boosted a post
</div> </div>
{{ utils.display_object(notif.outbox_object) }} {{ utils.display_object(notif.outbox_object) }}
{% elif notif.notification_type.value == "mention" %}
<div title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> mentioned you
</div>
{{ utils.display_object(notif.inbox_object) }}
{% else %} {% else %}
{{ notif }} Implement {{ notif.notification_type }}
{%- endif %} {%- endif %}
</div> </div>
{%- endfor %} {%- endfor %}