2 activity_lists::SiteInboxActivities,
3 http::{create_apub_response, receive_lemmy_activity},
4 objects::{instance::ApubSite, person::ApubPerson},
5 protocol::collections::empty_outbox::EmptyOutbox,
7 use activitypub_federation::{deser::context::WithContext, traits::ApubObject};
8 use actix_web::{web, HttpRequest, HttpResponse};
9 use lemmy_api_common::context::LemmyContext;
10 use lemmy_db_views::structs::SiteView;
11 use lemmy_utils::error::LemmyError;
14 pub(crate) async fn get_apub_site_http(
15 context: web::Data<LemmyContext>,
16 ) -> Result<HttpResponse, LemmyError> {
17 let site: ApubSite = SiteView::read_local(context.pool()).await?.site.into();
19 let apub = site.into_apub(&context).await?;
20 Ok(create_apub_response(&apub))
23 #[tracing::instrument(skip_all)]
24 pub(crate) async fn get_apub_site_outbox(
25 context: web::Data<LemmyContext>,
26 ) -> Result<HttpResponse, LemmyError> {
27 let outbox_id = format!(
29 context.settings().get_protocol_and_hostname()
31 let outbox = EmptyOutbox::new(Url::parse(&outbox_id)?)?;
32 Ok(create_apub_response(&outbox))
35 #[tracing::instrument(skip_all)]
36 pub async fn get_apub_site_inbox(
39 context: web::Data<LemmyContext>,
40 ) -> Result<HttpResponse, LemmyError> {
41 receive_lemmy_activity::<WithContext<SiteInboxActivities>, ApubPerson>(request, payload, context)