kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
a2b9096b19
commit
21c79a304c
10
common.py
10
common.py
|
@ -566,9 +566,9 @@ def actor(domain, user=None):
|
|||
if not user:
|
||||
user = User.get_or_create(domain)
|
||||
|
||||
actor = postprocess_as2(
|
||||
as2.from_as1(microformats2.json_to_object(hcard)), user=user)
|
||||
actor.update({
|
||||
actor_as1 = microformats2.json_to_object(hcard, rel_urls=mf2.get('rel-urls'))
|
||||
actor_as2 = postprocess_as2(as2.from_as1(actor_as1), user=user)
|
||||
actor_as2.update({
|
||||
'id': host_url(domain),
|
||||
# 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,
|
||||
|
@ -585,8 +585,8 @@ def actor(domain, user=None):
|
|||
},
|
||||
})
|
||||
|
||||
logger.info(f'Generated AS2 actor: {json_dumps(actor, indent=2)}')
|
||||
return actor
|
||||
logger.info(f'Generated AS2 actor: {json_dumps(actor_as2, indent=2)}')
|
||||
return actor_as2
|
||||
|
||||
|
||||
def fetch_followers(domain, collection):
|
||||
|
|
|
@ -179,7 +179,7 @@ class ActivityPubTest(testutil.TestCase):
|
|||
'url': 'http://localhost/r/https://foo.com/about-me',
|
||||
'attachment': [{
|
||||
'type': 'PropertyValue',
|
||||
'name': 'Link',
|
||||
'name': 'Mrs. ☕ Foo',
|
||||
'value': '<a rel=\"me\" href="https://foo.com/about-me">foo.com/about-me</a>',
|
||||
}],
|
||||
'inbox': 'http://localhost/foo.com/inbox',
|
||||
|
@ -196,6 +196,35 @@ class ActivityPubTest(testutil.TestCase):
|
|||
},
|
||||
}, got.json)
|
||||
|
||||
def test_actor_rel_me_links(self, _, mock_get, __):
|
||||
mock_get.return_value = requests_response("""
|
||||
<body>
|
||||
<div class="h-card">
|
||||
<a class="u-url" rel="me" href="/about-me">Mrs. ☕ Foo</a>
|
||||
<a class="u-url" rel="me" href="http://one" title="one title">
|
||||
one text
|
||||
</a>
|
||||
<a class="u-url" rel="me" href="https://two" title=" two title "> </a>
|
||||
</div>
|
||||
</body>
|
||||
""", url='https://foo.com/', content_type=common.CONTENT_TYPE_HTML)
|
||||
|
||||
got = self.client.get('/foo.com')
|
||||
self.assertEqual(200, got.status_code)
|
||||
self.assertEqual([{
|
||||
'type': 'PropertyValue',
|
||||
'name': 'Mrs. ☕ Foo',
|
||||
'value': '<a rel="me" href="https://foo.com/about-me">foo.com/about-me</a>',
|
||||
}, {
|
||||
'type': 'PropertyValue',
|
||||
'name': 'one text',
|
||||
'value': '<a rel="me" href="http://one">one</a>',
|
||||
}, {
|
||||
'type': 'PropertyValue',
|
||||
'name': 'two title',
|
||||
'value': '<a rel="me" href="https://two">two</a>',
|
||||
}], got.json['attachment'])
|
||||
|
||||
def test_actor_no_hcard(self, _, mock_get, __):
|
||||
mock_get.return_value = requests_response("""
|
||||
<body>
|
||||
|
|
Ładowanie…
Reference in New Issue