From 075d3c37429aa2dd622b6437f2d7c8d2f87c816a Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 11 Aug 2019 12:17:02 +0200 Subject: [PATCH] Don't spawn a task when an activity has no attachments --- blueprints/tasks.py | 4 +++- core/inbox.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/blueprints/tasks.py b/blueprints/tasks.py index 116b3df..bbd76eb 100644 --- a/blueprints/tasks.py +++ b/blueprints/tasks.py @@ -284,7 +284,9 @@ def task_cache_actor() -> _Response: # ) app.logger.info(f"actor cached for {iri}") - if activity.has_type([ap.ActivityType.CREATE, ap.ActivityType.ANNOUNCE]): + if activity.has_type( + [ap.ActivityType.CREATE, ap.ActivityType.ANNOUNCE] + ) and activity.get_object()._data.get("attachment", []): Tasks.cache_attachments(iri) except (ActivityGoneError, ActivityNotFoundError): diff --git a/core/inbox.py b/core/inbox.py index fc4b1f1..1d948c7 100644 --- a/core/inbox.py +++ b/core/inbox.py @@ -97,6 +97,9 @@ def _update_process_inbox(update: ap.Update, new_meta: _NewMeta) -> None: actor = ap.fetch_remote_activity(obj.get_actor().id) update_cached_actor(actor) + else: + raise ValueError(f"don't know how to update {obj!r}") + @process_inbox.register def _create_process_inbox(create: ap.Create, new_meta: _NewMeta) -> None: