kopia lustrzana https://github.com/snarfed/bridgy-fed
webmention => AP: Create: handle Follower with actor URL instead of object
we don't create these any more, we always fetch and store full actor objects, but we have a few old ones lying around in the prod datastore. for #33create
rodzic
11c66cfd3e
commit
2cb0dda2d1
|
@ -132,7 +132,8 @@ class Follower(StringIdModel):
|
|||
Key name is 'USER_DOMAIN FOLLOWER_ID', e.g.:
|
||||
'snarfed.org https://mastodon.social/@swentel'.
|
||||
"""
|
||||
# most recent AP Follow activity (JSON)
|
||||
# most recent AP Follow activity (JSON). must have a composite actor object
|
||||
# with an inbox, publicInbox, or sharedInbox!
|
||||
last_follow = ndb.TextProperty()
|
||||
|
||||
created = ndb.DateTimeProperty(auto_now_add=True)
|
||||
|
|
|
@ -135,14 +135,15 @@ class WebmentionHandler(webapp2.RequestHandler):
|
|||
|
||||
if not target:
|
||||
# interpret this as a Create or Update, deliver it to followers
|
||||
followers = Follower.query().filter(
|
||||
inboxes = []
|
||||
for follower in Follower.query().filter(
|
||||
Follower.key > Key('Follower', self.source_domain + ' '),
|
||||
Follower.key < Key('Follower', self.source_domain + chr(ord(' ') + 1)))
|
||||
actors = [json.loads(f.last_follow)['actor'] for f in followers
|
||||
if f.last_follow]
|
||||
inboxes = [a.get('endpoints', {}).get('sharedInbox') or
|
||||
a.get('publicInbox') or a.get('inbox')
|
||||
for a in actors]
|
||||
Follower.key < Key('Follower', self.source_domain + chr(ord(' ') + 1))):
|
||||
if follower.last_follow:
|
||||
actor = json.loads(follower.last_follow).get('actor', {})
|
||||
inboxes.append(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)),
|
||||
|
|
Ładowanie…
Reference in New Issue