mirror of
https://git.sr.ht/~tsileo/microblog.pub
synced 2024-11-15 03:04:28 +00:00
Fix forwarding
This commit is contained in:
parent
88186e2306
commit
9431cb09d7
1 changed files with 17 additions and 1 deletions
18
tasks.py
18
tasks.py
|
@ -114,7 +114,7 @@ def process_new_activity(self, iri: str) -> None:
|
||||||
|
|
||||||
if should_forward:
|
if should_forward:
|
||||||
log.info(f"will forward {activity!r} to followers")
|
log.info(f"will forward {activity!r} to followers")
|
||||||
activity.forward(back.followers_as_recipients())
|
forward_activity.delay(activity.id)
|
||||||
|
|
||||||
if should_delete:
|
if should_delete:
|
||||||
log.info(f"will soft delete {activity!r}")
|
log.info(f"will soft delete {activity!r}")
|
||||||
|
@ -367,6 +367,22 @@ def finish_post_to_outbox(self, iri: str) -> None:
|
||||||
for recp in recipients:
|
for recp in recipients:
|
||||||
log.debug(f"posting to {recp}")
|
log.debug(f"posting to {recp}")
|
||||||
post_to_remote_inbox.delay(payload, recp)
|
post_to_remote_inbox.delay(payload, recp)
|
||||||
|
except Exception as err:
|
||||||
|
log.exception(f"failed to post to remote inbox for {iri}")
|
||||||
|
self.retry(exc=err, countdown=int(random.uniform(2, 4) ** self.request.retries))
|
||||||
|
|
||||||
|
|
||||||
|
@app.task(bind=True, max_retries=12) # noqa:C901
|
||||||
|
def forward_activity(self, iri: str) -> None:
|
||||||
|
try:
|
||||||
|
activity = ap.fetch_remote_activity(iri)
|
||||||
|
recipients = back.followers_as_recipients()
|
||||||
|
log.debug(f"Forwarding {activity!r} to {recipients}")
|
||||||
|
activity = ap.clean_activity(activity.to_dict())
|
||||||
|
payload = json.dumps(activity)
|
||||||
|
for recp in recipients:
|
||||||
|
log.debug(f"forwarding {activity!r} to {recp}")
|
||||||
|
post_to_remote_inbox.delay(payload, recp)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
log.exception(f"failed to cache attachments for {iri}")
|
log.exception(f"failed to cache attachments for {iri}")
|
||||||
self.retry(exc=err, countdown=int(random.uniform(2, 4) ** self.request.retries))
|
self.retry(exc=err, countdown=int(random.uniform(2, 4) ** self.request.retries))
|
||||||
|
|
Loading…
Reference in a new issue