kopia lustrzana https://github.com/snarfed/bridgy-fed
webmention: de-dupe inboxes before delivering
rodzic
0532780eed
commit
33436a35a1
2
logs.py
2
logs.py
|
|
@ -10,8 +10,6 @@ import webapp2
|
|||
|
||||
from models import Response
|
||||
|
||||
VERSION_1_DEPLOYED = datetime.datetime(2017, 10, 26, 16, 0)
|
||||
|
||||
|
||||
class LogHandler(logs.LogHandler):
|
||||
VERSION_IDS = ['1']
|
||||
|
|
|
|||
|
|
@ -615,6 +615,11 @@ class WebmentionTest(testutil.TestCase):
|
|||
last_follow=json_dumps({'actor': {
|
||||
'inbox': 'https://unused/2',
|
||||
}}))
|
||||
Follower.get_or_create('orig', 'https://mastodon/fff',
|
||||
last_follow=json_dumps({'actor': {
|
||||
# dupe of eee; should be de-duped
|
||||
'inbox': 'https://inbox',
|
||||
}}))
|
||||
|
||||
got = application.get_response(
|
||||
'/webmention', method='POST', body=urlencode({
|
||||
|
|
@ -627,7 +632,7 @@ class WebmentionTest(testutil.TestCase):
|
|||
self.req('http://orig/post'),
|
||||
))
|
||||
|
||||
inboxes = ('https://public/inbox', 'https://shared/inbox', 'https://inbox')
|
||||
inboxes = ('https://inbox', 'https://public/inbox', 'https://shared/inbox')
|
||||
self.assertEqual(len(inboxes), len(mock_post.call_args_list))
|
||||
for call, inbox in zip(mock_post.call_args_list, inboxes):
|
||||
self.assertEqual((inbox,), call[0])
|
||||
|
|
|
|||
|
|
@ -140,21 +140,21 @@ class WebmentionHandler(common.Handler):
|
|||
|
||||
if not targets:
|
||||
# interpret this as a Create or Update, deliver it to followers
|
||||
inboxes = []
|
||||
inboxes = set()
|
||||
for follower in Follower.query().filter(
|
||||
Follower.key > Key('Follower', self.source_domain + ' '),
|
||||
Follower.key < Key('Follower', self.source_domain + chr(ord(' ') + 1))):
|
||||
if follower.status != 'inactive' and follower.last_follow:
|
||||
actor = json_loads(follower.last_follow).get('actor')
|
||||
if actor and isinstance(actor, dict):
|
||||
inboxes.append(actor.get('endpoints', {}).get('sharedInbox') or
|
||||
actor.get('publicInbox')or
|
||||
actor.get('inbox'))
|
||||
inboxes.add(actor.get('endpoints', {}).get('sharedInbox') or
|
||||
actor.get('publicInbox')or
|
||||
actor.get('inbox'))
|
||||
return [(Response.get_or_create(
|
||||
source=self.source_url, target=inbox, direction='out',
|
||||
protocol='activitypub', source_mf2=json_dumps(self.source_mf2)),
|
||||
inbox)
|
||||
for inbox in inboxes if inbox]
|
||||
for inbox in sorted(inboxes) if inbox]
|
||||
|
||||
resps_and_inbox_urls = []
|
||||
for target in targets:
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue