diff --git a/app/boxes.py b/app/boxes.py index 167279c..7b25641 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -1105,6 +1105,18 @@ async def save_to_inbox( ap_actor_id=actor.ap_id, ) 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: logger.info( "Received an Accept for an unsupported activity: " diff --git a/app/main.py b/app/main.py index ac2443f..a2d7dc1 100644 --- a/app/main.py +++ b/app/main.py @@ -78,7 +78,6 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac # Next: # - show pending follow request (and prevent double follow?) # - UI support for updating posts -# - Support for processing update # - Article support # - Fix tests # - Fix SQL tx in the codebase diff --git a/app/models.py b/app/models.py index 5bda03f..631857e 100644 --- a/app/models.py +++ b/app/models.py @@ -479,11 +479,18 @@ class Webmention(Base): class NotificationType(str, enum.Enum): NEW_FOLLOWER = "new_follower" UNFOLLOW = "unfollow" + + FOLLOW_REQUEST_ACCEPTED = "follow_request_accepted" + FOLLOW_REQUEST_REJECTED = "follow_request_rejected" + LIKE = "like" UNDO_LIKE = "undo_like" + ANNOUNCE = "announce" UNDO_ANNOUNCE = "undo_announce" + MENTION = "mention" + NEW_WEBMENTION = "new_webmention" UPDATED_WEBMENTION = "updated_webmention" DELETED_WEBMENTION = "deleted_webmention" diff --git a/app/templates/layout.html b/app/templates/layout.html index de6265f..e10dc0e 100644 --- a/app/templates/layout.html +++ b/app/templates/layout.html @@ -30,7 +30,7 @@
  • {{ admin_link("index", "Public") }}
  • {{ admin_link("admin_new", "New") }}
  • {{ admin_link("admin_stream", "Stream") }}
  • -
  • {{ admin_link("admin_inbox", "Inbox") }}/{{ admin_link("admin_outbox", "Outbox") }}
  • +
  • {{ admin_link("admin_inbox", "Inbox") }} / {{ admin_link("admin_outbox", "Outbox") }}
  • {{ admin_link("get_notifications", "Notifications") }} {% if notifications_count %}({{ notifications_count }}){% endif %}
  • {{ admin_link("get_lookup", "Lookup") }}
  • {{ admin_link("admin_bookmarks", "Bookmarks") }}
  • diff --git a/app/templates/notifications.html b/app/templates/notifications.html index 6585e48..412d77f 100644 --- a/app/templates/notifications.html +++ b/app/templates/notifications.html @@ -22,6 +22,16 @@ {{ notif.actor.display_name }} unfollowed you {{ utils.display_actor(notif.actor, actors_metadata) }} + {%- elif notif.notification_type.value == "follow_request_accepted" %} +
    + {{ notif.actor.display_name }} accepted your follow request +
    + {{ utils.display_actor(notif.actor, actors_metadata) }} + {%- elif notif.notification_type.value == "follow_request_rejected" %} +
    + {{ notif.actor.display_name }} rejected your follow request +
    + {{ utils.display_actor(notif.actor, actors_metadata) }} {% elif notif.notification_type.value == "like" %}
    {{ notif.actor.display_name }} liked a post