diff --git a/app.py b/app.py index f51f0b1..2259102 100644 --- a/app.py +++ b/app.py @@ -60,6 +60,7 @@ from core.meta import by_object_id from core.meta import by_remote_id from core.meta import by_type from core.meta import by_visibility +from core.meta import follow_request_accepted from core.meta import in_inbox from core.meta import in_outbox from core.meta import is_public @@ -145,6 +146,7 @@ def inject_config(): following_q = { **in_outbox(), **by_type(ActivityType.FOLLOW), + **follow_request_accepted(), **not_undo(), **not_deleted(), } @@ -849,7 +851,13 @@ def followers(): @app.route("/following") def following(): - q = {**in_outbox(), **by_type(ActivityType.FOLLOW), **not_undo()} + q = { + **in_outbox(), + **by_type(ActivityType.FOLLOW), + **not_deleted(), + **follow_request_accepted(), + **not_undo(), + } if is_api_request(): _log_sig() diff --git a/blueprints/admin.py b/blueprints/admin.py index 5486896..6d51602 100644 --- a/blueprints/admin.py +++ b/blueprints/admin.py @@ -379,6 +379,7 @@ def admin_notifications() -> _Response: "activity.object": {"$regex": f"^{config.BASE_URL}"}, } followed_query = {"type": ap.ActivityType.ACCEPT.value} + rejected_query = {"type": ap.ActivityType.REJECT.value} q = { "box": Box.INBOX.value, "$or": [ @@ -387,6 +388,7 @@ def admin_notifications() -> _Response: replies_query, new_followers_query, followed_query, + rejected_query, unfollow_query, likes_query, ], diff --git a/core/inbox.py b/core/inbox.py index 939f2f0..93cace5 100644 --- a/core/inbox.py +++ b/core/inbox.py @@ -176,15 +176,10 @@ def _follow_process_inbox(activity: ap.Follow, new_meta: _NewMeta) -> None: post_to_outbox(accept) -def _update_follow_status(follow: ap.BaseActivity, status: FollowStatus) -> None: - if not follow.has_type(ap.Follow) or not is_from_outbox(follow): - _logger.warning( - "received an Accept/Reject from an unexpected activity: {follow!r}" - ) - return None - +def _update_follow_status(follow_id: str, status: FollowStatus) -> None: + _logger.info(f"{follow_id} is {status}") update_one_activity( - by_remote_id(follow.id), upsert({MetaKey.FOLLOW_STATUS: status.value}) + by_remote_id(follow_id), upsert({MetaKey.FOLLOW_STATUS: status.value}) ) @@ -192,14 +187,14 @@ def _update_follow_status(follow: ap.BaseActivity, status: FollowStatus) -> None def _accept_process_inbox(activity: ap.Accept, new_meta: _NewMeta) -> None: _logger.info(f"process_inbox activity={activity!r}") # Set a flag on the follow - follow = activity.get_object() + follow = activity.get_object_id() _update_follow_status(follow, FollowStatus.ACCEPTED) @process_inbox.register def _reject_process_inbox(activity: ap.Reject, new_meta: _NewMeta) -> None: _logger.info(f"process_inbox activity={activity!r}") - follow = activity.get_object() + follow = activity.get_object_id() _update_follow_status(follow, FollowStatus.REJECTED)