kopia lustrzana https://github.com/snarfed/bridgy-fed
wrap activity ids and urls and actor ids in our /r/ endpoint
for #16, #32. cc @swentel.pull/36/head
rodzic
e720e543d8
commit
b25960ca93
18
common.py
18
common.py
|
|
@ -267,6 +267,9 @@ def postprocess_as2(activity, target=None, key=None):
|
|||
|
||||
assert activity.get('id') or (isinstance(obj, dict) and obj.get('id'))
|
||||
|
||||
activity['id'] = redirect_wrap(activity['id'])
|
||||
activity['url'] = redirect_wrap(activity['url'])
|
||||
|
||||
# cc public and target's author(s) and recipients
|
||||
# https://www.w3.org/TR/activitystreams-vocabulary/#audienceTargeting
|
||||
# https://w3c.github.io/activitypub/#delivery
|
||||
|
|
@ -299,6 +302,21 @@ def postprocess_as2_actor(actor):
|
|||
domain = urlparse.urlparse(url).netloc
|
||||
actor.setdefault('preferredUsername', domain)
|
||||
actor['id'] = '%s/%s' % (appengine_config.HOST_URL, domain)
|
||||
actor['url'] = redirect_wrap(url)
|
||||
|
||||
|
||||
def redirect_wrap(url):
|
||||
"""Returns a URL on our domain that redirects to this URL.
|
||||
|
||||
...to satisfy Mastodon's non-standard domain matching requirement. :(
|
||||
|
||||
https://github.com/snarfed/bridgy-fed/issues/16#issuecomment-424799599
|
||||
https://github.com/tootsuite/mastodon/pull/6219#issuecomment-429142747
|
||||
"""
|
||||
prefix = urlparse.urljoin(appengine_config.HOST_URL, '/r/')
|
||||
if url.startswith(prefix):
|
||||
return url
|
||||
return prefix + url
|
||||
|
||||
|
||||
def beautifulsoup_parse(html, **kwargs):
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class ActivityPubTest(testutil.TestCase):
|
|||
'name': 'Mrs. ☕ Foo',
|
||||
'preferredUsername': 'foo.com',
|
||||
'id': 'http://localhost/foo.com',
|
||||
'url': 'https://foo.com/about-me',
|
||||
'url': 'http://localhost/r/https://foo.com/about-me',
|
||||
'inbox': 'http://localhost/foo.com/inbox',
|
||||
'publicKey': {
|
||||
'publicKeyPem': MagicKey.get_by_id('foo.com').public_pem(),
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ class WebmentionTest(testutil.TestCase):
|
|||
self.repost_as2 = {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
'type': 'Announce',
|
||||
'id': 'http://a/repost',
|
||||
'url': 'http://a/repost',
|
||||
'id': 'http://localhost/r/http://a/repost',
|
||||
'url': 'http://localhost/r/http://a/repost',
|
||||
'name': 'reposted!',
|
||||
'object': 'tag:orig,2017:as2',
|
||||
'cc': [
|
||||
|
|
@ -123,7 +123,7 @@ class WebmentionTest(testutil.TestCase):
|
|||
'actor': {
|
||||
'type': 'Person',
|
||||
'id': 'http://localhost/orig',
|
||||
'url': 'http://orig',
|
||||
'url': 'http://localhost/r/http://orig',
|
||||
'name': 'Ms. ☕ Baz',
|
||||
'preferredUsername': 'orig',
|
||||
},
|
||||
|
|
@ -157,8 +157,8 @@ class WebmentionTest(testutil.TestCase):
|
|||
'object': {
|
||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||
'type': 'Note',
|
||||
'id': 'http://a/reply',
|
||||
'url': 'http://a/reply',
|
||||
'id': 'http://localhost/r/http://a/reply',
|
||||
'url': 'http://localhost/r/http://a/reply',
|
||||
'name': 'foo ☕ bar',
|
||||
'content': '<a class="u-in-reply-to" href="http://orig/post">foo ☕ bar</a>\n<a href="https://fed.brid.gy/"></a>',
|
||||
'inReplyTo': 'tag:orig,2017:as2',
|
||||
|
|
@ -171,7 +171,7 @@ class WebmentionTest(testutil.TestCase):
|
|||
'attributedTo': [{
|
||||
'type': 'Person',
|
||||
'id': 'http://localhost/orig',
|
||||
'url': 'http://orig',
|
||||
'url': 'http://localhost/r/http://orig',
|
||||
'preferredUsername': 'orig',
|
||||
'name': 'Ms. ☕ Baz',
|
||||
}],
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue