decord/source/modules/explicit_media_redaction/ExplicitMediaManager.tsx

756 lines
29 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 5017
// Function ID: 5018
2026-07-29 08:29:29 +00:00
// Name: resetManager
2026-08-24 06:08:38 +00:00
// Dependencies: [5018, 1218, 4975, 1391, 4999, 1980, 4201, 5023, 676, 685, 5006, 5024, 5025, 5027, 709, 5032, 5011, 5016, 5033, 5034, 11, 4808, 4628, 5043, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 5017 (resetManager)
import DISCORD_EPOCHDefault from "DISCORD_EPOCH" /* 11 */;
import redactionSettingToRenderedString from "redactionSettingToRenderedString" /* 5006 */;
import getEligibleHarmTypesConfigsForContext from "getEligibleHarmTypesConfigsForContext" /* 5024 */;
import initializeDefault from "initialize" /* 5043 */;
import closure_3 from "processMessage" /* 5018 */;
import { ReferencedMessageState } from "processMessage" /* 5018 */;
import closure_5 from "fetchFingerprint" /* 1218 */;
import closure_6 from "handlePermissionsChange" /* 4975 */;
import closure_7 from "ensureGuildLoaded" /* 1391 */;
import closure_8 from "reinjectEphemerals" /* 4999 */;
import closure_9 from "handleConnectionOpen" /* 1980 */;
import closure_10 from "handleConnectionOpen" /* 4201 */;
import closure_11 from "handleSearchMessagesSuccess" /* 5023 */;
import { MessageTypesWithLazyLoadedReferences as closure_12 } from "ME" /* 676 */;
import { UserSettingsTypes } from "MAX_FAVORITES" /* 685 */;
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 resetManager() {
2026-07-29 08:29:29 +00:00
const values = Object.values(closure_14);
2026-07-20 16:05:17 +00:00
const item = values.forEach((timeout) => {
clearTimeout(timeout.timeout);
});
2026-07-29 08:29:29 +00:00
closure_14 = {};
2026-07-20 16:05:17 +00:00
}
function maybeCancelTimeout(message, UPDATE) {
if (null != message.id) {
if (null != message.channel_id) {
2026-07-29 08:29:29 +00:00
const _HermesInternal = HermesInternal;
const combined = "" + message.channel_id + ":" + message.id;
if (null != dependencyMap[combined]) {
({ timeout, setAt } = dependencyMap[combined]);
2026-08-24 06:08:38 +00:00
if (UPDATE === redactionSettingToRenderedString.TimeoutCancelSource.UPDATE) {
2026-07-29 08:29:29 +00:00
let attachments = message.attachments;
if (attachments == null) {
attachments = [];
}
let embeds = message.embeds;
if (embeds == null) {
embeds = [];
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
const found = attachments.filter((media) => {
let obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Attachment, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.EXPLICIT, obj);
2026-07-29 08:29:29 +00:00
});
2026-08-24 06:08:38 +00:00
const found1 = embeds.filter((media) => {
let obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Embed, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.EXPLICIT, obj);
2026-07-29 08:29:29 +00:00
});
2026-08-24 06:08:38 +00:00
let tmp5Result = tmp5(5006);
2026-07-29 08:29:29 +00:00
let obj = { messageId: null, channelId: null, numOfAttachments: null, numOfEmbeds: null, numOfExplicitAttachments: null, numOfExplicitEmbeds: null };
({ id: obj2[0], channel_id: obj2[1] } = message);
obj[2] = attachments.length;
obj[3] = embeds.length;
obj[4] = found.length;
obj[5] = found1.length;
const result = tmp5Result.trackExplicitMediaScanComplete(obj);
}
2026-08-24 06:08:38 +00:00
tmp5Result = tmp5(5006);
2026-07-29 08:29:29 +00:00
tmp5Result.trackScanTiming(setAt, UPDATE);
2026-07-20 16:05:17 +00:00
const _clearTimeout = clearTimeout;
2026-07-29 08:29:29 +00:00
clearTimeout(timeout);
2026-07-23 10:11:24 +00:00
delete tmp[tmp2];
2026-07-20 16:05:17 +00:00
return true;
} else {
return false;
}
}
}
return false;
}
function withoutScheduledTimeout(arg0) {
2026-07-29 08:29:29 +00:00
return null == dependencyMap["" + arg0.channel_id + ":" + arg0.id];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
function handleUnscannedMessages(found2, isMessageUpdate) {
2026-07-20 16:05:17 +00:00
let obj = isMessageUpdate;
2026-07-29 08:29:29 +00:00
if (isMessageUpdate == null) {
2026-07-20 16:05:17 +00:00
obj = {};
}
const forceBatchScan = obj.forceBatchScan;
let tmp = undefined !== forceBatchScan && forceBatchScan;
const jitter = obj.jitter;
2026-07-29 08:29:29 +00:00
isMessageUpdate = undefined;
if (isMessageUpdate != null) {
isMessageUpdate = isMessageUpdate.isMessageUpdate;
}
const filter = found2.filter;
if (isMessageUpdate) {
let found = filter((message) => {
2026-08-24 06:08:38 +00:00
let result = found1(5024).isEligibleForScanning(message);
2026-07-29 08:29:29 +00:00
if (result) {
2026-08-24 06:08:38 +00:00
result = found1(5024).hasUnscannedMedia(message);
const tmpResult = found1(5024);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return result;
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
let found1 = found.filter(withoutScheduledTimeout);
} else {
2026-08-24 06:08:38 +00:00
found2 = filter((components) => found1(5024).isEligibleForScanning(components));
2026-07-29 08:29:29 +00:00
found1 = found2.filter(withoutScheduledTimeout);
}
const item = found1.forEach((channel_id) => {
const callback = channel_id;
const combined = "" + channel_id.channel_id + ":" + channel_id.id;
if (null == table[combined]) {
2026-08-24 06:08:38 +00:00
let obj = callback2(5011);
2026-07-29 08:29:29 +00:00
obj = { name: null };
2026-08-24 06:08:38 +00:00
obj[0] = callback(5016).MetricEvents.EXPLICIT_MEDIA_SCAN_CLIENT_TIMEOUT_CREATE;
2026-07-29 08:29:29 +00:00
obj.increment(obj);
obj = { setAt: null, timeout: null };
const _Date = Date;
obj[0] = Date.now();
const _setTimeout = setTimeout;
obj[1] = setTimeout(() => {
2026-08-24 06:08:38 +00:00
if (closure_1_16(channel_id, channel_id(closure_1_2[10]).TimeoutCancelSource.TIMEOUT)) {
const message = closure_1_8.getMessage(tmp.channel_id, tmp.id);
2026-07-29 08:29:29 +00:00
if (null != message) {
let tmp2Result = tmp2(tmp3[11]);
const unscannedMediaIds = tmp2Result.getUnscannedMediaIds(message);
({ attachmentIds, embedIds } = unscannedMediaIds);
tmp2Result = tmp2(tmp3[10]);
let obj = { channelId: null, messageId: null, attachmentIds: null, embedIds: null };
({ channel_id: obj3[0], id: obj3[1] } = tmp);
obj[2] = attachmentIds;
obj[3] = embedIds;
const result = tmp2Result.trackScanningTimedOut(obj);
}
obj = { type: "MESSAGE_EXPLICIT_CONTENT_SCAN_TIMEOUT", messageId: null, channelId: null };
({ id: obj5[1], channel_id: obj5[2] } = tmp);
2026-08-24 06:08:38 +00:00
closure_1_1(tmp3[14]).dispatch(obj);
const obj4 = closure_1_1(tmp3[14]);
2026-07-29 08:29:29 +00:00
}
}, 3000);
table[combined] = obj;
}
});
if (!tmp) {
const _Set = Set;
const set = new Set(found1.map((channel_id) => channel_id.channel_id));
tmp = set.size > 1;
}
2026-08-24 06:08:38 +00:00
closure_1 = tmp;
2026-07-29 08:29:29 +00:00
if (tmp2) {
let _setTimeout = setTimeout;
const _Math = Math;
const timerId = setTimeout(() => {
const found = found1.filter((arg0) => null != table["" + arg0.channel_id + ":" + arg0.id]);
if (0 !== found.length) {
2026-08-24 06:08:38 +00:00
const obj = found1(closure_1_2[15]);
2026-07-29 08:29:29 +00:00
if (tmp) {
const result = obj.sendMultiChannelMessagesForScanning(found);
} else {
const result1 = obj.sendMessagesForScanning(found[0].channel_id, found.map((id) => id.id));
}
}
}, 800 * Math.random());
} else if (0 !== found1.length) {
2026-08-24 06:08:38 +00:00
const obj2 = found1(5032);
2026-07-29 08:29:29 +00:00
if (tmp) {
let result = obj2.sendMultiChannelMessagesForScanning(found1);
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let result1 = obj2.sendMessagesForScanning(found1[0].channel_id, found1.map((id) => id.id));
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
function processMessagesFromAction(firstMessages, isMessageUpdate) {
const found = firstMessages.filter((message) => {
2026-08-24 06:08:38 +00:00
obj = obj(5033);
2026-07-29 08:29:29 +00:00
let result = obj.hasAttachmentsEmbedsComponentsOrSnapshots(message);
2026-08-24 06:08:38 +00:00
obj(5024);
2026-07-29 08:29:29 +00:00
if (result) {
result = 0 !== tmp3;
}
return result;
});
const mapped = firstMessages.map((referenced_message) => {
if (null != referenced_message) {
if ("referenced_message" in referenced_message) {
if (null != referenced_message.referenced_message) {
2026-08-24 06:08:38 +00:00
obj = obj(5033);
2026-07-29 08:29:29 +00:00
if (obj.hasAttachmentsEmbedsComponentsOrSnapshots(referenced_message.referenced_message)) {
if (0 !== tmpResult.getEnabledHarmTypesForMessage(referenced_message.referenced_message)) {
return referenced_message.referenced_message;
}
2026-08-24 06:08:38 +00:00
tmpResult = tmp(5024);
2026-07-29 08:29:29 +00:00
}
tmp = obj;
}
}
}
});
const found1 = mapped.filter((arg0) => null != arg0);
let tmp2 = found;
if (found1.length > 0) {
const items = [];
HermesBuiltin.arraySpread(found1, HermesBuiltin.arraySpread(found, 0));
tmp2 = items;
}
2026-08-24 06:08:38 +00:00
const arr4 = obj(5034)(tmp2, (id, id2) => id.id === id2.id && id.channel_id === id2.channel_id);
2026-07-29 08:29:29 +00:00
const found2 = arr4.filter((message) => {
2026-08-24 06:08:38 +00:00
obj = obj(5024);
2026-07-29 08:29:29 +00:00
return obj.hasUnscannedMedia(message);
});
obj = {};
obj = {};
const item = arr4.forEach((channel_id) => {
if (null == obj[channel_id.channel_id]) {
tmp[channel_id.channel_id] = { numOfAttachments: 0, numOfAttachmentsPendingScan: 0, numOfEmbeds: 0, numOfEmbedsPendingScan: 0 };
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (null == obj[channel_id.id]) {
obj = { channelId: null, numOfAttachments: 0, numOfSelfHarmAttachments: 0, numOfGoreAttachments: 0, numOfExplicitAttachments: 0, numOfEmbeds: 0, numOfSelfHarmEmbeds: 0, numOfGoreEmbeds: 0, numOfExplicitEmbeds: 0 };
obj[0] = channel_id.channel_id;
tmp2[channel_id.id] = obj;
2026-07-20 16:05:17 +00:00
}
const attachments = channel_id.attachments;
2026-07-29 08:29:29 +00:00
let num;
if (attachments != null) {
num = attachments.length;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
const embeds = channel_id.embeds;
2026-07-29 08:29:29 +00:00
let num2;
if (embeds != null) {
num2 = embeds.length;
}
if (num2 == null) {
num2 = 0;
}
2026-08-24 06:08:38 +00:00
const unscannedMediaIds = obj(closure_1_2[11]).getUnscannedMediaIds(channel_id);
2026-07-29 08:29:29 +00:00
obj[channel_id.channel_id].numOfAttachments = obj[channel_id.channel_id].numOfAttachments + num;
obj[channel_id.channel_id].numOfEmbeds = obj[channel_id.channel_id].numOfEmbeds + num2;
obj[channel_id.channel_id].numOfAttachmentsPendingScan = obj[channel_id.channel_id].numOfAttachmentsPendingScan + unscannedMediaIds.attachmentIds.length;
obj[channel_id.channel_id].numOfEmbedsPendingScan = obj[channel_id.channel_id].numOfEmbedsPendingScan + unscannedMediaIds.embedIds.length;
obj[channel_id.id].numOfAttachments = obj[channel_id.id].numOfAttachments + num;
obj[channel_id.id].numOfEmbeds = obj[channel_id.id].numOfEmbeds + num2;
2026-07-20 16:05:17 +00:00
const attachments1 = channel_id.attachments;
2026-07-29 08:29:29 +00:00
let num3;
if (attachments1 != null) {
2026-08-24 06:08:38 +00:00
num3 = attachments1.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Attachment, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.EXPLICIT, obj);
2026-07-20 16:05:17 +00:00
}).length;
}
2026-07-29 08:29:29 +00:00
if (num3 == null) {
num3 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[channel_id.id].numOfExplicitAttachments = num3;
2026-07-20 16:05:17 +00:00
const embeds1 = channel_id.embeds;
2026-07-29 08:29:29 +00:00
let num4;
if (embeds1 != null) {
2026-08-24 06:08:38 +00:00
num4 = embeds1.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Embed, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.EXPLICIT, obj);
2026-07-20 16:05:17 +00:00
}).length;
}
2026-07-29 08:29:29 +00:00
if (num4 == null) {
num4 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[channel_id.id].numOfExplicitEmbeds = num4;
2026-07-20 16:05:17 +00:00
const attachments2 = channel_id.attachments;
2026-07-29 08:29:29 +00:00
let num5;
if (attachments2 != null) {
2026-08-24 06:08:38 +00:00
num5 = attachments2.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Attachment, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.GORE, obj);
2026-07-20 16:05:17 +00:00
}).length;
}
2026-07-29 08:29:29 +00:00
if (num5 == null) {
num5 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[channel_id.id].numOfGoreAttachments = num5;
2026-07-20 16:05:17 +00:00
const embeds2 = channel_id.embeds;
2026-07-29 08:29:29 +00:00
let num6;
if (embeds2 != null) {
2026-08-24 06:08:38 +00:00
num6 = embeds2.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Embed, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.GORE, obj);
2026-07-20 16:05:17 +00:00
}).length;
}
2026-07-29 08:29:29 +00:00
if (num6 == null) {
num6 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[channel_id.id].numOfGoreEmbeds = num6;
2026-07-20 16:05:17 +00:00
const attachments3 = channel_id.attachments;
2026-07-29 08:29:29 +00:00
let num7;
if (attachments3 != null) {
2026-08-24 06:08:38 +00:00
num7 = attachments3.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Attachment, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.SELF_HARM, obj);
2026-07-20 16:05:17 +00:00
}).length;
}
2026-07-29 08:29:29 +00:00
if (num7 == null) {
num7 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[channel_id.id].numOfSelfHarmAttachments = num7;
2026-07-20 16:05:17 +00:00
const embeds3 = channel_id.embeds;
2026-07-29 08:29:29 +00:00
let num8;
if (embeds3 != null) {
2026-08-24 06:08:38 +00:00
num8 = embeds3.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Embed, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.SELF_HARM, obj);
2026-07-20 16:05:17 +00:00
}).length;
}
2026-07-29 08:29:29 +00:00
if (num8 == null) {
num8 = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[channel_id.id].numOfSelfHarmEmbeds = num8;
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
const entries = obj(11).entries(obj);
const item1 = entries.forEach((arg0) => {
2026-07-20 16:05:17 +00:00
[tmp, tmp2] = arg0;
2026-08-24 06:08:38 +00:00
obj = obj(5006);
2026-07-20 16:05:17 +00:00
obj = { channelId: tmp, numOfAttachments: tmp2.numOfAttachments, numOfAttachmentsPendingScan: tmp2.numOfAttachmentsPendingScan, numOfEmbeds: tmp2.numOfEmbeds, numOfEmbedsPendingScan: tmp2.numOfEmbedsPendingScan };
const result = obj.trackExplicitMediaRedactableMessagedLoaded(obj);
});
2026-07-29 08:29:29 +00:00
const obj3 = obj(11);
const entries1 = obj(11).entries(obj);
const item2 = entries1.forEach((arg0) => {
2026-07-20 16:05:17 +00:00
[tmp, tmp2] = arg0;
2026-08-24 06:08:38 +00:00
obj = obj(5006);
2026-07-20 16:05:17 +00:00
obj = { messageId: tmp, channelId: tmp2.channelId, numOfAttachments: tmp2.numOfAttachments, numOfGoreAttachments: tmp2.numOfGoreAttachments, numOfExplicitAttachments: tmp2.numOfExplicitAttachments, numOfSelfHarmAttachments: tmp2.numOfSelfHarmAttachments, numOfEmbeds: tmp2.numOfEmbeds, numOfGoreEmbeds: tmp2.numOfGoreEmbeds, numOfExplicitEmbeds: tmp2.numOfExplicitEmbeds, numOfSelfHarmEmbeds: tmp2.numOfSelfHarmEmbeds };
const result = obj.trackRedactableMessageLoaded(obj);
});
2026-07-29 08:29:29 +00:00
let flag = found2.length > 0;
2026-07-20 16:05:17 +00:00
if (flag) {
2026-07-29 08:29:29 +00:00
handleUnscannedMessages(found2, isMessageUpdate);
2026-07-20 16:05:17 +00:00
flag = true;
}
return flag;
}
function handleMessageUpdate(message) {
message = message.message;
if (null != message.channel_id) {
if (null != message.id) {
2026-07-29 08:29:29 +00:00
if (obj6.getChannelIdAndAuthorIdFromMessage(message).authorId !== store.getId()) {
2026-07-20 16:05:17 +00:00
if (null == message.embeds) {
if (null == message.attachments) {
2026-08-24 06:08:38 +00:00
let tmp20Result = tmp20(5006);
2026-07-29 08:29:29 +00:00
if (!tmp20Result.hasMessageSnapshotsWithAttachmentsOrEmbeds(message)) {
2026-07-20 16:05:17 +00:00
return false;
}
}
}
const embeds = message.embeds;
let length;
2026-07-29 08:29:29 +00:00
if (embeds != null) {
2026-07-20 16:05:17 +00:00
length = embeds.length;
}
if (0 === length) {
const attachments = message.attachments;
let length1;
2026-07-29 08:29:29 +00:00
if (attachments != null) {
2026-07-20 16:05:17 +00:00
length1 = attachments.length;
}
if (0 === length1) {
2026-08-24 06:08:38 +00:00
tmp20Result = tmp20(5006);
2026-07-29 08:29:29 +00:00
if (!tmp20Result.hasMessageSnapshotsWithAttachmentsOrEmbeds(message)) {
2026-07-20 16:05:17 +00:00
return false;
}
}
}
2026-07-29 08:29:29 +00:00
if (!tmp20Result1.hasUnscannedMedia(message)) {
2026-07-20 16:05:17 +00:00
message = store3.getMessage(message.channel_id, message.id);
2026-07-29 08:29:29 +00:00
if (message == null) {
2026-07-20 16:05:17 +00:00
message = message2.getMessage(message.id, message.channel_id);
}
2026-07-29 08:29:29 +00:00
if (message == null) {
2026-07-20 16:05:17 +00:00
const message1 = message.getMessage(message.channel_id, message.id);
2026-07-23 10:11:24 +00:00
message2 = undefined;
2026-07-29 08:29:29 +00:00
if (message1 != null) {
2026-07-20 16:05:17 +00:00
message2 = message1.message;
}
message = message2;
}
let hasUnscannedMediaResult = null == message;
if (!hasUnscannedMediaResult) {
2026-08-24 06:08:38 +00:00
const tmp20Result2 = tmp20(5024);
hasUnscannedMediaResult = tmp20Result2.hasUnscannedMedia(tmp20(4808).updateMessageRecord(message, message));
const tmp20Result3 = tmp20(4808);
2026-07-20 16:05:17 +00:00
}
if (!hasUnscannedMediaResult) {
2026-08-24 06:08:38 +00:00
maybeCancelTimeout(message, tmp20(5006).TimeoutCancelSource.UPDATE);
2026-07-20 16:05:17 +00:00
}
}
const channelId = store4.getChannelId();
if (message.channel_id !== channelId) {
2026-07-29 08:29:29 +00:00
if (message.channel_id !== tmp15) {
2026-07-20 16:05:17 +00:00
return false;
}
}
const message3 = store3.getMessage(message.channel_id, message.id);
2026-07-29 08:29:29 +00:00
let tmp18 = null != message3;
if (tmp18) {
2026-07-20 16:05:17 +00:00
const items = [message3];
2026-07-29 08:29:29 +00:00
tmp18 = processMessagesFromAction(items, { isMessageUpdate: true });
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp18;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
obj6 = getEligibleHarmTypesConfigsForContext;
2026-07-20 16:05:17 +00:00
}
}
return false;
}
function handleMessageCreate(optimistic) {
({ channelId, message } = optimistic);
if (!optimistic.optimistic) {
if (!optimistic.isPushNotification) {
if (null != channelId) {
if (obj2.getChannelIdAndAuthorIdFromMessage(message).authorId !== store.getId()) {
channelId = store4.getChannelId();
const currentSidebarChannelId = store2.getCurrentSidebarChannelId(channelId);
2026-07-23 10:11:24 +00:00
channel = channel.getChannel(channelId);
2026-07-29 08:29:29 +00:00
let tmp3Result = channelId === channelId || channelId === currentSidebarChannelId;
if (tmp3Result) {
const items = [message];
let flag;
if (channel != null) {
flag = channel.isPrivate();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag == null) {
flag = true;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag) {
let memberCount;
if (channel != null) {
memberCount = channel.memberCount;
}
let tmp5 = null == memberCount;
if (!tmp5) {
let memberCount1;
if (channel != null) {
memberCount1 = channel.memberCount;
}
tmp5 = memberCount1 > 100;
}
flag = tmp5;
}
const obj = { jitter: null };
obj[0] = flag;
tmp3Result = processMessagesFromAction(items, obj);
const tmp3 = processMessagesFromAction;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp3Result;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
obj2 = getEligibleHarmTypesConfigsForContext;
2026-07-20 16:05:17 +00:00
}
}
}
return false;
}
function handleMessagesLoad(arg0) {
({ channelId, messages } = arg0);
if (null != channelId) {
if (null != messages) {
channelId = store4.getChannelId();
let tmp4 = channelId === channelId || channelId === store2.getCurrentSidebarChannelId(channelId);
if (tmp4) {
tmp4 = processMessagesFromAction(messages);
}
return tmp4;
}
}
return false;
}
function handleSearchMessagesSuccess(data) {
data = data.data;
2026-08-24 06:08:38 +00:00
c0 = false;
2026-07-20 16:05:17 +00:00
const item = data.forEach((messages) => {
2026-08-24 06:08:38 +00:00
const tmp = closure_1_1(closure_1_2[22])(messages.messages);
closure_0 = closure_1_19(closure_1_1(closure_1_2[19])(closure_1_1(closure_1_2[22])(messages.messages), (id, id2) => id.id === id2.id && id.channel_id === id2.channel_id)) || closure_0;
2026-07-20 16:05:17 +00:00
});
2026-07-23 10:11:24 +00:00
return c0;
2026-07-20 16:05:17 +00:00
}
function handleLoadPinnedMessages(pins) {
pins = pins.pins;
return processMessagesFromAction(pins.map((message) => message.message));
}
function handleForumPostsLoad(threads) {
threads = threads.threads;
let tmp2 = null != threads;
if (tmp2) {
let tmp4 = store5.getGuildId() === tmp;
if (tmp4) {
2026-08-24 06:08:38 +00:00
const keys = DISCORD_EPOCHDefault.keys(threads);
2026-07-20 16:05:17 +00:00
tmp4 = processMessagesFromAction(keys.map((arg0) => threads[arg0].first_message));
2026-08-24 06:08:38 +00:00
const obj = DISCORD_EPOCHDefault;
2026-07-20 16:05:17 +00:00
}
tmp2 = tmp4;
}
return tmp2;
}
function handleThreadsLoad(firstMessages) {
firstMessages = firstMessages.firstMessages;
let tmp2 = null != firstMessages;
if (tmp2) {
2026-07-29 08:29:29 +00:00
let tmp4 = store5.getGuildId() === tmp;
if (tmp4) {
tmp4 = processMessagesFromAction(firstMessages, { forceBatchScan: true });
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp2 = tmp4;
2026-07-20 16:05:17 +00:00
}
return tmp2;
}
function handleSidebarViewChannel(channelId) {
channelId = channelId.channelId;
let tmp = null != channelId;
if (tmp) {
tmp = maybeScanMessagesForChannelId(channelId);
}
return tmp;
}
function handleChannelSelect(channelId) {
channelId = channelId.channelId;
let tmp = null != channelId;
if (tmp) {
2026-07-29 08:29:29 +00:00
let tmp3 = channelId === store4.getChannelId();
if (tmp3) {
tmp3 = maybeScanMessagesForChannelId(channelId);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = tmp3;
2026-07-20 16:05:17 +00:00
}
return tmp;
}
function handleUserSettingsUpdate(local) {
if (local.local) {
if (local.settings.type === UserSettingsTypes.PRELOADED_USER_SETTINGS) {
const channelId = store4.getChannelId();
let tmp5 = null != channelId;
if (tmp5) {
tmp5 = maybeScanMessagesForChannelId(channelId);
}
return tmp5;
}
}
return false;
}
function handleVoiceChannelChatOpen(chatOpen) {
2026-07-29 08:29:29 +00:00
chatOpen = chatOpen.chatOpen;
if (chatOpen) {
chatOpen = maybeScanMessagesForChannelId(tmp);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return chatOpen;
2026-07-20 16:05:17 +00:00
}
function maybeScanMessagesForChannelId(channelId) {
const messages = store3.getMessages(channelId);
let tmp = 0 !== messages.length;
if (tmp) {
2026-07-29 08:29:29 +00:00
const found = messages.filter((message) => {
2026-08-24 06:08:38 +00:00
obj = obj(5033);
2026-07-29 08:29:29 +00:00
let result = obj.hasAttachmentsEmbedsComponentsOrSnapshots(message);
if (result) {
2026-08-24 06:08:38 +00:00
result = 0 !== obj(5024).getEnabledHarmTypesForMessage(message);
const tmpResult = obj(5024);
2026-07-29 08:29:29 +00:00
}
return result;
});
const mapped = messages.map((type) => {
if (set.has(type.type)) {
if (null != type.messageReference) {
messageByReference = messageByReference.getMessageByReference(type.messageReference);
if (messageByReference.state === constants.LOADED) {
if (null != messageByReference.message) {
2026-08-24 06:08:38 +00:00
obj = obj(5033);
2026-07-29 08:29:29 +00:00
if (obj.hasAttachmentsEmbedsComponentsOrSnapshots(messageByReference.message)) {
if (0 !== tmp5Result.getEnabledHarmTypesForMessage(messageByReference.message)) {
return messageByReference.message;
}
2026-08-24 06:08:38 +00:00
tmp5Result = tmp5(5024);
2026-07-29 08:29:29 +00:00
}
tmp5 = obj;
}
}
}
}
});
const found1 = mapped.filter((arg0) => null != arg0);
let tmp3 = found;
if (found1.length > 0) {
const items = [];
HermesBuiltin.arraySpread(found1, HermesBuiltin.arraySpread(found, 0));
tmp3 = items;
}
2026-08-24 06:08:38 +00:00
const arr5 = obj(5034)(tmp3, (id, id2) => id.id === id2.id && id.channel_id === id2.channel_id);
2026-07-29 08:29:29 +00:00
const found2 = arr5.filter((message) => {
2026-08-24 06:08:38 +00:00
obj = obj(5024);
2026-07-29 08:29:29 +00:00
return obj.hasUnscannedMedia(message);
});
obj = {};
obj = {};
const item = arr5.forEach((channel_id) => {
if (null == obj[channel_id.channel_id]) {
tmp[channel_id.channel_id] = { numOfAttachments: 0, numOfAttachmentsPendingScan: 0, numOfEmbeds: 0, numOfEmbedsPendingScan: 0 };
}
if (null == obj[channel_id.id]) {
obj = { channelId: null, numOfAttachments: 0, numOfSelfHarmAttachments: 0, numOfGoreAttachments: 0, numOfExplicitAttachments: 0, numOfEmbeds: 0, numOfSelfHarmEmbeds: 0, numOfGoreEmbeds: 0, numOfExplicitEmbeds: 0 };
obj[0] = channel_id.channel_id;
tmp2[channel_id.id] = obj;
}
const attachments = channel_id.attachments;
let num;
if (attachments != null) {
num = attachments.length;
}
if (num == null) {
num = 0;
}
const embeds = channel_id.embeds;
let num2;
if (embeds != null) {
num2 = embeds.length;
}
if (num2 == null) {
num2 = 0;
}
2026-08-24 06:08:38 +00:00
const unscannedMediaIds = obj(closure_1_2[11]).getUnscannedMediaIds(channel_id);
2026-07-29 08:29:29 +00:00
obj[channel_id.channel_id].numOfAttachments = obj[channel_id.channel_id].numOfAttachments + num;
obj[channel_id.channel_id].numOfEmbeds = obj[channel_id.channel_id].numOfEmbeds + num2;
obj[channel_id.channel_id].numOfAttachmentsPendingScan = obj[channel_id.channel_id].numOfAttachmentsPendingScan + unscannedMediaIds.attachmentIds.length;
obj[channel_id.channel_id].numOfEmbedsPendingScan = obj[channel_id.channel_id].numOfEmbedsPendingScan + unscannedMediaIds.embedIds.length;
obj[channel_id.id].numOfAttachments = obj[channel_id.id].numOfAttachments + num;
obj[channel_id.id].numOfEmbeds = obj[channel_id.id].numOfEmbeds + num2;
const attachments1 = channel_id.attachments;
let num3;
if (attachments1 != null) {
2026-08-24 06:08:38 +00:00
num3 = attachments1.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Attachment, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.EXPLICIT, obj);
2026-07-29 08:29:29 +00:00
}).length;
}
if (num3 == null) {
num3 = 0;
}
obj[channel_id.id].numOfExplicitAttachments = num3;
const embeds1 = channel_id.embeds;
let num4;
if (embeds1 != null) {
2026-08-24 06:08:38 +00:00
num4 = embeds1.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Embed, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.EXPLICIT, obj);
2026-07-29 08:29:29 +00:00
}).length;
}
if (num4 == null) {
num4 = 0;
}
obj[channel_id.id].numOfExplicitEmbeds = num4;
const attachments2 = channel_id.attachments;
let num5;
if (attachments2 != null) {
2026-08-24 06:08:38 +00:00
num5 = attachments2.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Attachment, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.GORE, obj);
2026-07-29 08:29:29 +00:00
}).length;
}
if (num5 == null) {
num5 = 0;
}
obj[channel_id.id].numOfGoreAttachments = num5;
const embeds2 = channel_id.embeds;
let num6;
if (embeds2 != null) {
2026-08-24 06:08:38 +00:00
num6 = embeds2.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Embed, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.GORE, obj);
2026-07-29 08:29:29 +00:00
}).length;
}
if (num6 == null) {
num6 = 0;
}
obj[channel_id.id].numOfGoreEmbeds = num6;
const attachments3 = channel_id.attachments;
let num7;
if (attachments3 != null) {
2026-08-24 06:08:38 +00:00
num7 = attachments3.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Attachment, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.SELF_HARM, obj);
2026-07-29 08:29:29 +00:00
}).length;
}
if (num7 == null) {
num7 = 0;
}
obj[channel_id.id].numOfSelfHarmAttachments = num7;
const embeds3 = channel_id.embeds;
let num8;
if (embeds3 != null) {
2026-08-24 06:08:38 +00:00
num8 = embeds3.filter((media) => {
obj = callback(5024);
obj = { type: callback(5027).ObscuredMediaTypes.Embed, media };
return obj.isMediaFlaggedForHarmType(callback(5025).ContentHarmType.SELF_HARM, obj);
2026-07-29 08:29:29 +00:00
}).length;
}
if (num8 == null) {
num8 = 0;
}
obj[channel_id.id].numOfSelfHarmEmbeds = num8;
});
const entries = obj(11).entries(obj);
const item1 = entries.forEach((arg0) => {
[tmp, tmp2] = arg0;
2026-08-24 06:08:38 +00:00
obj = obj(5006);
2026-07-29 08:29:29 +00:00
obj = { channelId: tmp, numOfAttachments: tmp2.numOfAttachments, numOfAttachmentsPendingScan: tmp2.numOfAttachmentsPendingScan, numOfEmbeds: tmp2.numOfEmbeds, numOfEmbedsPendingScan: tmp2.numOfEmbedsPendingScan };
const result = obj.trackExplicitMediaRedactableMessagedLoaded(obj);
});
const obj3 = obj(11);
const entries1 = obj(11).entries(obj);
const item2 = entries1.forEach((arg0) => {
[tmp, tmp2] = arg0;
2026-08-24 06:08:38 +00:00
obj = obj(5006);
2026-07-29 08:29:29 +00:00
obj = { messageId: tmp, channelId: tmp2.channelId, numOfAttachments: tmp2.numOfAttachments, numOfGoreAttachments: tmp2.numOfGoreAttachments, numOfSelfHarmAttachments: tmp2.numOfSelfHarmAttachments, numOfExplicitAttachments: tmp2.numOfExplicitAttachments, numOfEmbeds: tmp2.numOfEmbeds, numOfGoreEmbeds: tmp2.numOfGoreEmbeds, numOfExplicitEmbeds: tmp2.numOfExplicitEmbeds, numOfSelfHarmEmbeds: tmp2.numOfSelfHarmEmbeds };
const result = obj.trackRedactableMessageLoaded(obj);
});
let flag = found2.length > 0;
if (flag) {
handleUnscannedMessages(found2);
flag = true;
}
tmp = flag;
const obj4 = obj(11);
2026-07-20 16:05:17 +00:00
}
return tmp;
}
2026-07-29 08:29:29 +00:00
let closure_14 = {};
2026-08-24 06:08:38 +00:00
initializeDefault;
2026-07-29 08:29:29 +00:00
let prototype = function ExplicitMediaManager() {
const applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target);
applyArgumentsResult.actions = { LOAD_MESSAGES_SUCCESS: handleMessagesLoad, LOAD_FORUM_POSTS: handleForumPostsLoad, LOAD_THREADS_SUCCESS: handleThreadsLoad, LOAD_ARCHIVED_THREADS_SUCCESS: handleThreadsLoad, SIDEBAR_VIEW_CHANNEL: handleSidebarViewChannel, MESSAGE_CREATE: handleMessageCreate, MESSAGE_UPDATE: handleMessageUpdate, LOGOUT: resetManager, SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess, MOD_VIEW_SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess, CHANNEL_SELECT: handleChannelSelect, LOAD_PINNED_MESSAGES_SUCCESS: handleLoadPinnedMessages, USER_SETTINGS_PROTO_UPDATE: handleUserSettingsUpdate, CHANNEL_RTC_UPDATE_CHAT_OPEN: handleVoiceChannelChatOpen };
return applyArgumentsResult;
}.prototype;
class prototype extends tmp2 {
}
prototype = new prototype();
2026-08-24 06:08:38 +00:00
let result = require("set").fileFinishedImporting("modules/explicit_media_redaction/ExplicitMediaManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default prototype;
2026-07-20 16:05:17 +00:00
export const MESSAGE_SCAN_TIMEOUT = 3000;
export const MAX_TIMEOUT_FOR_JITTER = 800;