예제 #1
0
def _follow_process_inbox(activity: ap.Follow, new_meta: _NewMeta) -> None:
    _logger.info(f"process_inbox activity={activity!r}")
    # Reply to a Follow with an Accept if we're not manully approving them
    if not config.MANUALLY_APPROVES_FOLLOWERS:
        accept_follow(activity)
    else:
        update_one_activity(
            by_remote_id(activity.id),
            upsert({MetaKey.FOLLOW_STATUS: FollowStatus.WAITING.value}),
        )
예제 #2
0
def api_accept_follow() -> _Response:
    oid = _user_api_arg("id")
    doc = DB.activities.find_one({"box": Box.INBOX.value, "remote_id": oid})
    print(doc)
    if not doc:
        raise ActivityNotFoundError(f"cannot found {oid}")

    obj = ap.parse_activity(doc.get("activity"))
    if not obj.has_type(ap.ActivityType.FOLLOW):
        raise ValueError(f"{obj} is not a Follow activity")

    accept_id = accept_follow(obj)

    return _user_api_response(activity=accept_id)