From f7cc00e443c5e7ea1766df7a99a153df19e9982c Mon Sep 17 00:00:00 2001 From: Kay Faraday Date: Wed, 28 Dec 2022 23:07:02 +0000 Subject: [PATCH] fetch_posts.py: remove lots of dead code --- fetch_posts.py | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/fetch_posts.py b/fetch_posts.py index f1b101e..557d84e 100755 --- a/fetch_posts.py +++ b/fetch_posts.py @@ -188,36 +188,7 @@ class PostFetcher: assert outbox['type'] in {'OrderedCollection', 'OrderedCollectionPage'} return outbox - async def _finger_actor(self, username, instance): - # despite HTTP being a direct violation of the WebFinger spec, assume e.g. Tor instances do not support - # HTTPS-over-onion - finger_url = f'http://{instance}/.well-known/webfinger?resource=acct:{username}@{instance}' - async with self._http.get(finger_url) as resp: finger_result = await resp.json() - return (profile_url := self._parse_webfinger_result(username, instance, finger_result)) - - def _parse_webfinger_result(self, username, instance, finger_result): - """given webfinger data, return profile URL for handle""" - def check_content_type(type, ct): return ct == type or ct.startswith(type+';') - check_ap = partial(check_content_type, ACTIVITYPUB_CONTENT_TYPE) - - try: - # note: the server might decide to return multiple links - # so we need to decide how to prefer one. - # i'd put "and yarl.URL(template).host == instance" here, - # but some instances have no subdomain for the handle yet use a subdomain for the canonical URL. - # Additionally, an instance could theoretically serve profile pages over I2P and the clearnet, - # for example. - return (profile_url := next( - link['href'] - for link in finger_result['links'] - if link['rel'] == 'self' and check_ap(link['type']) - )) - except StopIteration: - # this should never happen either - raise RuntimeError(f'fatal: while fingering {username}@{instance}, failed to find a profile URL') - async def amain(): - import json5 as json import third_party.utils as utils args = utils.arg_parser_factory(description='Fetch posts from all followed accounts').parse_args() config = utils.load_config(args.cfg)