From 99b8a405660a767411c4fc356c72758bf62ac28d Mon Sep 17 00:00:00 2001 From: sup39 <dev@sup39.dev> Date: Fri, 12 Apr 2024 22:32:42 +0900 Subject: [PATCH] fix (backend-rs): selected texts may be None in check_word_mute Co-authored-by: naskya <m@naskya.net> --- .../backend-rs/src/misc/check_word_mute.rs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/backend-rs/src/misc/check_word_mute.rs b/packages/backend-rs/src/misc/check_word_mute.rs index 3a761a61b0..801175c2af 100644 --- a/packages/backend-rs/src/misc/check_word_mute.rs +++ b/packages/backend-rs/src/misc/check_word_mute.rs @@ -31,21 +31,27 @@ async fn all_texts(note: NoteLike) -> Result<Vec<String>, DbErr> { .select_only() .column(drive_file::Column::Comment) .filter(drive_file::Column::Id.is_in(note.file_ids)) - .into_tuple::<String>() + .into_tuple::<Option<String>>() .all(db) - .await?, + .await? + .into_iter() + .flatten(), ); if let Some(renote_id) = note.renote_id { if let Some((text, cw)) = note::Entity::find_by_id(renote_id) .select_only() .columns([note::Column::Text, note::Column::Cw]) - .into_tuple::<(String, String)>() + .into_tuple::<(Option<String>, Option<String>)>() .one(db) .await? { - texts.push(text); - texts.push(cw); + if let Some(t) = text { + texts.push(t); + } + if let Some(c) = cw { + texts.push(c); + } } } @@ -53,12 +59,16 @@ async fn all_texts(note: NoteLike) -> Result<Vec<String>, DbErr> { if let Some((text, cw)) = note::Entity::find_by_id(reply_id) .select_only() .columns([note::Column::Text, note::Column::Cw]) - .into_tuple::<(String, String)>() + .into_tuple::<(Option<String>, Option<String>)>() .one(db) .await? { - texts.push(text); - texts.push(cw); + if let Some(t) = text { + texts.push(t); + } + if let Some(c) = cw { + texts.push(c); + } } }