Add notification for follow requests status

This commit is contained in:
Thomas Sileo 2022-07-22 19:36:58 +02:00
parent cf95836d2d
commit 4046fa0506
5 changed files with 30 additions and 2 deletions

View file

@ -1105,6 +1105,18 @@ async def save_to_inbox(
ap_actor_id=actor.ap_id, ap_actor_id=actor.ap_id,
) )
db_session.add(following) db_session.add(following)
notif_type = (
models.NotificationType.FOLLOW_REQUEST_ACCEPTED
if activity_ro.ap_type == "Accept"
else models.NotificationType.FOLLOW_REQUEST_REJECTED
)
notif = models.Notification(
notification_type=notif_type,
actor_id=actor.id,
inbox_object_id=inbox_object.id,
)
db_session.add(notif)
else: else:
logger.info( logger.info(
"Received an Accept for an unsupported activity: " "Received an Accept for an unsupported activity: "

View file

@ -78,7 +78,6 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac
# Next: # Next:
# - show pending follow request (and prevent double follow?) # - show pending follow request (and prevent double follow?)
# - UI support for updating posts # - UI support for updating posts
# - Support for processing update
# - Article support # - Article support
# - Fix tests # - Fix tests
# - Fix SQL tx in the codebase # - Fix SQL tx in the codebase

View file

@ -479,11 +479,18 @@ class Webmention(Base):
class NotificationType(str, enum.Enum): class NotificationType(str, enum.Enum):
NEW_FOLLOWER = "new_follower" NEW_FOLLOWER = "new_follower"
UNFOLLOW = "unfollow" UNFOLLOW = "unfollow"
FOLLOW_REQUEST_ACCEPTED = "follow_request_accepted"
FOLLOW_REQUEST_REJECTED = "follow_request_rejected"
LIKE = "like" LIKE = "like"
UNDO_LIKE = "undo_like" UNDO_LIKE = "undo_like"
ANNOUNCE = "announce" ANNOUNCE = "announce"
UNDO_ANNOUNCE = "undo_announce" UNDO_ANNOUNCE = "undo_announce"
MENTION = "mention" MENTION = "mention"
NEW_WEBMENTION = "new_webmention" NEW_WEBMENTION = "new_webmention"
UPDATED_WEBMENTION = "updated_webmention" UPDATED_WEBMENTION = "updated_webmention"
DELETED_WEBMENTION = "deleted_webmention" DELETED_WEBMENTION = "deleted_webmention"

View file

@ -22,6 +22,16 @@
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</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 == "follow_request_accepted" %}
<div class="actor-action" title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> accepted your follow request
</div>
{{ utils.display_actor(notif.actor, actors_metadata) }}
{%- elif notif.notification_type.value == "follow_request_rejected" %}
<div class="actor-action" title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> rejected your follow request
</div>
{{ utils.display_actor(notif.actor, actors_metadata) }}
{% elif notif.notification_type.value == "like" %} {% elif notif.notification_type.value == "like" %}
<div class="actor-action" title="{{ notif.created_at.isoformat() }}"> <div class="actor-action" title="{{ notif.created_at.isoformat() }}">
<a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> liked a post <a style="font-weight:bold;" href="{{ notif.actor.url }}">{{ notif.actor.display_name }}</a> liked a post