2022-04-13 18:12:25 +00:00
|
|
|
use crate::Perform;
|
|
|
|
use actix_web::web::Data;
|
2022-05-03 17:44:13 +00:00
|
|
|
use lemmy_api_common::{
|
|
|
|
post::{GetSiteMetadata, GetSiteMetadataResponse},
|
|
|
|
request::fetch_site_metadata,
|
2022-11-26 02:04:46 +00:00
|
|
|
LemmyContext,
|
2022-05-03 17:44:13 +00:00
|
|
|
};
|
2022-06-02 14:33:41 +00:00
|
|
|
use lemmy_utils::{error::LemmyError, ConnectionId};
|
2022-04-13 18:12:25 +00:00
|
|
|
|
|
|
|
#[async_trait::async_trait(?Send)]
|
|
|
|
impl Perform for GetSiteMetadata {
|
|
|
|
type Response = GetSiteMetadataResponse;
|
|
|
|
|
|
|
|
#[tracing::instrument(skip(context, _websocket_id))]
|
|
|
|
async fn perform(
|
|
|
|
&self,
|
|
|
|
context: &Data<LemmyContext>,
|
|
|
|
_websocket_id: Option<ConnectionId>,
|
|
|
|
) -> Result<GetSiteMetadataResponse, LemmyError> {
|
|
|
|
let data: &Self = self;
|
|
|
|
|
|
|
|
let metadata = fetch_site_metadata(context.client(), &data.url).await?;
|
|
|
|
|
|
|
|
Ok(GetSiteMetadataResponse { metadata })
|
|
|
|
}
|
|
|
|
}
|