decord/source/modules/gateway/EntityVersionsManager.tsx

207 lines
8.5 KiB
TypeScript
Raw Normal View History

// Module ID: 17461
// Function ID: 17462
// Name: EntityVersionsManager
// Dependencies: [5540, 5583, 1957, 2015, 1979, 5358, 3, 7221, 573, 504, 7753, 1239, 11, 2]
2026-07-23 10:11:24 +00:00
// Module 17461 (EntityVersionsManager)
import LoggerDefault from "Logger" /* 3 */;
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import GuildsRequiringDeletedIdsSyncDefault from "GuildsRequiringDeletedIdsSync" /* 7753 */;
import EmojiStore from "EmojiStore" /* 5540 */;
import StickersStore from "StickersStore" /* 5583 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import GuildRoleStore from "GuildRoleStore" /* 2015 */;
import GuildStore from "GuildStore" /* 1979 */;
import GatewayConnectionStore from "GatewayConnectionStore" /* 5358 */;
import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 7221 */;
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
function handleDeletedEntityIds(guild_id) {
2026-08-24 06:08:38 +00:00
importDefault = guild_id;
const guild = GuildStore.getGuild(guild_id.guild_id);
2026-07-20 16:05:17 +00:00
let name;
2026-07-29 08:29:29 +00:00
if (guild != null) {
2026-07-20 16:05:17 +00:00
name = guild.name;
}
2026-08-24 06:08:38 +00:00
closure_8.fileOnly("received deleted guild entities (id: " + guild_id.guild_id + ", name: " + name + ")");
const Emitter = initializeDefault.Emitter;
2026-07-23 10:11:24 +00:00
Emitter.batched(() => {
if (null != guild_id.channels) {
2026-07-29 08:29:29 +00:00
const guild_id2 = tmp.guild_id;
2026-07-20 16:05:17 +00:00
const _Set2 = Set;
2026-07-29 08:29:29 +00:00
const set = new Set(tmp.channels);
let set3 = guild_id2;
2026-07-29 08:29:29 +00:00
let set1 = set;
const keys = SnowflakeUtilsDefault.keys(ChannelStore.getMutableBasicGuildChannelsForGuild(guild_id2));
let obj3 = { channelIdsInMemory: keys, channelIdsFromServer: set };
closure_8.fileOnly("syncChannels", obj3);
const item = keys.forEach((id) => {
if (!set1.has(id)) {
const obj2 = { type: "CHANNEL_DELETE", channel: null };
const obj3 = { guild_id: set3, id, parent_id: "Array" };
obj2.channel = obj3;
set3(573).dispatch(obj2);
const obj = set3(573);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
});
2026-07-20 16:05:17 +00:00
}
if (null != guild_id.roles) {
2026-07-29 08:29:29 +00:00
guild_id = tmp.guild_id;
const _Set = Set;
set1 = new Set(tmp.roles);
set3 = guild_id;
const keys1 = SnowflakeUtilsDefault.keys(GuildRoleStore.getUnsafeMutableRoles(guild_id));
const item1 = keys1.forEach((roleId) => {
if (!set1.has(roleId)) {
const obj2 = { type: "GUILD_ROLE_DELETE", guildId: set3, roleId };
set3(573).dispatch(obj2);
const obj = set3(573);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
});
}
if (null != guild_id.emojis) {
2026-07-29 08:29:29 +00:00
const guild_id3 = tmp.guild_id;
const _Set3 = Set;
const set2 = new Set(tmp.emojis);
set3 = set2;
const guildEmoji = EmojiStore.getGuildEmoji(guild_id3);
2026-07-29 08:29:29 +00:00
const found = guildEmoji.filter((id) => set3.has(id.id));
if (guildEmoji.length !== found.length) {
const obj5 = { type: "GUILD_EMOJIS_UPDATE", guildId: guild_id3, emojis: found };
DispatcherDefault.dispatch(obj5);
2026-07-29 08:29:29 +00:00
}
}
if (null != guild_id.stickers) {
2026-07-29 08:29:29 +00:00
const guild_id4 = tmp.guild_id;
const _Set4 = Set;
set3 = new Set(tmp.stickers);
let stickersByGuildId = StickersStore.getStickersByGuildId(guild_id4);
2026-07-29 08:29:29 +00:00
if (stickersByGuildId == null) {
stickersByGuildId = [];
}
const found1 = stickersByGuildId.filter((id) => set3.has(id.id));
if (stickersByGuildId.length !== found1.length) {
const obj7 = { type: "GUILD_STICKERS_UPDATE", guildId: guild_id4, stickers: found1 };
DispatcherDefault.dispatch(obj7);
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
}
});
}
function handleConnectionOpen() {
const all = GuildsRequiringDeletedIdsSyncDefault.getAll();
2026-07-20 16:05:17 +00:00
all.then((arr) => {
const item = arr.forEach((item) => {
closure_0 = item;
2026-07-29 08:29:29 +00:00
const timerId = setTimeout(() => {
guild = guild.getGuild(closure_0);
2026-07-29 08:29:29 +00:00
let name;
if (guild != null) {
name = guild.name;
}
closure_2_8.fileOnly("requesting deleted guild entities (id: " + closure_0 + ", name: " + name + ")");
const keys = Object.keys(mutableBasicGuildChannelsForGuild.getMutableBasicGuildChannelsForGuild(tmp));
2026-07-29 08:29:29 +00:00
const sorted = keys.sort();
const obj2 = closure_2_0(1239);
const tmp5 = closure_2_0;
const str = closure_2_0(1239).v3(sorted.join(","));
sortedRoles = sortedRoles.getSortedRoles(tmp);
2026-07-29 08:29:29 +00:00
const mapped = sortedRoles.map((id) => id.id);
const str1 = closure_2_0(1239).v3(sorted.join(",")).toString();
2026-07-29 08:29:29 +00:00
const sorted1 = mapped.sort();
const obj5 = closure_2_0(1239);
const str2 = closure_2_0(1239).v3(sorted1.join(","));
guildEmoji = guildEmoji.getGuildEmoji(tmp);
2026-07-29 08:29:29 +00:00
const mapped1 = guildEmoji.map((id) => id.id);
const str5 = closure_2_0(1239).v3(sorted1.join(",")).toString();
2026-07-29 08:29:29 +00:00
const sorted2 = mapped1.sort();
const obj8 = closure_2_0(1239);
const str3 = closure_2_0(1239).v3(sorted2.join(","));
stickersByGuildId = stickersByGuildId.getStickersByGuildId(tmp);
2026-07-29 08:29:29 +00:00
let mapped2;
if (stickersByGuildId != null) {
mapped2 = stickersByGuildId.map((id) => id.id);
}
if (mapped2 == null) {
mapped2 = [];
}
const str6 = closure_2_0(1239).v3(sorted2.join(",")).toString();
2026-07-29 08:29:29 +00:00
const sorted3 = mapped2.sort();
const tmp5Result = tmp5(1239);
const str4 = tmp5(1239).v3(sorted3.join(","));
socket = socket.getSocket();
const deletedEntityIdsNotMatchingHash = socket.getDeletedEntityIdsNotMatchingHash(tmp, str1, str5, str6, tmp5(1239).v3(sorted3.join(",")).toString());
2026-07-29 08:29:29 +00:00
}, Math.ceil(2000 * Math.random()));
2026-07-20 16:05:17 +00:00
});
});
}
function handleGuildCreate(guild) {
guild = guild.guild;
if (guild.unableToSyncDeletes) {
2026-07-29 08:29:29 +00:00
const id = guild.id;
const _Math = Math;
const _Math2 = Math;
const _setTimeout = setTimeout;
const timerId = setTimeout(() => {
guild = guild.getGuild(closure_0);
2026-07-20 16:05:17 +00:00
let name;
2026-07-29 08:29:29 +00:00
if (guild != null) {
2026-07-20 16:05:17 +00:00
name = guild.name;
}
closure_2_8.fileOnly("requesting deleted guild entities (id: " + closure_0 + ", name: " + name + ")");
const keys = Object.keys(mutableBasicGuildChannelsForGuild.getMutableBasicGuildChannelsForGuild(tmp));
2026-07-29 08:29:29 +00:00
const sorted = keys.sort();
const obj2 = closure_2_0(1239);
const tmp5 = closure_2_0;
const str = closure_2_0(1239).v3(sorted.join(","));
sortedRoles = sortedRoles.getSortedRoles(tmp);
2026-07-29 08:29:29 +00:00
const mapped = sortedRoles.map((id) => id.id);
const str1 = closure_2_0(1239).v3(sorted.join(",")).toString();
2026-07-29 08:29:29 +00:00
const sorted1 = mapped.sort();
const obj5 = closure_2_0(1239);
const str2 = closure_2_0(1239).v3(sorted1.join(","));
guildEmoji = guildEmoji.getGuildEmoji(tmp);
2026-07-29 08:29:29 +00:00
const mapped1 = guildEmoji.map((id) => id.id);
const str5 = closure_2_0(1239).v3(sorted1.join(",")).toString();
2026-07-29 08:29:29 +00:00
const sorted2 = mapped1.sort();
const obj8 = closure_2_0(1239);
const str3 = closure_2_0(1239).v3(sorted2.join(","));
stickersByGuildId = stickersByGuildId.getStickersByGuildId(tmp);
2026-07-29 08:29:29 +00:00
let mapped2;
if (stickersByGuildId != null) {
mapped2 = stickersByGuildId.map((id) => id.id);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (mapped2 == null) {
mapped2 = [];
2026-07-20 16:05:17 +00:00
}
const str6 = closure_2_0(1239).v3(sorted2.join(",")).toString();
2026-07-29 08:29:29 +00:00
const sorted3 = mapped2.sort();
const tmp5Result = tmp5(1239);
const str4 = tmp5(1239).v3(sorted3.join(","));
socket = socket.getSocket();
const deletedEntityIdsNotMatchingHash = socket.getDeletedEntityIdsNotMatchingHash(tmp, str1, str5, str6, tmp5(1239).v3(sorted3.join(",")).toString());
2026-07-29 08:29:29 +00:00
}, Math.ceil(2000 * Math.random()));
}
2026-07-20 16:05:17 +00:00
}
let closure_8 = new LoggerDefault("EntityVersionsManager");
2026-07-29 08:29:29 +00:00
class EntityVersionsManager extends tmp3 {
constructor() {
applyArgumentsResult = HermesBuiltin.applyArguments(new.target, new.target);
obj = { GUILD_CREATE: handleGuildCreate, DELETED_ENTITY_IDS: handleDeletedEntityIds };
applyArgumentsResult.actions = obj;
return applyArgumentsResult;
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = EntityVersionsManager.prototype;
prototype["_initialize"] = function _initialize() {
const subscription = DispatcherDefault.subscribe("CONNECTION_OPEN", handleConnectionOpen);
2026-07-29 08:29:29 +00:00
};
prototype["_terminate"] = function _terminate() {
DispatcherDefault.unsubscribe("CONNECTION_OPEN", handleConnectionOpen);
2026-07-29 08:29:29 +00:00
};
const entityVersionsManager = new EntityVersionsManager();
const size = fn(2);
const result = size.fileFinishedImporting("modules/gateway/EntityVersionsManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default entityVersionsManager;