fedimbed: only sensitive spoiler if media so cw's arent double spoilered

This commit is contained in:
Cynthia Foxwell 2023-12-02 13:17:18 -07:00
parent 4c08c14a43
commit 2f4eeee255

View file

@ -131,7 +131,7 @@ async function processUrl(msg, url, spoiler = false) {
url = urlObj.href; url = urlObj.href;
} }
let platform = await resolvePlatform(url) ?? "<no nodeinfo>"; let platform = (await resolvePlatform(url)) ?? "<no nodeinfo>";
let color = PLATFORM_COLORS[platform]; let color = PLATFORM_COLORS[platform];
let platformName = platform let platformName = platform
.replace("gotosocial", "GoToSocial") .replace("gotosocial", "GoToSocial")
@ -335,9 +335,6 @@ async function processUrl(msg, url, spoiler = false) {
avatar: postData2.account?.avatar ?? postData2.user?.avatarUrl, avatar: postData2.account?.avatar ?? postData2.user?.avatarUrl,
}; };
timestamp = postData2.created_at ?? postData2.createdAt; timestamp = postData2.created_at ?? postData2.createdAt;
if (!spoiler && postData2.sensitive) {
spoiler = true;
}
emotes = postData2.emojis emotes = postData2.emojis
.filter((x) => !x.name.endsWith("@.")) .filter((x) => !x.name.endsWith("@."))
.map((x) => ({name: `:${x.name}:`, url: x.url})); .map((x) => ({name: `:${x.name}:`, url: x.url}));
@ -377,6 +374,9 @@ async function processUrl(msg, url, spoiler = false) {
} }
} }
} }
if (!spoiler && postData2.sensitive && attachments.length > 0) {
spoiler = true;
}
if (postData2.poll) { if (postData2.poll) {
poll = { poll = {
@ -407,9 +407,6 @@ async function processUrl(msg, url, spoiler = false) {
postData._misskey_content ?? postData.source?.content ?? postData.content; postData._misskey_content ?? postData.source?.content ?? postData.content;
cw = postData.summary; cw = postData.summary;
timestamp = postData.published; timestamp = postData.published;
if (!spoiler && postData.sensitive) {
spoiler = true;
}
if (postData.tag) if (postData.tag)
emotes = postData.tag emotes = postData.tag
@ -444,6 +441,10 @@ async function processUrl(msg, url, spoiler = false) {
} }
} }
if (!spoiler && postData.sensitive && attachments.length > 0) {
spoiler = true;
}
if (postData.image?.url) { if (postData.image?.url) {
const imageUrl = new URL(postData.image?.url); const imageUrl = new URL(postData.image?.url);
images.push({ images.push({