decord/source/modules/media_channel/MediaPostEmbedManager.tsx

263 lines
11 KiB
TypeScript
Raw Normal View History

// Module ID: 17917
// Function ID: 17918
// Name: MediaPostEmbedManager
// Dependencies: [2013, 502, 2021, 11559, 1074, 1095, 4784, 1384, 12005, 7221, 17537, 2]
2026-07-20 16:05:17 +00:00
// Module 17917 (MediaPostEmbedManager)
import MediaPostEmbedUtils from "MediaPostEmbedUtils" /* 4784 */;
import setupLoadFromMessageManagerHandlersDefault from "setupLoadFromMessageManagerHandlers" /* 17537 */;
import GatedChannelStore from "GatedChannelStore" /* 2013 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
import GuildMemberStore from "GuildMemberStore" /* 2021 */;
import MediaPostEmbedStore from "MediaPostEmbedStore" /* 11559 */;
import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 7221 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-07-20 16:05:17 +00:00
function resolveMediaPostEmbeds(embeds) {
2026-08-24 06:08:38 +00:00
closure_0 = embeds;
2026-07-20 16:05:17 +00:00
embeds = embeds.embeds;
let found;
2026-07-29 08:29:29 +00:00
if (embeds != null) {
found = embeds.filter((type) => type.type === first_message(closure_1_2[5]).MessageEmbedTypes.POST_PREVIEW);
2026-07-20 16:05:17 +00:00
}
let tmp2 = null != found;
if (tmp2) {
tmp2 = 0 !== found.length;
}
if (tmp2) {
const item = found.forEach((url) => {
if (null != url.url) {
const mediaPostEmbedChannelPath = MediaPostEmbedUtils.getMediaPostEmbedChannelPath(url.url);
2026-07-20 16:05:17 +00:00
if (null != mediaPostEmbedChannelPath) {
let threadId;
2026-07-29 08:29:29 +00:00
if (mediaPostEmbedChannelPath != null) {
2026-07-20 16:05:17 +00:00
threadId = mediaPostEmbedChannelPath.threadId;
}
if (null != threadId) {
let channelId;
2026-07-29 08:29:29 +00:00
if (mediaPostEmbedChannelPath != null) {
2026-07-20 16:05:17 +00:00
channelId = mediaPostEmbedChannelPath.channelId;
}
if (null != channelId) {
if (embedFetchState.getEmbedFetchState(mediaPostEmbedChannelPath.threadId) === constants.NOT_FETCHED) {
if (!set.has(mediaPostEmbedChannelPath.threadId)) {
2026-07-29 08:29:29 +00:00
obj4.add(mediaPostEmbedChannelPath.threadId);
2026-07-20 16:05:17 +00:00
let guildId;
id = id.getId();
2026-07-29 08:29:29 +00:00
if (mediaPostEmbedChannelPath != null) {
2026-07-20 16:05:17 +00:00
guildId = mediaPostEmbedChannelPath.guildId;
}
const isMemberResult = member.isMember(guildId, id);
const isChannelGatedResult = channelGated.isChannelGated(mediaPostEmbedChannelPath.guildId, mediaPostEmbedChannelPath.channelId);
2026-07-29 08:29:29 +00:00
let num = first_message.flags;
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp14 = isMemberResult;
const tmp17Result = tmp17(tmp18[7]);
2026-07-20 16:05:17 +00:00
if (isMemberResult) {
2026-07-29 08:29:29 +00:00
tmp14 = false === isChannelGatedResult;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!tmp14) {
let tmp15 = !isMemberResult;
if (!isMemberResult) {
tmp15 = hasFlagResult;
}
tmp14 = tmp15;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!tmp14) {
const mediaPostEmbed = tmp17(tmp18[8]).fetchMediaPostEmbed(mediaPostEmbedChannelPath.threadId);
const tmp17Result2 = tmp17(tmp18[8]);
2026-07-20 16:05:17 +00:00
}
hasFlagResult = tmp17(tmp18[7]).hasFlag(num, constants2.IS_CROSSPOST);
2026-07-20 16:05:17 +00:00
}
obj4 = set;
2026-07-20 16:05:17 +00:00
}
}
}
}
}
});
}
}
const FetchState = fn(11559).FetchState;
const MessageFlags = fn(1074).MessageFlags;
const set = new Set();
2026-07-29 08:29:29 +00:00
class MediaPostEmbedManager extends tmp7 {
constructor() {
tmp3 = new MediaPostEmbedManager(tmp2, tmp);
tmp3.actions = { LOAD_THREADS_SUCCESS: tmp3.handleLoadThreadsSuccess, LOAD_ARCHIVED_THREADS_SUCCESS: tmp3.handleLoadThreadsSuccess, LOAD_FORUM_POSTS: tmp3.handleLoadForumPosts };
obj = {
onBeforeBatch() {
return set.clear();
2026-07-29 08:29:29 +00:00
}
};
tmp4 = closure_1(closure_2[10])(tmp3, resolveMediaPostEmbeds, obj);
2026-07-29 08:29:29 +00:00
return tmp3;
}
}
const prototype = MediaPostEmbedManager.prototype;
prototype["handleLoadThreadsSuccess"] = function handleLoadThreadsSuccess(firstMessages) {
firstMessages = firstMessages.firstMessages;
if (null == firstMessages) {
return false;
} else {
set.clear();
if (firstMessages != null) {
let item = firstMessages.forEach((embeds) => {
2026-08-24 06:08:38 +00:00
closure_0 = embeds;
2026-07-29 08:29:29 +00:00
embeds = embeds.embeds;
let found;
if (embeds != null) {
found = embeds.filter((type) => type.type === first_message(closure_1_2[5]).MessageEmbedTypes.POST_PREVIEW);
2026-07-29 08:29:29 +00:00
}
let tmp2 = null != found;
if (tmp2) {
tmp2 = 0 !== found.length;
}
if (tmp2) {
const item = found.forEach((url) => {
if (null != url.url) {
const mediaPostEmbedChannelPath = MediaPostEmbedUtils.getMediaPostEmbedChannelPath(url.url);
2026-07-29 08:29:29 +00:00
if (null != mediaPostEmbedChannelPath) {
let threadId;
if (mediaPostEmbedChannelPath != null) {
threadId = mediaPostEmbedChannelPath.threadId;
}
if (null != threadId) {
let channelId;
if (mediaPostEmbedChannelPath != null) {
channelId = mediaPostEmbedChannelPath.channelId;
}
if (null != channelId) {
if (embedFetchState.getEmbedFetchState(mediaPostEmbedChannelPath.threadId) === constants.NOT_FETCHED) {
if (!set.has(mediaPostEmbedChannelPath.threadId)) {
2026-07-29 08:29:29 +00:00
obj4.add(mediaPostEmbedChannelPath.threadId);
let guildId;
id = id.getId();
2026-07-29 08:29:29 +00:00
if (mediaPostEmbedChannelPath != null) {
guildId = mediaPostEmbedChannelPath.guildId;
}
const isMemberResult = member.isMember(guildId, id);
const isChannelGatedResult = channelGated.isChannelGated(mediaPostEmbedChannelPath.guildId, mediaPostEmbedChannelPath.channelId);
2026-07-29 08:29:29 +00:00
let num = first_message.flags;
if (num == null) {
num = 0;
}
let tmp14 = isMemberResult;
const tmp17Result = tmp17(tmp18[7]);
2026-07-29 08:29:29 +00:00
if (isMemberResult) {
tmp14 = false === isChannelGatedResult;
}
if (!tmp14) {
let tmp15 = !isMemberResult;
if (!isMemberResult) {
tmp15 = hasFlagResult;
}
tmp14 = tmp15;
}
if (!tmp14) {
const mediaPostEmbed = tmp17(tmp18[8]).fetchMediaPostEmbed(mediaPostEmbedChannelPath.threadId);
const tmp17Result2 = tmp17(tmp18[8]);
2026-07-29 08:29:29 +00:00
}
hasFlagResult = tmp17(tmp18[7]).hasFlag(num, constants2.IS_CROSSPOST);
2026-07-29 08:29:29 +00:00
}
obj4 = set;
2026-07-29 08:29:29 +00:00
}
}
}
}
}
});
}
});
}
}
};
function handleLoadForumPosts(threads) {
2026-07-29 08:29:29 +00:00
set.clear();
const values = Object.values(threads.threads);
const mapped = values.map((first_message) => {
first_message = first_message.first_message;
if (null != first_message) {
const embeds = first_message.embeds;
let found;
if (embeds != null) {
found = embeds.filter((type) => type.type === first_message(closure_1_2[5]).MessageEmbedTypes.POST_PREVIEW);
2026-07-29 08:29:29 +00:00
}
let tmp3 = null != found;
if (tmp3) {
tmp3 = 0 !== found.length;
}
if (tmp3) {
const item = found.forEach((url) => {
if (null != url.url) {
const mediaPostEmbedChannelPath = MediaPostEmbedUtils.getMediaPostEmbedChannelPath(url.url);
2026-07-29 08:29:29 +00:00
if (null != mediaPostEmbedChannelPath) {
let threadId;
if (mediaPostEmbedChannelPath != null) {
threadId = mediaPostEmbedChannelPath.threadId;
}
if (null != threadId) {
let channelId;
if (mediaPostEmbedChannelPath != null) {
channelId = mediaPostEmbedChannelPath.channelId;
}
if (null != channelId) {
if (embedFetchState.getEmbedFetchState(mediaPostEmbedChannelPath.threadId) === constants.NOT_FETCHED) {
if (!set.has(mediaPostEmbedChannelPath.threadId)) {
2026-07-29 08:29:29 +00:00
obj4.add(mediaPostEmbedChannelPath.threadId);
let guildId;
id = id.getId();
2026-07-29 08:29:29 +00:00
if (mediaPostEmbedChannelPath != null) {
guildId = mediaPostEmbedChannelPath.guildId;
}
const isMemberResult = member.isMember(guildId, id);
const isChannelGatedResult = channelGated.isChannelGated(mediaPostEmbedChannelPath.guildId, mediaPostEmbedChannelPath.channelId);
2026-07-29 08:29:29 +00:00
let num = first_message.flags;
if (num == null) {
num = 0;
}
let tmp14 = isMemberResult;
const tmp17Result = tmp17(tmp18[7]);
2026-07-29 08:29:29 +00:00
if (isMemberResult) {
tmp14 = false === isChannelGatedResult;
}
if (!tmp14) {
let tmp15 = !isMemberResult;
if (!isMemberResult) {
tmp15 = hasFlagResult;
}
tmp14 = tmp15;
}
if (!tmp14) {
const mediaPostEmbed = tmp17(tmp18[8]).fetchMediaPostEmbed(mediaPostEmbedChannelPath.threadId);
const tmp17Result2 = tmp17(tmp18[8]);
2026-07-29 08:29:29 +00:00
}
hasFlagResult = tmp17(tmp18[7]).hasFlag(num, constants2.IS_CROSSPOST);
2026-07-29 08:29:29 +00:00
}
obj4 = set;
2026-07-29 08:29:29 +00:00
}
}
}
}
}
});
}
}
return null != first_message;
});
}
prototype["handleLoadForumPosts"] = handleLoadForumPosts;
const handleLoadForumPosts1 = new handleLoadForumPosts(tmp4, tmp3, tmp2, Object, prototype, MediaPostEmbedManager, tmp, resolveMediaPostEmbeds);
handleLoadForumPosts1.actions = { LOAD_THREADS_SUCCESS: handleLoadForumPosts1.handleLoadThreadsSuccess, LOAD_ARCHIVED_THREADS_SUCCESS: handleLoadForumPosts1.handleLoadThreadsSuccess, LOAD_FORUM_POSTS: handleLoadForumPosts1.handleLoadForumPosts };
setupLoadFromMessageManagerHandlersDefault(handleLoadForumPosts1, resolveMediaPostEmbeds, {
2026-07-29 08:29:29 +00:00
onBeforeBatch() {
return set.clear();
2026-07-29 08:29:29 +00:00
}
});
const size = fn(2);
const result = size.fileFinishedImporting("modules/media_channel/MediaPostEmbedManager.tsx");
2026-07-20 16:05:17 +00:00
export default handleLoadForumPosts1;