kopia lustrzana https://github.com/snarfed/bridgy-fed
webmention => AP/Salmon: handle no targets or followers, return 200
fixes https://console.cloud.google.com/errors/CIrig_2B6_i87AEpull/59/head
rodzic
e964190162
commit
0af5c136bb
|
@ -294,6 +294,23 @@ class WebmentionTest(testutil.TestCase):
|
|||
|
||||
mock_get.assert_has_calls((self.req('http://a/post'),))
|
||||
|
||||
def test_no_targets(self, mock_get, mock_post):
|
||||
mock_get.return_value = requests_response("""
|
||||
<html>
|
||||
<body class="h-entry">
|
||||
<p class="e-content">no one to send to! <a href="http://localhost/"></a></p>
|
||||
</body>
|
||||
</html>""", content_type=CONTENT_TYPE_HTML)
|
||||
|
||||
got = app.get_response(
|
||||
'/webmention', method='POST', body=urllib.urlencode({
|
||||
'source': 'http://a/post',
|
||||
'target': 'https://fed.brid.gy/',
|
||||
}))
|
||||
self.assertEquals(200, got.status_int)
|
||||
|
||||
mock_get.assert_has_calls((self.req('http://a/post'),))
|
||||
|
||||
def test_no_backlink(self, mock_get, mock_post):
|
||||
mock_get.return_value = requests_response(
|
||||
self.reply_html.replace('<a href="http://localhost/"></a>', ''),
|
||||
|
|
|
@ -209,6 +209,10 @@ class WebmentionHandler(webapp2.RequestHandler):
|
|||
def try_salmon(self):
|
||||
"""Returns True if we attempted OStatus delivery. Raises otherwise."""
|
||||
target = self.target_resp.url if self.target_resp else self._single_target()
|
||||
if not target:
|
||||
logging.warning("No targets or followers. Ignoring.")
|
||||
return False
|
||||
|
||||
resp = Response.get_or_create(
|
||||
source=self.source_url, target=target, direction='out',
|
||||
source_mf2=json.dumps(self.source_mf2))
|
||||
|
|
Ładowanie…
Reference in New Issue