mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Fix follower handling
This commit is contained in:
parent
0b34913c6e
commit
6a20f30bad
3 changed files with 16 additions and 11 deletions
10
app.py
10
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()
|
||||
|
|
|
@ -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,
|
||||
],
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue