Skip to content

fediverse_pasture.runner.application

activity_for_firefish(domain, username, session) async

Creates a ApplicationAdapterForLastActivity object for connecting to firefish. Example usage:

firefish = await activity_for_firefish("firefish_web", "admin", session)
Source code in fediverse_pasture/runner/application/__init__.py
async def activity_for_firefish(
    domain: str, username: str, session: aiohttp.ClientSession
) -> ApplicationAdapterForLastActivity:
    """Creates a ApplicationAdapterForLastActivity object for connecting to
    firefish. Example usage:

    ```python
    firefish = await activity_for_firefish("firefish_web", "admin", session)
    ```
    """
    firefish = FirefishApplication(domain=domain, username=username)

    return await firefish.last_activity(session)

activity_for_mastodon(domain, username, access_token, session) async

Creates a ApplicationAdapterForLastActivity object for connecting to mastodon. Example usage:

mastodon = await activity_for_mastodon("mastodon_web", "bob", "xxx", session)
Source code in fediverse_pasture/runner/application/__init__.py
async def activity_for_mastodon(
    domain: str, username: str, access_token: str, session: aiohttp.ClientSession
) -> ApplicationAdapterForLastActivity:
    """Creates a ApplicationAdapterForLastActivity object for connecting to
    mastodon. Example usage:

    ```python
    mastodon = await activity_for_mastodon("mastodon_web", "bob", "xxx", session)
    ```
    """
    mastodon = MastodonApplication(
        domain=domain, access_token=access_token, username=username
    )

    return mastodon.last_activity(session)

actor_for_application(account_uri, application_name, session) async

Creates a ApplicationAdapterForActor

Parameters:

Name Type Description Default
account_uri str

The acct uri, e.g. acct:user@domain

required
application_name str

The name of the application

required
session ClientSession

the aiohttp ClientSession

required
Source code in fediverse_pasture/runner/application/__init__.py
async def actor_for_application(
    account_uri: str, application_name: str, session: aiohttp.ClientSession
) -> ApplicationAdapterForActor:
    """Creates a ApplicationAdapterForActor

    :param account_uri: The acct uri, e.g. `acct:user@domain`
    :param application_name: The name of the application
    :param session: the aiohttp ClientSession
    """

    domain = account_uri.split("@")[1]

    actor_uri, _ = await lookup_uri_with_webfinger(
        session, account_uri, f"http://{domain}"
    )

    if not actor_uri:
        raise ValueError(f"Actor not found with URI {account_uri}")

    return ApplicationAdapterForActor(
        actor_uri=actor_uri, application_name=application_name
    )