fedimbed: still spoiler sensitive text content with no cw (cohost)

This commit is contained in:
Cynthia Foxwell 2024-04-16 12:48:28 -06:00
parent 77c73e814a
commit 61e8b573b1
1 changed files with 12 additions and 4 deletions

View File

@ -183,7 +183,8 @@ async function processUrl(msg, url, spoiler = false) {
timestamp,
title,
poll,
emotes = [];
emotes = [],
sensitive = false;
// Fetch post
let rawPostData;
@ -374,6 +375,7 @@ async function processUrl(msg, url, spoiler = false) {
emotes = postData2.emojis
.filter((x) => !x.name.endsWith("@."))
.map((x) => ({name: `:${x.name}:`, url: x.url}));
sensitive = postData2.sensitive;
const attachments = postData2.media_attachments ?? postData2.files;
if (attachments) {
@ -470,6 +472,7 @@ async function processUrl(msg, url, spoiler = false) {
postData._misskey_content ?? postData.source?.content ?? postData.content;
cw = postData.summary;
timestamp = postData.published;
sensitive = postData.sensitive;
if (postData.tag) {
let tag = postData.tag;
@ -676,13 +679,18 @@ async function processUrl(msg, url, spoiler = false) {
let desc = "";
let MAX_LENGTH = 3999;
if (
cw != "" &&
(cw != "" || sensitive) &&
images.length == 0 &&
videos.length == 0 &&
audios.length == 0
) {
desc += "\u26a0 " + cw + "\n\n||" + content + "||";
MAX_LENGTH -= 8 - cw.length;
desc += "||" + content + "||";
MAX_LENGTH -= 4;
if (cw != "") {
desc = "\u26a0 " + cw + "\n\n" + desc;
MAX_LENGTH -= 4 - cw.length;
}
} else {
desc = content;
}