From 89e21b88e3663e91548a82bccca078201e3d73ac Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Fri, 19 Aug 2022 00:03:49 +0200 Subject: [PATCH] Tweak query for pruning inbox data --- app/prune.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/prune.py b/app/prune.py index 877b58f..d779ba3 100644 --- a/app/prune.py +++ b/app/prune.py @@ -4,6 +4,7 @@ from loguru import logger from sqlalchemy import and_ from sqlalchemy import delete from sqlalchemy import not_ +from sqlalchemy import or_ from app import activitypub as ap from app import models @@ -55,7 +56,15 @@ async def _prune_old_inbox_objects( # Keep announced objects models.InboxObject.announced_via_outbox_object_ap_id.is_(None), # Keep objects related to local conversations - models.InboxObject.conversation.not_like(f"{BASE_URL}/%"), + or_( + models.InboxObject.conversation.not_like(f"{BASE_URL}/%"), + models.InboxObject.conversation.is_(None), + ), + # Keep activities related to the outbox (like Like/Announce/Follow...) + or_( + models.InboxObject.activity_object_ap_id.not_like(f"{BASE_URL}/*"), + models.InboxObject.activity_object_ap_id.is_(None), + ), # Keep direct messages not_( and_(