kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
f296d0f017
commit
05c8dc83c4
14
common.py
14
common.py
|
@ -464,7 +464,11 @@ def postprocess_as2_actor(actor, user=None):
|
|||
Returns:
|
||||
actor dict
|
||||
"""
|
||||
urls = util.get_list(actor, 'url') or [f'https://{user.key.id()}/']
|
||||
url = f'https://{user.key.id()}/' if user else None
|
||||
urls = util.get_list(actor, 'url')
|
||||
if not urls and url:
|
||||
urls = [url]
|
||||
|
||||
domain = util.domain_from_link(urls[0], minimize=False)
|
||||
urls[0] = redirect_wrap(urls[0])
|
||||
|
||||
|
@ -476,6 +480,14 @@ def postprocess_as2_actor(actor, user=None):
|
|||
'preferredUsername': domain,
|
||||
})
|
||||
|
||||
# Override the label for their home page to be "Web site"
|
||||
for att in util.get_list(actor, 'attachment'):
|
||||
if att.get('type') == 'PropertyValue':
|
||||
val = att.get('value', '')
|
||||
link = util.parse_html(val).find('a')
|
||||
if url and (val == url or link.get('href') == url):
|
||||
att['name'] = 'Web site'
|
||||
|
||||
# required by pixelfed. https://github.com/snarfed/bridgy-fed/issues/39
|
||||
actor.setdefault('summary', '')
|
||||
return actor
|
||||
|
|
|
@ -201,6 +201,7 @@ class ActivityPubTest(testutil.TestCase):
|
|||
<body>
|
||||
<div class="h-card">
|
||||
<a class="u-url" rel="me" href="/about-me">Mrs. ☕ Foo</a>
|
||||
<a class="u-url" rel="me" href="/">should be ignored</a>
|
||||
<a class="u-url" rel="me" href="http://one" title="one title">
|
||||
one text
|
||||
</a>
|
||||
|
@ -215,6 +216,10 @@ class ActivityPubTest(testutil.TestCase):
|
|||
'type': 'PropertyValue',
|
||||
'name': 'Mrs. ☕ Foo',
|
||||
'value': '<a rel="me" href="https://foo.com/about-me">foo.com/about-me</a>',
|
||||
}, {
|
||||
'type': 'PropertyValue',
|
||||
'name': 'Web site',
|
||||
'value': '<a rel="me" href="https://foo.com/">foo.com</a>',
|
||||
}, {
|
||||
'type': 'PropertyValue',
|
||||
'name': 'one text',
|
||||
|
|
Ładowanie…
Reference in New Issue