diff options
author | uvok | 2025-01-23 20:48:19 +0100 |
---|---|---|
committer | uvok | 2025-01-23 20:48:19 +0100 |
commit | 5d893fc963b4d4089551085155057ae960c1e085 (patch) | |
tree | 0848e6394f086c83951460d9a819afd4c5118691 /de_uvok/activitypub_fuse/providers.py | |
parent | 4b537dd1d252026a2f3124191c9b91791e698f90 (diff) |
Add doc
Diffstat (limited to 'de_uvok/activitypub_fuse/providers.py')
-rw-r--r-- | de_uvok/activitypub_fuse/providers.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/de_uvok/activitypub_fuse/providers.py b/de_uvok/activitypub_fuse/providers.py index 19cee62..74b08b4 100644 --- a/de_uvok/activitypub_fuse/providers.py +++ b/de_uvok/activitypub_fuse/providers.py @@ -14,18 +14,59 @@ _api_url_m_status_template = "https://{server}/api/v1/accounts/{uid}/statuses" class StatusProvider: + """ + Base class for status providers. + """ + def load_statuses(self, max_id="") -> tuple[list[Status], Optional[str]]: + """ + Load statuses up to a given maximum ID. + + Args: + max_id (str): The maximum ID for loading statuses. + Can be empty or None to load the first page. + + Returns: + tuple: A tuple containing a list of Status objects and, + optionally, a max ID for the next call. + """ raise NotImplementedError def _fallback_not_found(self): + """ + Handle user not found error by returning a Status representing that error. + + Returns: + list: A list containing a single 'not-found' status. + """ return [Status("not-found", "User not found", "1970-01-01T00:00:00Z")] def _fallback_error(self, error_msg: str): + """ + Handle an error by returning a Status representing that error. + + Args: + error_msg (str): The error message to be included in the fallback status. + + Returns: + list: A list containing a single 'error' status. + """ return [Status("error", error_msg, "1970-01-01T00:00:00Z")] class ActivityPubStatusProvider(StatusProvider): + """ + Status provider for ActivityPub protocol. + """ + def __init__(self, server: str, user: str): + """ + Initialize the ActivityPub status provider. + + Args: + server (str): The server FQDN. + user (str): The user name (just the name, not the full ID). + """ self.server = server self.user = user @@ -69,7 +110,18 @@ class ActivityPubStatusProvider(StatusProvider): class MastodonStatusProvider(StatusProvider): + """ + Status provider for Mastodon API. + """ + def __init__(self, server: str, user: str): + """ + Initialize the Mastodon status provider. + + Args: + server (str): The server FQDN. + user (str): The user name (just the name, not the full ID). + """ self.server = server self.user = user self.userid = 0 |