From 0e9d7f388a51a657325356d165f29df4a5e03a94 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 24 May 2024 22:11:56 +0900 Subject: [PATCH] fix (backend-rs): don't check quoted post in antennas --- .../backend-rs/src/misc/get_note_all_texts.rs | 24 +++++++++++++++---- .../backend-rs/src/misc/get_note_summary.rs | 2 +- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/backend-rs/src/misc/get_note_all_texts.rs b/packages/backend-rs/src/misc/get_note_all_texts.rs index 12afe6d679..13fed2c581 100644 --- a/packages/backend-rs/src/misc/get_note_all_texts.rs +++ b/packages/backend-rs/src/misc/get_note_all_texts.rs @@ -2,7 +2,7 @@ use crate::database::db_conn; use crate::model::entity::{drive_file, note}; use sea_orm::{prelude::*, QuerySelect}; -/// TODO: handle name collisions better +// TODO?: handle name collisions #[crate::export(object, js_name = "NoteLikeForAllTexts")] pub struct NoteLike { pub file_ids: Vec, @@ -13,14 +13,26 @@ pub struct NoteLike { pub reply_id: Option, } -pub async fn all_texts(note: NoteLike, include_in_reply_to: bool) -> Result, DbErr> { +/// Returns [Vec] containing the post text, content warning, +/// those of the "parent" (replied/quoted) posts, and alt texts of attached files. +/// +/// ## Arguments +/// +/// * `note` - [NoteLike] object +/// * `include_parent` - whether to take the reply-to post and quoted post into account +pub async fn all_texts(note: NoteLike, include_parent: bool) -> Result, DbErr> { let db = db_conn().await?; let mut texts: Vec = vec![]; + let is_renote: bool; if let Some(text) = note.text { + is_renote = false; texts.push(text); + } else { + is_renote = true; } + if let Some(cw) = note.cw { texts.push(cw); } @@ -37,8 +49,10 @@ pub async fn all_texts(note: NoteLike, include_in_reply_to: bool) -> Result, Option)>() @@ -56,7 +70,7 @@ pub async fn all_texts(note: NoteLike, include_in_reply_to: bool) -> Result