kopia lustrzana https://github.com/snarfed/bridgy-fed
rename Web.LABEL from 'webmention' to 'web'
rodzic
93f621aaf5
commit
47b04f5574
|
@ -3,7 +3,7 @@
|
||||||
URL pattern is /convert/SOURCE/DEST , where SOURCE and DEST are the LABEL
|
URL pattern is /convert/SOURCE/DEST , where SOURCE and DEST are the LABEL
|
||||||
constants from the :class:`Protocol` subclasses.
|
constants from the :class:`Protocol` subclasses.
|
||||||
|
|
||||||
Currently only supports /convert/activitypub/webmention/...
|
Currently only supports /convert/activitypub/web/...
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
@ -78,4 +78,4 @@ def convert(src, dest, _):
|
||||||
def render_redirect():
|
def render_redirect():
|
||||||
"""Redirect from old /render?id=... endpoint to /convert/..."""
|
"""Redirect from old /render?id=... endpoint to /convert/..."""
|
||||||
id = flask_util.get_required_param('id')
|
id = flask_util.get_required_param('id')
|
||||||
return redirect(f'/convert/activitypub/webmention/{id}', code=301)
|
return redirect(f'/convert/activitypub/web/{id}', code=301)
|
||||||
|
|
|
@ -387,13 +387,13 @@ class Object(StringIdModel):
|
||||||
"""
|
"""
|
||||||
assert '^^' not in self.key.id()
|
assert '^^' not in self.key.id()
|
||||||
id = self.key.id().replace('#', '^^')
|
id = self.key.id().replace('#', '^^')
|
||||||
return common.host_url(f'convert/{self.source_protocol}/webmention/{id}')
|
return common.host_url(f'convert/{self.source_protocol}/web/{id}')
|
||||||
|
|
||||||
def actor_link(self):
|
def actor_link(self):
|
||||||
"""Returns a pretty actor link with their name and profile picture."""
|
"""Returns a pretty actor link with their name and profile picture."""
|
||||||
attrs = {'class': 'h-card u-author'}
|
attrs = {'class': 'h-card u-author'}
|
||||||
|
|
||||||
if (self.source_protocol in ('webmention', 'ui') and g.user and
|
if (self.source_protocol in ('web', 'webmention', 'ui') and g.user and
|
||||||
g.user.key.id() in self.domains):
|
g.user.key.id() in self.domains):
|
||||||
# outbound; show a nice link to the user
|
# outbound; show a nice link to the user
|
||||||
return g.user.user_page_link()
|
return g.user.user_page_link()
|
||||||
|
|
4
pages.py
4
pages.py
|
@ -314,10 +314,10 @@ def nodeinfo():
|
||||||
# 'activeMonth':
|
# 'activeMonth':
|
||||||
# 'activeHalfyear':
|
# 'activeHalfyear':
|
||||||
},
|
},
|
||||||
'localPosts': Object.query(Object.source_protocol == 'webmention',
|
'localPosts': Object.query(Object.source_protocol.IN(('web', 'webmention')),
|
||||||
Object.type.IN(['note', 'article']),
|
Object.type.IN(['note', 'article']),
|
||||||
).count(),
|
).count(),
|
||||||
'localComments': Object.query(Object.source_protocol == 'webmention',
|
'localComments': Object.query(Object.source_protocol.IN(('web', 'webmention')),
|
||||||
Object.type == 'comment',
|
Object.type == 'comment',
|
||||||
).count(),
|
).count(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -328,7 +328,7 @@ class Protocol:
|
||||||
|
|
||||||
# send webmentions and update Object
|
# send webmentions and update Object
|
||||||
errors = [] # stores (code, body) tuples
|
errors = [] # stores (code, body) tuples
|
||||||
targets = [Target(uri=uri, protocol='webmention') for uri in targets]
|
targets = [Target(uri=uri, protocol='web') for uri in targets]
|
||||||
|
|
||||||
obj.populate(
|
obj.populate(
|
||||||
undelivered=targets,
|
undelivered=targets,
|
||||||
|
|
|
@ -244,7 +244,7 @@ class ActivityPubTest(TestCase):
|
||||||
self.key_id_obj.put()
|
self.key_id_obj.put()
|
||||||
|
|
||||||
def assert_object(self, id, **props):
|
def assert_object(self, id, **props):
|
||||||
return super().assert_object(id, delivered_protocol='webmention', **props)
|
return super().assert_object(id, delivered_protocol='web', **props)
|
||||||
|
|
||||||
def sign(self, path, body):
|
def sign(self, path, body):
|
||||||
"""Constructs HTTP Signature, returns headers."""
|
"""Constructs HTTP Signature, returns headers."""
|
||||||
|
@ -356,7 +356,7 @@ class ActivityPubTest(TestCase):
|
||||||
headers={'Accept': '*/*'},
|
headers={'Accept': '*/*'},
|
||||||
allow_redirects=False,
|
allow_redirects=False,
|
||||||
data={
|
data={
|
||||||
'source': f'http://localhost/convert/activitypub/webmention/{convert_id}',
|
'source': f'http://localhost/convert/activitypub/web/{convert_id}',
|
||||||
'target': 'https://user.com/post',
|
'target': 'https://user.com/post',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -448,7 +448,7 @@ class ActivityPubTest(TestCase):
|
||||||
headers={'Accept': '*/*'},
|
headers={'Accept': '*/*'},
|
||||||
allow_redirects=False,
|
allow_redirects=False,
|
||||||
data={
|
data={
|
||||||
'source': f'http://localhost/convert/activitypub/webmention/{convert_id}',
|
'source': f'http://localhost/convert/activitypub/web/{convert_id}',
|
||||||
'target': orig_url,
|
'target': orig_url,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -573,7 +573,7 @@ class ActivityPubTest(TestCase):
|
||||||
headers={'Accept': '*/*'},
|
headers={'Accept': '*/*'},
|
||||||
allow_redirects=False,
|
allow_redirects=False,
|
||||||
data={
|
data={
|
||||||
'source': f'http://localhost/convert/activitypub/webmention/{convert_id}',
|
'source': f'http://localhost/convert/activitypub/web/{convert_id}',
|
||||||
'target': 'https://tar.get/',
|
'target': 'https://tar.get/',
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -607,7 +607,7 @@ class ActivityPubTest(TestCase):
|
||||||
args, kwargs = mock_post.call_args
|
args, kwargs = mock_post.call_args
|
||||||
self.assertEqual(('https://user.com/webmention',), args)
|
self.assertEqual(('https://user.com/webmention',), args)
|
||||||
self.assertEqual({
|
self.assertEqual({
|
||||||
'source': 'http://localhost/convert/activitypub/webmention/http:/mas.to/like^^ok',
|
'source': 'http://localhost/convert/activitypub/web/http:/mas.to/like^^ok',
|
||||||
'target': 'https://user.com/post',
|
'target': 'https://user.com/post',
|
||||||
}, kwargs['data'])
|
}, kwargs['data'])
|
||||||
|
|
||||||
|
@ -702,7 +702,7 @@ class ActivityPubTest(TestCase):
|
||||||
args, kwargs = mock_post.call_args_list[1]
|
args, kwargs = mock_post.call_args_list[1]
|
||||||
self.assertEqual(('https://user.com/webmention',), args)
|
self.assertEqual(('https://user.com/webmention',), args)
|
||||||
self.assertEqual({
|
self.assertEqual({
|
||||||
'source': 'http://localhost/convert/activitypub/webmention/https:/mas.to/6d1a',
|
'source': 'http://localhost/convert/activitypub/web/https:/mas.to/6d1a',
|
||||||
'target': 'https://user.com/',
|
'target': 'https://user.com/',
|
||||||
}, kwargs['data'])
|
}, kwargs['data'])
|
||||||
|
|
||||||
|
@ -1328,7 +1328,7 @@ class ActivityPubUtilsTest(TestCase):
|
||||||
self.assert_equals(AS2_OBJ, got.as2)
|
self.assert_equals(AS2_OBJ, got.as2)
|
||||||
mock_get.assert_has_calls([self.as2_req(id)])
|
mock_get.assert_has_calls([self.as2_req(id)])
|
||||||
|
|
||||||
self.assert_object(id, delivered_protocol='webmention',
|
self.assert_object(id, delivered_protocol='web',
|
||||||
as2=AS2_OBJ, as1=AS2_OBJ,
|
as2=AS2_OBJ, as1=AS2_OBJ,
|
||||||
source_protocol='activitypub',
|
source_protocol='activitypub',
|
||||||
# check that it reused our original Object
|
# check that it reused our original Object
|
||||||
|
|
|
@ -64,7 +64,7 @@ EXPECTED_AUTHOR_HTML = """\
|
||||||
class ConvertTest(testutil.TestCase):
|
class ConvertTest(testutil.TestCase):
|
||||||
|
|
||||||
def test_unknown_source(self):
|
def test_unknown_source(self):
|
||||||
resp = self.client.get('/convert/nope/webmention/http://foo')
|
resp = self.client.get('/convert/nope/web/http://foo')
|
||||||
self.assertEqual(404, resp.status_code)
|
self.assertEqual(404, resp.status_code)
|
||||||
|
|
||||||
def test_unknown_dest(self):
|
def test_unknown_dest(self):
|
||||||
|
@ -72,11 +72,11 @@ class ConvertTest(testutil.TestCase):
|
||||||
self.assertEqual(404, resp.status_code)
|
self.assertEqual(404, resp.status_code)
|
||||||
|
|
||||||
def test_missing_url(self):
|
def test_missing_url(self):
|
||||||
resp = self.client.get('/convert/activitypub/webmention/')
|
resp = self.client.get('/convert/activitypub/web/')
|
||||||
self.assertEqual(404, resp.status_code)
|
self.assertEqual(404, resp.status_code)
|
||||||
|
|
||||||
def test_url_not_web(self):
|
def test_url_not_web(self):
|
||||||
resp = self.client.get('/convert/activitypub/webmention/git+ssh://foo/bar')
|
resp = self.client.get('/convert/activitypub/web/git+ssh://foo/bar')
|
||||||
self.assertEqual(400, resp.status_code)
|
self.assertEqual(400, resp.status_code)
|
||||||
|
|
||||||
def test_activitypub_to_web_object(self):
|
def test_activitypub_to_web_object(self):
|
||||||
|
@ -84,7 +84,7 @@ class ConvertTest(testutil.TestCase):
|
||||||
with self.request_context:
|
with self.request_context:
|
||||||
Object(id=url, our_as1=COMMENT).put()
|
Object(id=url, our_as1=COMMENT).put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/https://user.com/bar?baz=baj&biff')
|
resp = self.client.get('/convert/activitypub/web/https://user.com/bar?baz=baj&biff')
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
self.assert_multiline_equals(EXPECTED_HTML, resp.get_data(as_text=True),
|
self.assert_multiline_equals(EXPECTED_HTML, resp.get_data(as_text=True),
|
||||||
ignore_blanks=True)
|
ignore_blanks=True)
|
||||||
|
@ -93,7 +93,7 @@ class ConvertTest(testutil.TestCase):
|
||||||
with self.request_context:
|
with self.request_context:
|
||||||
Object(id='http://foo').put()
|
Object(id='http://foo').put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(404, resp.status_code)
|
self.assertEqual(404, resp.status_code)
|
||||||
|
|
||||||
@patch('requests.get')
|
@patch('requests.get')
|
||||||
|
@ -101,7 +101,7 @@ class ConvertTest(testutil.TestCase):
|
||||||
mock_get.return_value = self.as2_resp(as2.from_as1(COMMENT))
|
mock_get.return_value = self.as2_resp(as2.from_as1(COMMENT))
|
||||||
url = 'https://user.com/bar?baz=baj&biff'
|
url = 'https://user.com/bar?baz=baj&biff'
|
||||||
|
|
||||||
resp = self.client.get(f'/convert/activitypub/webmention/{url}')
|
resp = self.client.get(f'/convert/activitypub/web/{url}')
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
self.assertEqual(CONTENT_TYPE_HTML, resp.content_type)
|
self.assertEqual(CONTENT_TYPE_HTML, resp.content_type)
|
||||||
self.assert_multiline_equals(EXPECTED_HTML, resp.get_data(as_text=True),
|
self.assert_multiline_equals(EXPECTED_HTML, resp.get_data(as_text=True),
|
||||||
|
@ -113,7 +113,7 @@ class ConvertTest(testutil.TestCase):
|
||||||
def test_activitypub_to_web_fetch_fails(self, mock_get):
|
def test_activitypub_to_web_fetch_fails(self, mock_get):
|
||||||
mock_get.side_effect = [requests_response('', status=405)]
|
mock_get.side_effect = [requests_response('', status=405)]
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(502, resp.status_code)
|
self.assertEqual(502, resp.status_code)
|
||||||
mock_get.assert_has_calls((self.as2_req('http://foo'),))
|
mock_get.assert_has_calls((self.as2_req('http://foo'),))
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class ConvertTest(testutil.TestCase):
|
||||||
Object(id='http://bar', our_as1=ACTOR,
|
Object(id='http://bar', our_as1=ACTOR,
|
||||||
source_protocol='activitypub').put()
|
source_protocol='activitypub').put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
self.assert_multiline_equals(EXPECTED_AUTHOR_HTML, resp.get_data(as_text=True),
|
self.assert_multiline_equals(EXPECTED_AUTHOR_HTML, resp.get_data(as_text=True),
|
||||||
ignore_blanks=True)
|
ignore_blanks=True)
|
||||||
|
@ -135,7 +135,7 @@ class ConvertTest(testutil.TestCase):
|
||||||
with self.request_context:
|
with self.request_context:
|
||||||
Object(id='http://foo', our_as1=comment).put()
|
Object(id='http://foo', our_as1=comment).put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
expected = EXPECTED_HTML.replace(
|
expected = EXPECTED_HTML.replace(
|
||||||
'\n<meta http-equiv="refresh" content="0;url=https://fake.com/123456">', ''
|
'\n<meta http-equiv="refresh" content="0;url=https://fake.com/123456">', ''
|
||||||
|
@ -147,14 +147,14 @@ class ConvertTest(testutil.TestCase):
|
||||||
with self.request_context:
|
with self.request_context:
|
||||||
Object(id='http://foo', as2={'content': 'foo'}, deleted=True).put()
|
Object(id='http://foo', as2={'content': 'foo'}, deleted=True).put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(410, resp.status_code)
|
self.assertEqual(410, resp.status_code)
|
||||||
|
|
||||||
def test_activitypub_to_web_delete_activity(self):
|
def test_activitypub_to_web_delete_activity(self):
|
||||||
with self.request_context:
|
with self.request_context:
|
||||||
Object(id='http://foo', our_as1=DELETE_OF_ID).put()
|
Object(id='http://foo', our_as1=DELETE_OF_ID).put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(410, resp.status_code)
|
self.assertEqual(410, resp.status_code)
|
||||||
|
|
||||||
def test_activitypub_to_web_update_inner_obj_exists_redirect(self):
|
def test_activitypub_to_web_update_inner_obj_exists_redirect(self):
|
||||||
|
@ -163,9 +163,9 @@ class ConvertTest(testutil.TestCase):
|
||||||
Object(id='http://foo', our_as1=UPDATE).put()
|
Object(id='http://foo', our_as1=UPDATE).put()
|
||||||
Object(id=UPDATE['object']['id'], as2={'content': 'foo'}).put()
|
Object(id=UPDATE['object']['id'], as2={'content': 'foo'}).put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(301, resp.status_code)
|
self.assertEqual(301, resp.status_code)
|
||||||
self.assertEqual(f'/convert/activitypub/webmention/tag:fake.com:123456',
|
self.assertEqual(f'/convert/activitypub/web/tag:fake.com:123456',
|
||||||
resp.headers['Location'])
|
resp.headers['Location'])
|
||||||
|
|
||||||
def test_activitypub_to_web_delete_inner_obj_exists_redirect(self):
|
def test_activitypub_to_web_delete_inner_obj_exists_redirect(self):
|
||||||
|
@ -174,9 +174,9 @@ class ConvertTest(testutil.TestCase):
|
||||||
Object(id='http://foo', our_as1=DELETE_OF_ID).put()
|
Object(id='http://foo', our_as1=DELETE_OF_ID).put()
|
||||||
Object(id=DELETE_OF_ID['object'], as2={'content': 'foo'}).put()
|
Object(id=DELETE_OF_ID['object'], as2={'content': 'foo'}).put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(301, resp.status_code)
|
self.assertEqual(301, resp.status_code)
|
||||||
self.assertEqual(f'/convert/activitypub/webmention/tag:fake.com:123456',
|
self.assertEqual(f'/convert/activitypub/web/tag:fake.com:123456',
|
||||||
resp.headers['Location'])
|
resp.headers['Location'])
|
||||||
|
|
||||||
def test_activitypub_to_web_update_no_inner_obj_serve_as_is(self):
|
def test_activitypub_to_web_update_no_inner_obj_serve_as_is(self):
|
||||||
|
@ -184,7 +184,7 @@ class ConvertTest(testutil.TestCase):
|
||||||
# UPDATE's object field is a full object
|
# UPDATE's object field is a full object
|
||||||
Object(id='http://foo', our_as1=UPDATE).put()
|
Object(id='http://foo', our_as1=UPDATE).put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
self.assert_multiline_in("""\
|
self.assert_multiline_in("""\
|
||||||
<div class="e-content p-name">
|
<div class="e-content p-name">
|
||||||
|
@ -199,7 +199,7 @@ A ☕ reply
|
||||||
Object(id='http://foo', our_as1=UPDATE).put()
|
Object(id='http://foo', our_as1=UPDATE).put()
|
||||||
Object(id=UPDATE['object']['id'], as2={'id': 'foo'}).put()
|
Object(id=UPDATE['object']['id'], as2={'id': 'foo'}).put()
|
||||||
|
|
||||||
resp = self.client.get('/convert/activitypub/webmention/http://foo')
|
resp = self.client.get('/convert/activitypub/web/http://foo')
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
self.assert_multiline_in("""\
|
self.assert_multiline_in("""\
|
||||||
<div class="e-content p-name">
|
<div class="e-content p-name">
|
||||||
|
@ -211,5 +211,5 @@ A ☕ reply
|
||||||
def test_render_endpoint_redirect(self):
|
def test_render_endpoint_redirect(self):
|
||||||
resp = self.client.get('/render?id=http://foo%3Fbar')
|
resp = self.client.get('/render?id=http://foo%3Fbar')
|
||||||
self.assertEqual(301, resp.status_code)
|
self.assertEqual(301, resp.status_code)
|
||||||
self.assertEqual(f'/convert/activitypub/webmention/http://foo?bar',
|
self.assertEqual(f'/convert/activitypub/web/http://foo?bar',
|
||||||
resp.headers['Location'])
|
resp.headers['Location'])
|
||||||
|
|
|
@ -109,11 +109,11 @@ class ObjectTest(TestCase):
|
||||||
|
|
||||||
def test_proxy_url(self):
|
def test_proxy_url(self):
|
||||||
obj = Object(id='abc', source_protocol='bluesky')
|
obj = Object(id='abc', source_protocol='bluesky')
|
||||||
self.assertEqual('http://localhost/convert/bluesky/webmention/abc',
|
self.assertEqual('http://localhost/convert/bluesky/web/abc',
|
||||||
obj.proxy_url())
|
obj.proxy_url())
|
||||||
|
|
||||||
obj = Object(id='ab#c', source_protocol='ui')
|
obj = Object(id='ab#c', source_protocol='ui')
|
||||||
self.assertEqual('http://localhost/convert/ui/webmention/ab^^c',
|
self.assertEqual('http://localhost/convert/ui/web/ab^^c',
|
||||||
obj.proxy_url())
|
obj.proxy_url())
|
||||||
|
|
||||||
def test_put(self):
|
def test_put(self):
|
||||||
|
|
|
@ -38,6 +38,7 @@ class ProtocolTest(TestCase):
|
||||||
|
|
||||||
def test_protocols_global(self):
|
def test_protocols_global(self):
|
||||||
self.assertEqual(Fake, PROTOCOLS['fake'])
|
self.assertEqual(Fake, PROTOCOLS['fake'])
|
||||||
|
self.assertEqual(Web, PROTOCOLS['web'])
|
||||||
self.assertEqual(Web, PROTOCOLS['webmention'])
|
self.assertEqual(Web, PROTOCOLS['webmention'])
|
||||||
|
|
||||||
@patch('requests.get')
|
@patch('requests.get')
|
||||||
|
|
|
@ -567,14 +567,14 @@ class WebTest(testutil.TestCase):
|
||||||
|
|
||||||
self.assert_object('https://user.com/reply',
|
self.assert_object('https://user.com/reply',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
mf2=self.reply_mf2,
|
mf2=self.reply_mf2,
|
||||||
as1=self.reply_as1,
|
as1=self.reply_as1,
|
||||||
type='comment',
|
type='comment',
|
||||||
)
|
)
|
||||||
self.assert_object('https://user.com/reply#bridgy-fed-create',
|
self.assert_object('https://user.com/reply#bridgy-fed-create',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
mf2=self.reply_mf2,
|
mf2=self.reply_mf2,
|
||||||
our_as1=self.create_reply_as1,
|
our_as1=self.create_reply_as1,
|
||||||
|
@ -711,7 +711,7 @@ class WebTest(testutil.TestCase):
|
||||||
mf2 = util.parse_mf2(html)['items'][0]
|
mf2 = util.parse_mf2(html)['items'][0]
|
||||||
self.assert_object('https://user.com/repost',
|
self.assert_object('https://user.com/repost',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
mf2=mf2,
|
mf2=mf2,
|
||||||
as1=microformats2.json_to_object(mf2),
|
as1=microformats2.json_to_object(mf2),
|
||||||
|
@ -769,7 +769,7 @@ class WebTest(testutil.TestCase):
|
||||||
|
|
||||||
self.assert_object('https://user.com/like',
|
self.assert_object('https://user.com/like',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
mf2=self.like_mf2,
|
mf2=self.like_mf2,
|
||||||
as1=microformats2.json_to_object(self.like_mf2),
|
as1=microformats2.json_to_object(self.like_mf2),
|
||||||
type='like',
|
type='like',
|
||||||
|
@ -878,11 +878,11 @@ class WebTest(testutil.TestCase):
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
mf2=self.note_mf2,
|
mf2=self.note_mf2,
|
||||||
type='note',
|
type='note',
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
)
|
)
|
||||||
self.assert_object('https://user.com/post#bridgy-fed-create',
|
self.assert_object('https://user.com/post#bridgy-fed-create',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
mf2=self.note_mf2,
|
mf2=self.note_mf2,
|
||||||
our_as1=self.create_as1,
|
our_as1=self.create_as1,
|
||||||
|
@ -927,7 +927,7 @@ class WebTest(testutil.TestCase):
|
||||||
self.assert_object(
|
self.assert_object(
|
||||||
f'https://user.com/post#bridgy-fed-update-2022-01-02T03:04:05+00:00',
|
f'https://user.com/post#bridgy-fed-update-2022-01-02T03:04:05+00:00',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
mf2=self.note_mf2,
|
mf2=self.note_mf2,
|
||||||
our_as1=update_as1,
|
our_as1=update_as1,
|
||||||
|
@ -983,7 +983,7 @@ class WebTest(testutil.TestCase):
|
||||||
|
|
||||||
self.assert_object('https://user.com/follow',
|
self.assert_object('https://user.com/follow',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
mf2=self.follow_mf2,
|
mf2=self.follow_mf2,
|
||||||
as1=self.follow_as1,
|
as1=self.follow_as1,
|
||||||
|
@ -1060,7 +1060,7 @@ class WebTest(testutil.TestCase):
|
||||||
|
|
||||||
self.assert_object('https://user.com/follow#2',
|
self.assert_object('https://user.com/follow#2',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
mf2=self.follow_fragment_mf2,
|
mf2=self.follow_fragment_mf2,
|
||||||
as1=self.follow_fragment_as1,
|
as1=self.follow_fragment_as1,
|
||||||
|
@ -1121,7 +1121,7 @@ class WebTest(testutil.TestCase):
|
||||||
as1 = microformats2.json_to_object(mf2)
|
as1 = microformats2.json_to_object(mf2)
|
||||||
self.assert_object('https://user.com/follow',
|
self.assert_object('https://user.com/follow',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
mf2=mf2,
|
mf2=mf2,
|
||||||
as1=as1,
|
as1=as1,
|
||||||
|
@ -1186,7 +1186,7 @@ class WebTest(testutil.TestCase):
|
||||||
|
|
||||||
self.assert_object('https://user.com/post#bridgy-fed-delete',
|
self.assert_object('https://user.com/post#bridgy-fed-delete',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
our_as1=DELETE_AS1,
|
our_as1=DELETE_AS1,
|
||||||
delivered=inboxes,
|
delivered=inboxes,
|
||||||
|
@ -1245,7 +1245,7 @@ class WebTest(testutil.TestCase):
|
||||||
|
|
||||||
self.assert_object('https://user.com/follow',
|
self.assert_object('https://user.com/follow',
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='failed',
|
status='failed',
|
||||||
mf2=self.follow_mf2,
|
mf2=self.follow_mf2,
|
||||||
as1=self.follow_as1,
|
as1=self.follow_as1,
|
||||||
|
@ -1311,7 +1311,7 @@ class WebTest(testutil.TestCase):
|
||||||
|
|
||||||
# homepage object
|
# homepage object
|
||||||
self.assert_object('https://user.com/',
|
self.assert_object('https://user.com/',
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
mf2=ACTOR_MF2_REL_URLS,
|
mf2=ACTOR_MF2_REL_URLS,
|
||||||
type='person',
|
type='person',
|
||||||
)
|
)
|
||||||
|
@ -1335,7 +1335,7 @@ class WebTest(testutil.TestCase):
|
||||||
}
|
}
|
||||||
self.assert_object(id,
|
self.assert_object(id,
|
||||||
domains=['user.com'],
|
domains=['user.com'],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
status='complete',
|
status='complete',
|
||||||
our_as1=expected_as1,
|
our_as1=expected_as1,
|
||||||
delivered=['https://inbox', 'https://shared/inbox'],
|
delivered=['https://inbox', 'https://shared/inbox'],
|
||||||
|
@ -1614,7 +1614,7 @@ class WebProtocolTest(testutil.TestCase):
|
||||||
args, kwargs = mock_post.call_args
|
args, kwargs = mock_post.call_args
|
||||||
self.assertEqual(('https://user.com/webmention',), args)
|
self.assertEqual(('https://user.com/webmention',), args)
|
||||||
self.assertEqual({
|
self.assertEqual({
|
||||||
'source': 'http://localhost/convert/ui/webmention/http:/mas.to/like^^ok',
|
'source': 'http://localhost/convert/ui/web/http:/mas.to/like^^ok',
|
||||||
'target': 'https://user.com/post',
|
'target': 'https://user.com/post',
|
||||||
}, kwargs['data'])
|
}, kwargs['data'])
|
||||||
|
|
||||||
|
|
2
ui.py
2
ui.py
|
@ -1,6 +1,6 @@
|
||||||
"""Stub UI Protocol class, for objects created in the UI.
|
"""Stub UI Protocol class, for objects created in the UI.
|
||||||
|
|
||||||
Needed for serving /convert/ui/webmention/... requests.
|
Needed for serving /convert/ui/web/... requests.
|
||||||
"""
|
"""
|
||||||
from models import User
|
from models import User
|
||||||
from protocol import Protocol
|
from protocol import Protocol
|
||||||
|
|
11
web.py
11
web.py
|
@ -42,7 +42,7 @@ class Web(User, Protocol):
|
||||||
|
|
||||||
The key name is the domain.
|
The key name is the domain.
|
||||||
"""
|
"""
|
||||||
LABEL = 'webmention'
|
LABEL = 'web'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_kind(cls):
|
def _get_kind(cls):
|
||||||
|
@ -227,6 +227,9 @@ class Web(User, Protocol):
|
||||||
|
|
||||||
return html, {'Content-Type': common.CONTENT_TYPE_HTML}
|
return html, {'Content-Type': common.CONTENT_TYPE_HTML}
|
||||||
|
|
||||||
|
# 'webmention' is an old LABEL alias for 'web'
|
||||||
|
PROTOCOLS['webmention'] = Web
|
||||||
|
|
||||||
|
|
||||||
@app.post('/webmention')
|
@app.post('/webmention')
|
||||||
def webmention_external():
|
def webmention_external():
|
||||||
|
@ -347,7 +350,7 @@ def webmention_task():
|
||||||
|
|
||||||
obj.populate(
|
obj.populate(
|
||||||
domains=[g.user.key.id()],
|
domains=[g.user.key.id()],
|
||||||
source_protocol='webmention',
|
source_protocol='web',
|
||||||
)
|
)
|
||||||
if not inboxes_to_targets:
|
if not inboxes_to_targets:
|
||||||
obj.labels.append('user')
|
obj.labels.append('user')
|
||||||
|
@ -383,7 +386,7 @@ def webmention_task():
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
obj = Object(id=id, mf2=obj.mf2, our_as1=update_as1, labels=['user'],
|
obj = Object(id=id, mf2=obj.mf2, our_as1=update_as1, labels=['user'],
|
||||||
domains=[g.user.key.id()], source_protocol='webmention')
|
domains=[g.user.key.id()], source_protocol='web')
|
||||||
|
|
||||||
elif obj.new:
|
elif obj.new:
|
||||||
logger.info(f'New Object {obj.key.id()}')
|
logger.info(f'New Object {obj.key.id()}')
|
||||||
|
@ -399,7 +402,7 @@ def webmention_task():
|
||||||
}
|
}
|
||||||
obj = Object(id=id, mf2=obj.mf2, our_as1=create_as1,
|
obj = Object(id=id, mf2=obj.mf2, our_as1=create_as1,
|
||||||
domains=[g.user.key.id()], labels=['user'],
|
domains=[g.user.key.id()], labels=['user'],
|
||||||
source_protocol='webmention')
|
source_protocol='web')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
msg = f'{obj.key.id()} is unchanged, nothing to do'
|
msg = f'{obj.key.id()} is unchanged, nothing to do'
|
||||||
|
|
Ładowanie…
Reference in New Issue