kopia lustrzana https://github.com/snarfed/bridgy-fed
Protocol.maybe_accept_follow: switch send from inline to task
rodzic
e5a6ebf228
commit
2189652a1d
26
protocol.py
26
protocol.py
|
@ -1040,29 +1040,27 @@ class Protocol:
|
||||||
if 'accept' not in follower.SUPPORTED_AS1_TYPES:
|
if 'accept' not in follower.SUPPORTED_AS1_TYPES:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
target = follower.target_for(follower.obj)
|
||||||
|
if not target:
|
||||||
|
error(f"Couldn't find delivery target for follower {follower.key}")
|
||||||
|
|
||||||
# send accept. note that this is one accept for the whole
|
# send accept. note that this is one accept for the whole
|
||||||
# follow, even if it has multiple followees!
|
# follow, even if it has multiple followees!
|
||||||
id = f'{followee.key.id()}/followers#accept-{follow.key.id()}'
|
id = f'{followee.key.id()}/followers#accept-{follow.key.id()}'
|
||||||
accept = Object.get_or_create(id, authed_as=followee.key.id(),
|
undelivered = [Target(protocol=follower.LABEL, uri=target)]
|
||||||
our_as1={
|
accept = {
|
||||||
'id': id,
|
'id': id,
|
||||||
'objectType': 'activity',
|
'objectType': 'activity',
|
||||||
'verb': 'accept',
|
'verb': 'accept',
|
||||||
'actor': followee.key.id(),
|
'actor': followee.key.id(),
|
||||||
'object': follow.as1,
|
'object': follow.as1,
|
||||||
})
|
}
|
||||||
|
obj = Object.get_or_create(id, authed_as=followee.key.id(),
|
||||||
|
undelivered=undelivered, our_as1=accept)
|
||||||
|
|
||||||
from_target = follower.target_for(follower.obj)
|
common.create_task(queue='send', obj=obj.key.urlsafe(),
|
||||||
if not from_target:
|
url=target, protocol=follower.LABEL,
|
||||||
error(f"Couldn't find delivery target for follower {follower}")
|
user=followee.key.urlsafe())
|
||||||
|
|
||||||
sent = follower.send(accept, from_target, from_user=followee)
|
|
||||||
if sent:
|
|
||||||
accept.populate(
|
|
||||||
delivered=[Target(protocol=follower.LABEL, uri=from_target)],
|
|
||||||
status='complete',
|
|
||||||
)
|
|
||||||
accept.put()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def bot_follow(bot_cls, user):
|
def bot_follow(bot_cls, user):
|
||||||
|
|
Ładowanie…
Reference in New Issue