fix: Refactor lysand note handling in conversion.rs

This commit is contained in:
aprilthepink 2024-06-17 22:33:30 +02:00
parent 56b008fcae
commit 03f6663768

View file

@ -131,25 +131,13 @@ pub async fn receive_lysand_note(note: Note, db_id: String) -> anyhow::Result<en
} else { } else {
None None
}; };
let reply_string: Option<String> = if let Some(rep) = note.replies_to.clone() { let reply_uuid: Option<String> = if let Some(rep) = note.replies_to.clone() {
let note = fetch_note_from_url(rep).await?; Some(db_post_from_url(rep).await?.id)
let fake_rep_url = Url::parse(&format!(
"https://{}/apbridge/object/{}",
API_DOMAIN.to_string(),
&note.id.to_string()
))?;
Some(fake_rep_url.into())
} else { } else {
None None
}; };
let quote_string: Option<String> = if let Some(rep) = note.quotes.clone() { let quote_uuid: Option<String> = if let Some(rep) = note.quotes.clone() {
let note = fetch_note_from_url(rep).await?; Some(db_post_from_url(rep).await?.id)
let fake_rep_url = Url::parse(&format!(
"https://{}/apbridge/object/{}",
API_DOMAIN.to_string(),
&note.id.to_string()
))?;
Some(fake_rep_url.into())
} else { } else {
None None
}; };
@ -189,8 +177,8 @@ pub async fn receive_lysand_note(note: Note, db_id: String) -> anyhow::Result<en
visibility: Set(visibility.to_string()), visibility: Set(visibility.to_string()),
title: Set(note.subject.clone()), title: Set(note.subject.clone()),
url: Set(ap_note.id.to_string()), url: Set(ap_note.id.to_string()),
reply_id: Set(reply_string), reply_id: Set(reply_uuid),
quoting_id: Set(quote_string), quoting_id: Set(quote_uuid),
spoiler_text: Set(note.subject), spoiler_text: Set(note.subject),
..Default::default() ..Default::default()
}; };