Skip to content

cattle_grid.activity_pub

is_valid_requester_for_obj async

is_valid_requester_for_obj(
    session: AsyncSession, requester: str, obj: dict
)

Checks if the requested is allowed to view the object

Source code in cattle_grid/activity_pub/actor/requester.py
async def is_valid_requester_for_obj(session: AsyncSession, requester: str, obj: dict):
    """Checks if the requested is allowed to view the object"""

    actor_id = obj.get("attributedTo")
    if actor_id is None:
        actor_id = obj.get("actor")
    if actor_id is None:
        raise ActorNotFound("Object does not have an actor or attributedTo")

    actor = await session.scalar(select(Actor).where(Actor.actor_id == actor_id))
    if actor is None:
        raise ActorNotFound("Actor not found")

    return await is_valid_requester(session, requester, actor, obj)