From 973a3060acc8f3af590afc827400ae5e0e8560d5 Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 19 Apr 2024 04:04:19 +0200 Subject: [PATCH] feat: show replies collection inline with object --- src/model/object.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/model/object.rs b/src/model/object.rs index eeceba95..b2887674 100644 --- a/src/model/object.rs +++ b/src/model/object.rs @@ -1,4 +1,4 @@ -use apb::{BaseMut, ObjectMut}; +use apb::{BaseMut, CollectionMut, ObjectMut}; use sea_orm::entity::prelude::*; use crate::routes::activitypub::jsonld::LD; @@ -59,6 +59,13 @@ impl Model { .set_content(self.content.as_deref()) .set_context(apb::Node::maybe_link(self.context.clone())) .set_in_reply_to(apb::Node::maybe_link(self.in_reply_to.clone())) + .set_replies(apb::Node::object( + serde_json::Value::new_object() + .set_id(Some(&format!("{}/replies", self.id))) + .set_collection_type(Some(apb::CollectionType::OrderedCollection)) + .set_first(apb::Node::link(format!("{}/replies/page", self.id))) + .set_total_items(Some(self.comments as u64)) + )) .set_published(Some(self.published)) .set_to(apb::Node::links(self.to.0.clone())) .set_bto(apb::Node::Empty)