Tweak replies management, improve tombstone support

This commit is contained in:
Thomas Sileo
2018-06-03 14:34:04 +02:00
parent 31300e20d7
commit 786816f0a2
2 changed files with 27 additions and 7 deletions

View File

@@ -866,21 +866,21 @@ class Create(BaseActivity):
'meta.count_reply': 1,
'meta.count_direct_reply': direct_reply,
},
'$addToSet': {'meta.thread_children': obj.id},
}):
DB.outbox.update_one({'activity.object.id': reply.id}, {
'$inc': {
'meta.count_reply': 1,
'meta.count_direct_reply': direct_reply,
},
'$addToSet': {'meta.thread_children': obj.id},
})
direct_reply = 0
reply_id = reply.id
reply = reply.get_local_reply()
logger.debug(f'next_reply={reply}')
if reply:
# Only append to threads if it's not the root
threads.append(reply_id)
threads.append(reply_id)
if reply_id:
if not DB.inbox.find_one_and_update({'activity.object.id': obj.id}, {
@@ -1018,6 +1018,15 @@ class Note(BaseActivity):
return Delete(object=Tombstone(id=self.id).to_dict(embed=True))
def get_tombstone(self, deleted: Optional[str]) -> BaseActivity:
return Tombstone(
id=self.id,
published=self.published,
deleted=deleted,
updated=updated,
)
_ACTIVITY_TYPE_TO_CLS = {
ActivityType.IMAGE: Image,
ActivityType.PERSON: Person,