kopia lustrzana https://github.com/snarfed/bridgy-fed
add 'ignored' status for AP requests where the target has no webmention endpoint
rodzic
d16a20bcff
commit
4eaf70aa51
|
@ -209,6 +209,9 @@ def send_webmentions(activity_wrapped, proxy=None, **response_props):
|
|||
webmention.send(endpoint, wm_source, target, headers=HEADERS)
|
||||
response.status = 'complete'
|
||||
logging.info('Success!')
|
||||
else:
|
||||
response.status = 'ignored'
|
||||
logging.info('Ignoring.')
|
||||
except BaseException as e:
|
||||
errors.append(util.interpret_http_exception(e))
|
||||
response.put()
|
||||
|
|
|
@ -65,7 +65,7 @@ class Response(StringIdModel):
|
|||
|
||||
Key name is 'SOURCE_URL TARGET_URL', e.g. 'http://a/reply http://orig/post'.
|
||||
"""
|
||||
STATUSES = ('new', 'complete', 'error')
|
||||
STATUSES = ('new', 'complete', 'error', 'ignored')
|
||||
PROTOCOLS = ('activitypub', 'ostatus')
|
||||
DIRECTIONS = ('out', 'in')
|
||||
|
||||
|
|
|
@ -439,3 +439,19 @@ class ActivityPubTest(testutil.TestCase):
|
|||
got = self.client.post('/foo.com/inbox', json=LIKE)
|
||||
self.assertEqual(504, got.status_code)
|
||||
|
||||
def test_inbox_no_webmention_endpoint(self, mock_head, mock_get, mock_post):
|
||||
mock_get.side_effect = [
|
||||
# source actor
|
||||
requests_response(LIKE_WITH_ACTOR['actor'],
|
||||
headers={'Content-Type': common.CONTENT_TYPE_AS2}),
|
||||
# target post webmention discovery
|
||||
requests_response('<html><body>foo</body></html>'),
|
||||
]
|
||||
|
||||
got = self.client.post('/foo.com/inbox', json=LIKE)
|
||||
self.assertEqual(200, got.status_code)
|
||||
|
||||
resp = Response.get_by_id('http://this/like__ok http://orig/post')
|
||||
self.assertEqual('in', resp.direction)
|
||||
self.assertEqual('activitypub', resp.protocol)
|
||||
self.assertEqual('ignored', resp.status)
|
||||
|
|
Ładowanie…
Reference in New Issue