mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-09 03:31:53 +00:00
Addressing PR comments
This commit is contained in:
parent
7b887394e3
commit
17315cb164
4 changed files with 21 additions and 26 deletions
|
@ -132,6 +132,7 @@ pub async fn create_post(
|
||||||
|
|
||||||
let post_form = PostInsertForm::builder()
|
let post_form = PostInsertForm::builder()
|
||||||
.name(data.name.trim().to_string())
|
.name(data.name.trim().to_string())
|
||||||
|
.url_content_type(metadata.content_type)
|
||||||
.url(url)
|
.url(url)
|
||||||
.body(body)
|
.body(body)
|
||||||
.alt_text(alt_text.clone())
|
.alt_text(alt_text.clone())
|
||||||
|
|
|
@ -81,7 +81,8 @@ pub async fn update_post(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch post links and thumbnail if url was updated
|
// Fetch post links and thumbnail if url was updated
|
||||||
let (embed_title, embed_description, embed_video_url, metadata_thumbnail) = match &url {
|
let (embed_title, embed_description, embed_video_url, metadata_thumbnail, metadata_content_type) =
|
||||||
|
match &url {
|
||||||
Some(url) => {
|
Some(url) => {
|
||||||
// Only generate the thumbnail if there's no custom thumbnail provided,
|
// Only generate the thumbnail if there's no custom thumbnail provided,
|
||||||
// otherwise it will save it in pictrs
|
// otherwise it will save it in pictrs
|
||||||
|
@ -93,6 +94,7 @@ pub async fn update_post(
|
||||||
Some(metadata.opengraph_data.description),
|
Some(metadata.opengraph_data.description),
|
||||||
Some(metadata.opengraph_data.embed_video_url),
|
Some(metadata.opengraph_data.embed_video_url),
|
||||||
Some(metadata.thumbnail),
|
Some(metadata.thumbnail),
|
||||||
|
Some(metadata.content_type),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
_ => Default::default(),
|
_ => Default::default(),
|
||||||
|
@ -123,6 +125,7 @@ pub async fn update_post(
|
||||||
let post_form = PostUpdateForm {
|
let post_form = PostUpdateForm {
|
||||||
name: data.name.clone(),
|
name: data.name.clone(),
|
||||||
url,
|
url,
|
||||||
|
url_content_type: metadata_content_type,
|
||||||
body: diesel_option_overwrite(body),
|
body: diesel_option_overwrite(body),
|
||||||
alt_text: diesel_option_overwrite(alt_text.clone()),
|
alt_text: diesel_option_overwrite(alt_text.clone()),
|
||||||
nsfw: data.nsfw,
|
nsfw: data.nsfw,
|
||||||
|
|
|
@ -74,8 +74,6 @@ pub(crate) struct Link {
|
||||||
href: Url,
|
href: Url,
|
||||||
media_type: Option<String>,
|
media_type: Option<String>,
|
||||||
r#type: LinkType,
|
r#type: LinkType,
|
||||||
/// Used for alt_text
|
|
||||||
name: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
@ -94,8 +92,6 @@ pub(crate) struct Document {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: DocumentType,
|
kind: DocumentType,
|
||||||
url: Url,
|
url: Url,
|
||||||
/// Used for alt_text
|
|
||||||
name: Option<String>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
|
@ -120,12 +116,8 @@ impl Attachment {
|
||||||
|
|
||||||
pub(crate) fn alt_text(self) -> Option<String> {
|
pub(crate) fn alt_text(self) -> Option<String> {
|
||||||
match self {
|
match self {
|
||||||
// url as sent by Lemmy (new)
|
|
||||||
Attachment::Link(l) => l.name,
|
|
||||||
// image sent by lotide
|
|
||||||
Attachment::Image(i) => i.name,
|
Attachment::Image(i) => i.name,
|
||||||
// sent by mobilizon
|
_ => None,
|
||||||
Attachment::Document(d) => d.name,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +190,6 @@ impl Attachment {
|
||||||
href: url,
|
href: url,
|
||||||
media_type,
|
media_type,
|
||||||
r#type: Default::default(),
|
r#type: Default::default(),
|
||||||
name,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ pub struct PostUpdateForm {
|
||||||
pub language_id: Option<LanguageId>,
|
pub language_id: Option<LanguageId>,
|
||||||
pub featured_community: Option<bool>,
|
pub featured_community: Option<bool>,
|
||||||
pub featured_local: Option<bool>,
|
pub featured_local: Option<bool>,
|
||||||
pub url_content_type: Option<String>,
|
pub url_content_type: Option<Option<String>>,
|
||||||
pub alt_text: Option<Option<String>>,
|
pub alt_text: Option<Option<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue