new incoming webmention UI: expect them to add fed.brid.gy link

...instead of wrapping URL in fed.brid.gy/wm/... to inject webmention Link endpoint.
pull/27/head
Ryan Barrett 2017-10-01 21:43:01 -07:00
rodzic 4284ef830d
commit f6a3ca1848
3 zmienionych plików z 15 dodań i 4 usunięć

Wyświetl plik

@ -12,6 +12,7 @@
<link rel="apple-touch-icon-precomposed" sizes="32x32" href="https://brid.gy/static/favicon.png">
<link rel="stylesheet" href="/static/bootstrap.min.css" />
<link rel="stylesheet" href="/static/style.css" type="text/css" />
<link rel="webmention" href="/webmention" />
</head>
<body>

Wyświetl plik

@ -50,6 +50,7 @@ class WebmentionTest(testutil.TestCase):
<a class="u-url" href="http://a/reply"></a>
<p class="e-content">
<a class="u-in-reply-to" href="http://orig/post">foo bar</a>
<a href="https://fed.brid.gy/"></a>
</p>
</div>
</body>
@ -81,7 +82,7 @@ class WebmentionTest(testutil.TestCase):
got = app.get_response(
'/webmention', method='POST', body=urllib.urlencode({
'source': 'http://a/reply',
'target': 'http://orig/post',
'target': 'https://fed.brid.gy/',
}))
self.assertEquals(200, got.status_int)
@ -102,9 +103,11 @@ class WebmentionTest(testutil.TestCase):
'@context': 'https://www.w3.org/ns/activitystreams',
'@type': 'Note',
'type': 'Note',
'@id': 'http://a/reply',
'id': 'http://a/reply',
'url': 'http://a/reply',
'displayName': 'foo ☕ bar',
'content': ' <a class="u-in-reply-to" href="http://orig/post">foo ☕ bar</a> ',
'content': ' <a class="u-in-reply-to" href="http://orig/post">foo ☕ bar</a> <a href="https://fed.brid.gy/"></a> ',
'inReplyTo': 'http://orig/post',
'cc': [
common.AS2_PUBLIC_AUDIENCE,
@ -173,7 +176,7 @@ class WebmentionTest(testutil.TestCase):
'ref': 'tag:fed.brid.gy,2017-08-22:orig-post'
}, entry['thr_in-reply-to'])
self.assertEquals(
'<a class="u-in-reply-to" href="http://orig/post">foo ☕ bar</a>',
'<a class="u-in-reply-to" href="http://orig/post">foo ☕ bar</a> <a href="https://fed.brid.gy/"></a>',
entry.content[0]['value'])
def test_salmon_get_salmon_from_webfinger(self, mock_get, mock_post):

Wyświetl plik

@ -46,7 +46,14 @@ class WebmentionHandler(webapp2.RequestHandler):
source_obj = microformats2.json_to_object(entry)
logging.info('Converted to AS: %s', json.dumps(source_obj, indent=2))
# fetch target page as AS object
# fetch target page as AS object. (target is first in-reply-to, not
# query param.)
target = util.get_first(source_obj, 'inReplyTo')
if isinstance(target, dict):
target = target.get('url')
if not target:
self.abort(400, 'No u-in-reply-to found in %s' % source)
try:
resp = common.requests_get(target, headers=activitypub.CONNEG_HEADER,
log=True)