forked from alemi/upub
fix: insert liked element also in single obj view
This commit is contained in:
parent
2c302b4fbf
commit
3237a38d74
1 changed files with 17 additions and 10 deletions
|
@ -1,6 +1,6 @@
|
||||||
pub mod replies;
|
pub mod replies;
|
||||||
|
|
||||||
use apb::ObjectMut;
|
use apb::{CollectionMut, ObjectMut};
|
||||||
use axum::extract::{Path, Query, State};
|
use axum::extract::{Path, Query, State};
|
||||||
use sea_orm::{ColumnTrait, ModelTrait, QueryFilter};
|
use sea_orm::{ColumnTrait, ModelTrait, QueryFilter};
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ pub async fn view(
|
||||||
.await?
|
.await?
|
||||||
.ok_or_else(UpubError::not_found)?;
|
.ok_or_else(UpubError::not_found)?;
|
||||||
|
|
||||||
let object = match item {
|
let (object, liked) = match item {
|
||||||
Event::Tombstone => return Err(UpubError::not_found()),
|
Event::Tombstone => return Err(UpubError::not_found()),
|
||||||
Event::Activity(_) => return Err(UpubError::not_found()),
|
Event::Activity(_) => return Err(UpubError::not_found()),
|
||||||
Event::StrayObject { object, liked: _ } => object,
|
Event::StrayObject { object, liked } => (object, liked),
|
||||||
Event::DeepActivity { activity: _, liked: _, object } => object,
|
Event::DeepActivity { activity: _, liked, object } => (object, liked),
|
||||||
};
|
};
|
||||||
|
|
||||||
let attachments = object.find_related(model::attachment::Entity)
|
let attachments = object.find_related(model::attachment::Entity)
|
||||||
|
@ -56,10 +56,17 @@ pub async fn view(
|
||||||
// .set_first(apb::Node::link(crate::url!(ctx, "/objects/{id}/replies/page")))
|
// .set_first(apb::Node::link(crate::url!(ctx, "/objects/{id}/replies/page")))
|
||||||
// .set_total_items(Some(object.comments as u64));
|
// .set_total_items(Some(object.comments as u64));
|
||||||
|
|
||||||
Ok(JsonLD(
|
let likes_count = object.likes as u64;
|
||||||
object.ap()
|
let mut obj = object.ap().set_attachment(apb::Node::array(attachments));
|
||||||
// .set_replies(apb::Node::object(replies))
|
|
||||||
.set_attachment(apb::Node::array(attachments))
|
if let Some(liked) = liked {
|
||||||
.ld_context()
|
obj = obj.set_audience(apb::Node::object( // TODO setting this again ewww...
|
||||||
))
|
serde_json::Value::new_object()
|
||||||
|
.set_collection_type(Some(apb::CollectionType::OrderedCollection))
|
||||||
|
.set_total_items(Some(likes_count))
|
||||||
|
.set_ordered_items(apb::Node::links(vec![liked]))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(JsonLD(obj.ld_context()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue