Improve replies handling

This commit is contained in:
Thomas Sileo
2019-08-25 12:48:04 +02:00
parent bb43aec474
commit 3f65368547
3 changed files with 29 additions and 11 deletions

View File

@@ -735,6 +735,15 @@ def handle_replies(create: ap.Create) -> None:
)
return None
# 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}
else:
in_reply_to_data = {
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
creply = DB.activities.find_one_and_update(
{**by_object_id(in_reply_to), **by_type(ap.ActivityType.CREATE)},
@@ -747,4 +756,4 @@ def handle_replies(create: ap.Create) -> None:
)
# Spawn a task to process it (and determine if it needs to be saved)
Tasks.process_reply(create.get_object().id)
Tasks.process_reply(create.get_object_id())