decord/source/modules/messages/MessageAttachmentUtils.tsx

189 lines
7.5 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 11240
// Function ID: 11241
2026-07-20 16:05:17 +00:00
// Name: getForumPostShouldObscure
2026-08-24 06:08:38 +00:00
// Dependencies: [4024, 676, 5024, 5027, 5026, 8554, 647, 4069, 10756, 1236, 2]
2026-07-20 16:05:17 +00:00
// Exports: getObscureReasonForAttachment, getObscureReasonForEmbed, getObscureReasonForUnfurledMediaItem, getObscuredAlt, useShouldObscure
2026-08-24 06:08:38 +00:00
// Module 11240 (getForumPostShouldObscure)
import getSystemLocale from "getSystemLocale" /* 1236 */;
import getEligibleHarmTypesConfigsForContext from "getEligibleHarmTypesConfigsForContext" /* 5024 */;
import ObscureReason from "ObscureReason" /* 5026 */;
import ContentHarmTypeChannel from "ContentHarmTypeChannel" /* 5027 */;
import isMediaAttachment from "isMediaAttachment" /* 8554 */;
import computeGlobalSpoilerDisplayDefault from "computeGlobalSpoilerDisplay" /* 10756 */;
import closure_3 from "getUncachedChannelPermissions" /* 4024 */;
import { Permissions } from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
2026-07-20 16:05:17 +00:00
function getForumPostShouldObscure(media, arg1, enabledHarmTypesBitmaskForChannelType) {
if (null == media) {
const items = [false, undefined];
return items;
} else {
const type = media.type;
2026-08-24 06:08:38 +00:00
if (isMediaAttachment.ForumPostMediaTypes.EMBED === type) {
2026-07-29 08:29:29 +00:00
let obj = { type: null, media: null };
2026-08-24 06:08:38 +00:00
obj[0] = tmp4(5027).ObscuredMediaTypes.Embed;
2026-07-29 08:29:29 +00:00
obj[1] = media;
let tmp = obj;
2026-08-24 06:08:38 +00:00
} else if (tmp4(8554).ForumPostMediaTypes.ATTACHMENT === type) {
2026-07-29 08:29:29 +00:00
obj = { type: null, media: null };
2026-08-24 06:08:38 +00:00
obj[0] = tmp4(5027).ObscuredMediaTypes.Attachment;
2026-07-29 08:29:29 +00:00
obj[1] = media;
tmp = obj;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
tmp = null;
2026-08-24 06:08:38 +00:00
if (tmp4(8554).ForumPostMediaTypes.COMPONENT === type) {
2026-07-29 08:29:29 +00:00
obj = { type: null, media: null };
2026-08-24 06:08:38 +00:00
obj[0] = tmp4(5027).ObscuredMediaTypes.GenericMedia;
2026-07-29 08:29:29 +00:00
obj[1] = media.srcUnfurledMediaItem;
tmp = obj;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
if (null == tmp) {
2026-07-20 16:05:17 +00:00
const items1 = [false, undefined];
return items1;
} else {
2026-08-24 06:08:38 +00:00
let tmp4Result = tmp4(5024);
2026-07-29 08:29:29 +00:00
const mediaObscuredReasonFromBitmask = tmp4Result.getMediaObscuredReasonFromBitmask(tmp, enabledHarmTypesBitmaskForChannelType);
2026-08-24 06:08:38 +00:00
tmp4Result = tmp4(5024);
2026-07-20 16:05:17 +00:00
if (mediaObscuredReasonFromBitmask.length > 0) {
const items2 = [true, mediaObscuredReasonFromBitmask[0]];
2026-07-29 08:29:29 +00:00
let tmp2 = items2;
2026-07-20 16:05:17 +00:00
} else {
const items3 = [, ];
2026-07-29 08:29:29 +00:00
if (tmp8) {
2026-07-20 16:05:17 +00:00
items3[0] = true;
2026-08-24 06:08:38 +00:00
items3[1] = tmp4(5026).ObscureReason.POTENTIAL_EXPLICIT_CONTENT;
2026-07-29 08:29:29 +00:00
tmp2 = items3;
2026-07-20 16:05:17 +00:00
} else if (media.spoiler) {
items3[0] = arg1;
2026-08-24 06:08:38 +00:00
items3[1] = tmp4(5026).ObscureReason.SPOILER;
2026-07-29 08:29:29 +00:00
tmp2 = items3;
2026-07-20 16:05:17 +00:00
} else {
items3[0] = false;
items3[1] = undefined;
2026-07-29 08:29:29 +00:00
tmp2 = items3;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
return tmp2;
2026-07-20 16:05:17 +00:00
}
}
}
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/messages/MessageAttachmentUtils.tsx");
2026-07-20 16:05:17 +00:00
2026-08-15 05:55:55 +00:00
export const getObscureReasonForAttachment = function getObscureReasonForAttachment(attachment, enabledHarmTypesBitmaskForChannelAndAuthorId, c2) {
let flag = c2;
if (c2 === undefined) {
flag = false;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
let obj = getEligibleHarmTypesConfigsForContext;
obj = { type: ContentHarmTypeChannel.ObscuredMediaTypes.Attachment, media: attachment };
2026-07-20 16:05:17 +00:00
const mediaObscuredReasonFromBitmask = obj.getMediaObscuredReasonFromBitmask(obj, enabledHarmTypesBitmaskForChannelAndAuthorId);
2026-08-24 06:08:38 +00:00
getEligibleHarmTypesConfigsForContext;
obj = { type: ContentHarmTypeChannel.ObscuredMediaTypes.Attachment, media: attachment };
2026-07-20 16:05:17 +00:00
if (mediaObscuredReasonFromBitmask.length > 0) {
let first = mediaObscuredReasonFromBitmask[0];
2026-07-29 08:29:29 +00:00
} else if (tmp4) {
2026-08-24 06:08:38 +00:00
first = tmp(5026).ObscureReason.POTENTIAL_EXPLICIT_CONTENT;
2026-07-20 16:05:17 +00:00
} else {
first = null;
2026-08-15 05:55:55 +00:00
if (flag) {
2026-08-24 06:08:38 +00:00
first = tmp(5026).ObscureReason.SPOILER;
2026-07-20 16:05:17 +00:00
}
}
return first;
};
2026-08-24 06:08:38 +00:00
export const getObscureReasonForEmbed = function getObscureReasonForEmbed(media, message, flag2, closure_3) {
let obj = getEligibleHarmTypesConfigsForContext;
obj = { type: ContentHarmTypeChannel.ObscuredMediaTypes.Embed, media };
const mediaObscuredReasonFromBitmask = obj.getMediaObscuredReasonFromBitmask(obj, closure_3);
2026-07-29 08:29:29 +00:00
const bot = message.author.bot;
let isMediaScanPendingResult = !bot;
if (!bot) {
obj = { type: null, media: null };
2026-08-24 06:08:38 +00:00
obj[0] = tmp(5027).ObscuredMediaTypes.Embed;
2026-08-15 05:55:55 +00:00
obj[1] = media;
2026-08-24 06:08:38 +00:00
isMediaScanPendingResult = tmp(5024).isMediaScanPending(obj, closure_3);
const tmpResult = tmp(5024);
2026-07-20 16:05:17 +00:00
}
if (mediaObscuredReasonFromBitmask.length > 0) {
let first = mediaObscuredReasonFromBitmask[0];
} else if (isMediaScanPendingResult) {
2026-08-24 06:08:38 +00:00
first = tmp(5026).ObscureReason.POTENTIAL_EXPLICIT_CONTENT;
2026-07-20 16:05:17 +00:00
} else {
first = null;
2026-07-29 08:29:29 +00:00
if (flag2) {
2026-08-24 06:08:38 +00:00
first = tmp(5026).ObscureReason.SPOILER;
2026-07-20 16:05:17 +00:00
}
}
return first;
};
2026-08-15 05:55:55 +00:00
export const getObscureReasonForUnfurledMediaItem = function getObscureReasonForUnfurledMediaItem(media, enabledContentHarmTypeFlags, arg2, isBot) {
let flag = arg2;
if (arg2 === undefined) {
2026-07-20 16:05:17 +00:00
flag = false;
}
2026-07-29 08:29:29 +00:00
let flag2 = isBot;
if (isBot === undefined) {
2026-07-20 16:05:17 +00:00
flag2 = false;
}
2026-08-24 06:08:38 +00:00
let obj = getEligibleHarmTypesConfigsForContext;
obj = { type: ContentHarmTypeChannel.ObscuredMediaTypes.GenericMedia, media };
2026-07-20 16:05:17 +00:00
const mediaObscuredReasonFromBitmask = obj.getMediaObscuredReasonFromBitmask(obj, enabledContentHarmTypeFlags);
let isMediaScanPendingResult = !flag2;
2026-07-29 08:29:29 +00:00
if (!flag2) {
obj = { type: null, media: null };
2026-08-24 06:08:38 +00:00
obj[0] = tmp(5027).ObscuredMediaTypes.GenericMedia;
2026-07-29 08:29:29 +00:00
obj[1] = media;
2026-08-24 06:08:38 +00:00
isMediaScanPendingResult = tmp(5024).isMediaScanPending(obj, enabledContentHarmTypeFlags);
const tmpResult = tmp(5024);
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
if (mediaObscuredReasonFromBitmask.includes(ObscureReason.ObscureReason.EXPLICIT_CONTENT)) {
let EXPLICIT_CONTENT = tmp(5026).ObscureReason.EXPLICIT_CONTENT;
} else if (mediaObscuredReasonFromBitmask.includes(tmp(5026).ObscureReason.GORE_CONTENT)) {
EXPLICIT_CONTENT = tmp(5026).ObscureReason.GORE_CONTENT;
} else if (mediaObscuredReasonFromBitmask.includes(tmp(5026).ObscureReason.SELF_HARM_CONTENT)) {
EXPLICIT_CONTENT = tmp(5026).ObscureReason.SELF_HARM_CONTENT;
2026-07-20 16:05:17 +00:00
} else if (isMediaScanPendingResult) {
2026-08-24 06:08:38 +00:00
EXPLICIT_CONTENT = tmp(5026).ObscureReason.POTENTIAL_EXPLICIT_CONTENT;
2026-07-20 16:05:17 +00:00
} else {
EXPLICIT_CONTENT = null;
if (flag) {
2026-08-24 06:08:38 +00:00
EXPLICIT_CONTENT = tmp(5026).ObscureReason.SPOILER;
2026-07-20 16:05:17 +00:00
}
}
return EXPLICIT_CONTENT;
};
export { getForumPostShouldObscure };
export const useShouldObscure = function useShouldObscure(channel) {
2026-07-23 10:11:24 +00:00
channel = channel.channel;
2026-08-24 06:08:38 +00:00
const items = [closure_3];
2026-07-29 08:29:29 +00:00
const stateFromStores = channel(647).useStateFromStores(items, () => {
2026-07-20 16:05:17 +00:00
let canResult = null != channel;
if (canResult) {
2026-08-24 06:08:38 +00:00
canResult = closure_1_3.can(closure_1_4.MANAGE_MESSAGES, tmp);
2026-07-20 16:05:17 +00:00
}
return canResult;
});
2026-08-24 06:08:38 +00:00
const RenderSpoilers = channel(4069).RenderSpoilers;
2026-07-20 16:05:17 +00:00
const setting = RenderSpoilers.useSetting();
2026-07-29 08:29:29 +00:00
const obj = channel(647);
2026-08-24 06:08:38 +00:00
const enabledHarmTypesBitmaskForChannelType = channel(5024).getEnabledHarmTypesBitmaskForChannelType(channel(5027).ContentHarmTypeChannel.GUILD);
return getForumPostShouldObscure(channel.media, !computeGlobalSpoilerDisplayDefault(setting, stateFromStores), enabledHarmTypesBitmaskForChannelType);
2026-07-20 16:05:17 +00:00
};
export const getObscuredAlt = function getObscuredAlt(obscureReason) {
2026-08-24 06:08:38 +00:00
if (ObscureReason.ObscureReason.EXPLICIT_CONTENT !== obscureReason) {
if (tmp(5026).ObscureReason.GORE_CONTENT !== obscureReason) {
if (tmp(5026).ObscureReason.SELF_HARM_CONTENT !== obscureReason) {
if (tmp(5026).ObscureReason.SPOILER === obscureReason) {
2026-07-29 08:29:29 +00:00
const intl = tmp(1236).intl;
return intl.string(tmp(1236).t["XpfDH+"]);
2026-07-20 16:05:17 +00:00
}
}
}
}
2026-07-29 08:29:29 +00:00
const intl2 = tmp(1236).intl;
2026-08-24 06:08:38 +00:00
return intl2.string(getSystemLocale.t.SEgHFh);
2026-07-20 16:05:17 +00:00
};