mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-10 10:08:58 +00:00
parent
497564359b
commit
09cd32034b
|
@ -25,3 +25,19 @@ impl<T> WithContext<T> {
|
|||
self.inner
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(crate) struct WithContextJson {
|
||||
#[serde(rename = "@context")]
|
||||
context: OneOrMany<AnyBase>,
|
||||
inner: serde_json::Value,
|
||||
}
|
||||
|
||||
impl WithContextJson {
|
||||
pub(crate) fn new(inner: serde_json::Value) -> WithContextJson {
|
||||
WithContextJson {
|
||||
context: CONTEXT.clone(),
|
||||
inner,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
activity_lists::SharedInboxActivities,
|
||||
check_is_apub_id_valid,
|
||||
context::WithContext,
|
||||
context::{WithContext, WithContextJson},
|
||||
fetcher::user_or_community::UserOrCommunity,
|
||||
http::{community::receive_group_inbox, person::receive_person_inbox},
|
||||
insert_activity,
|
||||
|
@ -129,6 +129,12 @@ where
|
|||
.json(WithContext::new(data))
|
||||
}
|
||||
|
||||
fn create_json_apub_response(data: serde_json::Value) -> HttpResponse<Body> {
|
||||
HttpResponse::Ok()
|
||||
.content_type(APUB_JSON_CONTENT_TYPE)
|
||||
.json(WithContextJson::new(data))
|
||||
}
|
||||
|
||||
fn create_apub_tombstone_response<T>(data: &T) -> HttpResponse<Body>
|
||||
where
|
||||
T: Serialize,
|
||||
|
@ -167,7 +173,7 @@ pub(crate) async fn get_activity(
|
|||
if !activity.local || sensitive {
|
||||
Ok(HttpResponse::NotFound().finish())
|
||||
} else {
|
||||
Ok(create_apub_response(&activity.data))
|
||||
Ok(create_json_apub_response(activity.data))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue