From 9705f81360d31e54104d2f61ebf86e34fd7a30a4 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 4 Sep 2019 23:18:02 +0200 Subject: [PATCH] Fix threads display --- blueprints/admin.py | 8 ++++++++ core/shared.py | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/blueprints/admin.py b/blueprints/admin.py index b07ff7c..5486896 100644 --- a/blueprints/admin.py +++ b/blueprints/admin.py @@ -27,6 +27,7 @@ from core.activitypub import Box from core.activitypub import post_to_outbox from core.db import find_one_activity from core.meta import by_object_id +from core.meta import by_remote_id from core.meta import by_type from core.meta import follow_request_accepted from core.meta import in_outbox @@ -268,6 +269,13 @@ def admin_thread() -> _Response: abort(404) data = find_one_activity({**by_type(ap.ActivityType.CREATE), **by_object_id(oid)}) + if not data: + dat = DB.replies.find_one({**by_remote_id(oid)}) + data = { + "activity": {"object": dat["activity"]}, + "meta": dat["meta"], + "_id": dat["_id"], + } if not data: abort(404) diff --git a/core/shared.py b/core/shared.py index 41c5192..8f04999 100644 --- a/core/shared.py +++ b/core/shared.py @@ -23,6 +23,7 @@ from config import ME from core import activitypub from core.db import find_activities from core.meta import MetaKey +from core.meta import by_object_id from core.meta import by_type from core.meta import flag from core.meta import not_deleted @@ -147,6 +148,11 @@ def _build_thread(data, include_children=True): # noqa: C901 ) replies = [data] + for dat in find_activities( + {**by_object_id(root_id), **not_deleted(), **by_type(ap.ActivityType.CREATE)} + ): + replies.append(dat) + for dat in find_activities( { **flag(MetaKey.THREAD_ROOT_PARENT, root_id),