|
|
|
@ -11,8 +11,8 @@ use url::Url;
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
|
pub enum PostOrComment {
|
|
|
|
|
Post(ApubPost),
|
|
|
|
|
Comment(ApubComment),
|
|
|
|
|
Post(Box<ApubPost>),
|
|
|
|
|
Comment(Box<ApubComment>),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Deserialize)]
|
|
|
|
@ -39,10 +39,10 @@ impl ApubObject for PostOrComment {
|
|
|
|
|
) -> Result<Option<Self>, LemmyError> {
|
|
|
|
|
let post = ApubPost::read_from_apub_id(object_id.clone(), data).await?;
|
|
|
|
|
Ok(match post {
|
|
|
|
|
Some(o) => Some(PostOrComment::Post(o)),
|
|
|
|
|
Some(o) => Some(PostOrComment::Post(Box::new(o))),
|
|
|
|
|
None => ApubComment::read_from_apub_id(object_id, data)
|
|
|
|
|
.await?
|
|
|
|
|
.map(PostOrComment::Comment),
|
|
|
|
|
.map(|c| PostOrComment::Comment(Box::new(c))),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -79,12 +79,12 @@ impl ApubObject for PostOrComment {
|
|
|
|
|
request_counter: &mut i32,
|
|
|
|
|
) -> Result<Self, LemmyError> {
|
|
|
|
|
Ok(match apub {
|
|
|
|
|
PageOrNote::Page(p) => {
|
|
|
|
|
PostOrComment::Post(ApubPost::from_apub(p, context, request_counter).await?)
|
|
|
|
|
}
|
|
|
|
|
PageOrNote::Note(n) => {
|
|
|
|
|
PostOrComment::Comment(ApubComment::from_apub(n, context, request_counter).await?)
|
|
|
|
|
}
|
|
|
|
|
PageOrNote::Page(p) => PostOrComment::Post(Box::new(
|
|
|
|
|
ApubPost::from_apub(p, context, request_counter).await?,
|
|
|
|
|
)),
|
|
|
|
|
PageOrNote::Note(n) => PostOrComment::Comment(Box::new(
|
|
|
|
|
ApubComment::from_apub(n, context, request_counter).await?,
|
|
|
|
|
)),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|