From: Simon Tatham Date: Sat, 13 Jan 2024 13:37:37 +0000 (+0000) Subject: When replying to a post, propagate its spoiler warning. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=d8690bec7c6a90c324a7a1a226737a627faedbc7;p=mastodonochrome.git When replying to a post, propagate its spoiler warning. I forgot this yesterday in discussions of a maths problem, and posted an answer in cleartext. Happily, it wasn't a very hard problem. But it would have been better if the default had been to repeat the spoiler text from the parent post; I could always change it manually, but if I don't want to think very hard, this would more likely be right. --- diff --git a/src/posting.rs b/src/posting.rs index 28b17b7..a387938 100644 --- a/src/posting.rs +++ b/src/posting.rs @@ -95,12 +95,20 @@ impl Post { let text = userids.map(|acct| format!("@{} ", acct)).collect(); + // Set a default content warning of the same as the post we're + // replying to. + let content_warning = if !st.sensitive { + None + } else { + Some(st.spoiler_text.clone()) + }; + Ok(Post { text, m: PostMetadata { in_reply_to_id: Some(id.to_owned()), visibility: st.visibility, // match the existing vis - content_warning: None, + content_warning, language: default_language(&ac), }, })