remove common.actor()

pull/475/head
Ryan Barrett 2023-04-04 22:19:35 -07:00
rodzic 22ca59749e
commit 0dbe18aae4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
1 zmienionych plików z 0 dodań i 47 usunięć

Wyświetl plik

@ -187,50 +187,3 @@ def webmention_endpoint_cache_key(url):
def webmention_discover(url, **kwargs):
"""Thin caching wrapper around :func:`webmention.discover`."""
return webmention.discover(url, **kwargs)
def actor(user):
"""Fetches a home page, converts its representative h-card to AS2 actor.
Args:
user: :class:`User`
Returns: (dict mf2 item, dict AS1 actor, dict AS2 actor)
"""
assert user
domain = user.key.id()
try:
mf2 = util.fetch_mf2(user.homepage, gateway=True)
except ValueError as e:
error(f"Couldn't fetch {user.homepage}: {e}")
hcard = mf2util.representative_hcard(mf2, mf2['url'])
logger.info(f'Representative h-card: {json_dumps(hcard, indent=2)}')
if not hcard:
error(f"Couldn't find a representative h-card (http://microformats.org/wiki/representative-hcard-parsing) on {mf2['url']}")
actor_as1 = microformats2.json_to_object(hcard, rel_urls=mf2.get('rel-urls'))
# TODO: fix circular dependency
import activitypub
actor_as2 = activitypub.postprocess_as2(as2.from_as1(actor_as1))
# TODO: unify with activitypub.actor()
actor_as2.update({
'id': user.actor_id(),
# This has to be the domain for Mastodon etc interop! It seems like it
# should be the custom username from the acct: u-url in their h-card,
# but that breaks Mastodon's Webfinger discovery. Background:
# https://github.com/snarfed/bridgy-fed/issues/302#issuecomment-1324305460
# https://github.com/snarfed/bridgy-fed/issues/77
'preferredUsername': domain,
'inbox': host_url(f'{domain}/inbox'),
'outbox': host_url(f'{domain}/outbox'),
'following': host_url(f'{domain}/following'),
'followers': host_url(f'{domain}/followers'),
'endpoints': {
'sharedInbox': host_url('inbox'),
},
})
logger.info(f'Generated AS2 actor: {json_dumps(actor_as2, indent=2)}')
return hcard, actor_as1, actor_as2