From 90609468f1c355519f39a200c3a82488e5ad6bf5 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Tue, 3 Sep 2019 22:24:30 +0200 Subject: [PATCH] Tweak reply processing --- core/activitypub.py | 12 ++++++++---- core/meta.py | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/activitypub.py b/core/activitypub.py index 4522484..8bc64ec 100644 --- a/core/activitypub.py +++ b/core/activitypub.py @@ -763,13 +763,17 @@ def handle_replies(create: ap.Create) -> None: ) return None + in_reply_to_data = { + MetaKey.IN_REPLY_TO: in_reply_to, + MetaKey.IN_REPLY_TO_URL: reply.get_url(), + } # Update the activity to save some data about the reply if reply.get_actor().id == create.get_actor().id: - in_reply_to_data = {MetaKey.IN_REPLY_TO_SELF: True} + in_reply_to_data.update({MetaKey.IN_REPLY_TO_SELF: True}) else: - in_reply_to_data = { - MetaKey.IN_REPLY_TO_ACTOR: reply.get_actor().to_dict(embed=True) - } + in_reply_to_data.update( + {MetaKey.IN_REPLY_TO_ACTOR: reply.get_actor().to_dict(embed=True)} + ) update_one_activity(by_remote_id(create.id), upsert(in_reply_to_data)) # It's a regular reply, try to increment the reply counter diff --git a/core/meta.py b/core/meta.py index d00f1db..bc2f5e7 100644 --- a/core/meta.py +++ b/core/meta.py @@ -54,6 +54,8 @@ class MetaKey(Enum): THREAD_ROOT_PARENT = "thread_root_parent" + IN_REPLY_TO = "in_reply_to" + IN_REPLY_TO_URL = "in_reply_to_url" IN_REPLY_TO_SELF = "in_reply_to_self" IN_REPLY_TO_ACTOR = "in_reply_to_actor"