From b6751f511a1220ae04e5c3aa0fdbcbd8bc39a095 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sat, 10 Aug 2019 11:58:04 +0200 Subject: [PATCH] Tweak actor caching --- blueprints/tasks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/blueprints/tasks.py b/blueprints/tasks.py index 7350181..f5e5fa1 100644 --- a/blueprints/tasks.py +++ b/blueprints/tasks.py @@ -21,6 +21,7 @@ from core.activitypub import _actor_hash from core.activitypub import _add_answers_to_question from core.activitypub import no_cache from core.activitypub import post_to_outbox +from core.db import update_many_activities from core.db import update_one_activity from core.inbox import process_inbox from core.meta import MetaKey @@ -276,12 +277,17 @@ def task_cache_actor() -> _Response: ) # Cache the actor info - DB.activities.update_many( + update_many_activities( { **flag(MetaKey.ACTOR_ID, actor.id), **flag(MetaKey.ACTOR_HASH, {"$ne": actor_hash}), }, - upsert({MetaKey.ACTOR: actor.to_dict(embed=True)}), + upsert( + { + MetaKey.ACTOR: actor.to_dict(embed=True), + MetaKey.ACTOR_HASH: actor_hash, + } + ), ) # TODO(tsileo): Also update following (it's in the object)