summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruvok2025-01-19 18:30:41 +0100
committeruvok2025-01-19 18:30:41 +0100
commit66bc030cb0294b9d08dc2c5ced262a5a830e1d8e (patch)
treeb608e0d6b170ddc9e474840003371da7aa6b574c
parentbc0f3a819096d11af030803868f0e64b3917999d (diff)
Finish Mastodon API
-rw-r--r--hello-fusepy.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/hello-fusepy.py b/hello-fusepy.py
index ff9fd42..2c2d430 100644
--- a/hello-fusepy.py
+++ b/hello-fusepy.py
@@ -24,6 +24,7 @@ class APIChoice(enum.Enum):
api_url_ap_template = "https://{server}/users/{user}/outbox?page=true"
api_url_m_lookup_template = "https://{server}/api/v1/accounts/lookup"
+api_url_m_status_template = "https://{server}/api/v1/accounts/{uid}/statuses"
class Status(object):
@@ -52,7 +53,6 @@ class ActivityPubStatusProvider(StatusProvider):
res.raise_for_status()
stats = res.json()
- logging.debug(f"Status: ${stats['id']}")
return [
Status(
s["object"]["id"].split("/")[-1],
@@ -78,7 +78,20 @@ class MastodonStatusProvider(StatusProvider):
res.raise_for_status()
user = res.json()
self.userid = user["id"]
- return self._fallback_not_found()
+
+ url = api_url_m_status_template.format(server=self.server, uid=urllib.parse.quote(self.userid))
+ res = requests.get(url)
+ if res.status_code == 404:
+ return self._fallback_not_found()
+ statuses = res.json()
+ return [
+ Status(
+ s["id"],
+ s["content"],
+ s["created_at"],
+ )
+ for s in statuses
+ ]
class HelloWorld(Operations, LoggingMixIn):
def __init__(self, api: APIChoice, server: str, user: str):
@@ -180,6 +193,6 @@ def main(args):
if __name__ == "__main__":
- logging.basicConfig(level=logging.DEBUG)
+ #logging.basicConfig(level=logging.DEBUG)
args = parse_arguments()
main(args)