mirror of
https://github.com/LemmyNet/lemmy
synced 2024-10-30 15:21:20 +00:00
31829b6c05
* Untangle thumbnail generation logic (ref #4604) * prettier * test cleanup * fix tests * also consider opengraph image for local thumbnail generation
18 lines
516 B
Rust
18 lines
516 B
Rust
use actix_web::web::{Data, Json, Query};
|
|
use lemmy_api_common::{
|
|
context::LemmyContext,
|
|
post::{GetSiteMetadata, GetSiteMetadataResponse},
|
|
request::fetch_link_metadata,
|
|
};
|
|
use lemmy_utils::error::LemmyResult;
|
|
|
|
#[tracing::instrument(skip(context))]
|
|
pub async fn get_link_metadata(
|
|
data: Query<GetSiteMetadata>,
|
|
context: Data<LemmyContext>,
|
|
) -> LemmyResult<Json<GetSiteMetadataResponse>> {
|
|
let metadata = fetch_link_metadata(&data.url, &context).await?;
|
|
|
|
Ok(Json(GetSiteMetadataResponse { metadata }))
|
|
}
|