// Module ID: 5008 // Function ID: 5009 // Name: MessageStore // Dependencies: [32, 5, 2098, 5009, 2109, 502, 2041, 5520, 2096, 2105, 2063, 4427, 4437, 2095, 4609, 1372, 1074, 3, 11, 5521, 5526, 2070, 5524, 5010, 1385, 12, 7874, 5020, 4439, 8108, 14060, 504, 12028, 1978, 573, 2] // Module 5008 (MessageStore) import LoggerDefault from "Logger" /* 3 */; import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */; import _modDef12 from "module_12" /* 12 */; import initializeDefault from "initialize" /* 504 */; import DispatcherDefault from "Dispatcher" /* 573 */; import FlagUtils from "FlagUtils" /* 1385 */; import Server from "Server" /* 1978 */; import DatabaseDaosDefault from "DatabaseDaos" /* 2070 */; import ReactionUtils from "ReactionUtils" /* 4439 */; import MessageRecordUtils from "MessageRecordUtils" /* 5010 */; import ChannelMessagesDefault from "ChannelMessages" /* 5521 */; import GatewayConnectionStore from "GatewayConnectionStore" /* 5526 */; import ExplicitMediaRedactionUtils from "ExplicitMediaRedactionUtils" /* 7874 */; import MessageQueue from "MessageQueue" /* 8108 */; import canEditMessageDefault from "canEditMessage" /* 12028 */; import GuildAutomodMessageStoreUtils from "GuildAutomodMessageStoreUtils" /* 14060 */; import _slicedToArray from "module_32" /* 32 */; import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */; import ImpersonateStore from "ImpersonateStore" /* 2098 */; import EphemeralMessageStore from "EphemeralMessageStore" /* 5009 */; import LocaleStore from "LocaleStore" /* 2109 */; import AuthenticationStore from "AuthenticationStore" /* 502 */; import ChannelStore from "ChannelStore" /* 2041 */; import DimensionStore from "DimensionStore" /* 5520 */; import GuildChannelStore from "GuildChannelStore" /* 2096 */; import GuildMemberStore from "GuildMemberStore" /* 2105 */; import GuildStore from "GuildStore" /* 2063 */; import PermissionStore from "PermissionStore" /* 4427 */; import RelationshipStore from "RelationshipStore" /* 4437 */; import SelectedChannelStore from "SelectedChannelStore" /* 2095 */; import SelectedGuildStore from "SelectedGuildStore" /* 4609 */; import UserStore from "UserStore" /* 1372 */; const IOSPushNotificationRawPayloadFixExperiment = tmp3(5524); require = fn; function reinjectEphemerals(channelId, truncateResult) { closure_0 = truncateResult; if (truncateResult.hasMoreAfter) { return truncateResult; } else { const messages = EphemeralMessageStore.getMessages(channelId); if (0 === messages.length) { return truncateResult; } else { let firstResult = null; if (truncateResult.hasMoreBefore) { firstResult = truncateResult.first(); } importDefault = firstResult; const found = messages.filter((id) => { const hasItem = truncateResult.has(id.id); let tmp2 = !hasItem; if (!hasItem) { let tmp5 = null == firstResult; if (!tmp5) { tmp5 = SnowflakeUtilsDefault.compare(id.id, tmp3.id) > 0; } tmp2 = tmp5; } return tmp2; }); let mutation = truncateResult; if (0 !== found.length) { mutation = truncateResult.mutate((_merge) => { _merge._merge(found); const _array = _merge._array; const sorted = _array.sort((id, id2) => closure_1_1(found[18]).compare(id.id, id2.id)); }, true); } return mutation; } } } function handleConnectionOpen() { const item = ChannelMessagesDefault.forEach((mutate) => { ChannelMessagesDefault.commit(mutate.mutate({ ready: false, loadingMore: false })); }); set.clear(); map.clear(); } let closure_31 = async function _addPushNotificationMessageIfNotCached(arg0, value) { if (c7 === 2) { c7 = 3; throw new TypeError("Generator functions may not be called on executing generators"); } else if (tmp6 === 3) { if (arg0 === 1) { throw value; } else if (arg0 === 2) { const obj5 = { value, done: true }; return obj5; } else { return { value: "HermesInternal", done: null }; } } else { try { c7 = 2; if (0 === c6) { if (arg0 === 1) { c7 = 3; throw value; } else if (arg0 === 2) { c7 = 3; const obj6 = { value, done: true }; return obj6; } else { closure_4 = tmp3; closure_3 = tmp28; closure_131_0 = closure_0; closure_131_1 = closure_1; closure_131_2 = closure_2; let orCreate; const databaseResult = DatabaseDaosDefault.database(); basicChannel = basicChannel.getBasicChannel(closure_0); if (null != databaseResult) { if (null != basicChannel) { c5 = 1; c6 = 2; c7 = 1; const obj7 = { value: DatabaseDaosDefault.messages(databaseResult).get(basicChannel.guild_id, tmp34, tmp35.id), done: false }; return obj7; } } tmp34 = closure_0; tmp35 = closure_1; } } else { if (1 === tmp7) { c5 = 0; } else if (arg0 === 1) { c7 = 3; throw value; } else if (arg0 === 2) { c5 = 0; c7 = 3; const obj = { value, done: true }; return obj; } else if (null == value) { c5 = 0; } c5 = 0; c7 = 3; return { value: "HermesInternal", done: null }; } closure_132_28.log("Push notification message not in cache, adding directly", closure_131_1.id, closure_131_1.channel_id); orCreate = closure_132_1(closure_132_2[19]).getOrCreate(closure_131_0); const obj2 = closure_132_1(closure_132_2[19]); closure_132_1(closure_132_2[19]).commit(orCreate.receivePushNotification(closure_131_1, closure_131_2)); closure_132_35.emitChange(); c7 = 3; const obj3 = closure_132_1(closure_132_2[19]); } catch (tmp27) { if (tmp4 === c5) { c7 = tmp2; throw tmp27; } else { c6 = tmp; } tmp28 = c5; } } }; function receiveMediaMentionMessage(item10038) { const media_mention = item10038.media_mention; let message_id; if (media_mention != null) { message_id = media_mention.message_id; } if (null != message_id) { const attachment_id = item10038.media_mention.attachment_id; const orCreate = ChannelMessagesDefault.getOrCreate(attachment_id); const obj = {}; const merged = Object.assign(item10038); obj.channel_id = attachment_id; obj.type = constants6.MEDIA_MENTION_MESSAGE; obj.id = item10038.media_mention.message_id; const obj2 = { channel_id: item10038.channel_id, message_id: item10038.media_mention.message_id, type: constants4.DEFAULT, guild_id: null }; const channel = ChannelStore.getChannel(item10038.channel_id); let guild_id; if (channel != null) { guild_id = channel.guild_id; } obj2.guild_id = guild_id; obj.message_reference = obj2; const tmp5 = importDefault; const mutation = orCreate.receiveMessage(obj, false).mutate({ ready: true }); const receiveMessageResult = orCreate.receiveMessage(obj, false); tmp5(5521).commit(mutation); const tmp5Result = tmp5(5521); } } function invalidateInaccessibleMessages(arg0) { closure_0 = arg0; importDefault = false; const item = ChannelMessagesDefault.forEach((cached) => { if (!cached.cached) { const basicChannel = ChannelStore.getBasicChannel(cached.channelId); let guild_id; if (basicChannel != null) { guild_id = basicChannel.guild_id; } if (guild_id === guildId) { if (!PermissionStore.canBasicChannel(constants.VIEW_CHANNEL, basicChannel)) { ChannelMessagesDefault.commit(cached.mutate({ cached: true })); c1 = true; } } } }); return importDefault; } function handleRoleUpdate(guildId) { guildId = guildId.guildId; importDefault = false; const item = ChannelMessagesDefault.forEach((cached) => { if (!cached.cached) { const basicChannel = ChannelStore.getBasicChannel(cached.channelId); let guild_id; if (basicChannel != null) { guild_id = basicChannel.guild_id; } if (guild_id === guildId) { if (!PermissionStore.canBasicChannel(constants.VIEW_CHANNEL, basicChannel)) { ChannelMessagesDefault.commit(cached.mutate({ cached: true })); c1 = true; } } } }); return importDefault; } function handleCleanup() { const item = ChannelMessagesDefault.forEach((channelId) => { channelId = channelId.channelId; if (null == channel.getChannel(channelId)) { ChannelMessagesDefault.clear(channelId); } }); } function handleRelationshipUpdate() { c0 = false; const item = ChannelMessagesDefault.forEach((reset) => { ChannelMessagesDefault.commit(reset.reset(reset.map((blocked) => { let result = blocked; if (blocked.blocked !== blockedForMessage.isBlockedForMessage(blocked)) { c0 = true; result = blocked.set("blocked", obj.isBlockedForMessage(blocked)); } let result1 = result; if (result.ignored !== blockedForMessage.isIgnoredForMessage(result)) { c0 = true; result1 = result.set("ignored", obj.isIgnoredForMessage(result)); } return result1; }))); }); return c0; } function performAuthorUpdate(guildId) { closure_0 = guildId; const item = ChannelMessagesDefault.forEach((channelId) => { const channel = ChannelStore.getChannel(channelId.channelId); let guild_id; if (channel != null) { guild_id = channel.guild_id; } if (guild_id === guildId) { const items = []; c1 = false; const item = channelId.forEach((nick) => { const messageAuthor = guildId(dependencyMap[27]).getMessageAuthor(nick); ({ nick, colorString } = messageAuthor); if (nick === nick.nick) { if (colorString === nick.colorString) { items.push(nick); } } c1 = true; items.push(nick.merge({ nick, colorString })); }); if (c1) { ChannelMessagesDefault.commit(channelId.reset(items)); } } }); } function handleReaction(optimistic) { ({ type: importDefault, channelId, emoji: dependencyMap, reactionType: _slicedToArray } = optimistic); ({ messageId, userId } = optimistic); value = ChannelMessagesDefault.get(channelId); if (null == value) { return false; } else { if (obj4.shouldApplyReaction(optimistic)) { const basicChannel = ChannelStore.getBasicChannel(channelId); let type; if (basicChannel != null) { type = basicChannel.type; } const isDMChannel = type === constants2.DM; closure_5 = AuthenticationStore.getId() === userId; const updateResult = value.update(messageId, (addReaction) => { if ("MESSAGE_REACTION_ADD" === importDefault) { const obj = { colors: optimistic.colors, reactionType, isDMChannel }; let addReactionResult = addReaction.addReaction(dependencyMap, closure_5, obj); } else { addReactionResult = addReaction.removeReaction(dependencyMap, closure_5, reactionType); } return addReactionResult; }); ChannelMessagesDefault.commit(updateResult); } else { return false; } obj4 = ReactionUtils; } } function handleMessageSendFailedAutomod(arg0) { ({ type: require, messageData } = arg0); const failedMessageId = MessageQueue.getFailedMessageId(messageData); const orCreate = ChannelMessagesDefault.getOrCreate(messageData.message.channelId); if (orCreate.has(failedMessageId)) { const updateResult = orCreate.update(failedMessageId, (embeds) => { embeds = embeds.embeds; let length; if (embeds != null) { length = embeds.filter(GuildAutomodMessageStoreUtils.isNotAutomodEmbed).length; } let result = embeds; if (length > 0) { result = embeds.set("embeds", []); } let result1 = result; if ("MESSAGE_SEND_FAILED_AUTOMOD" === closure_1_0) { result1 = result.set("flags", FlagUtils.addFlag(result.flags, constants3.EPHEMERAL)); } return result1; }); ChannelMessagesDefault.commit(updateResult); } else { return false; } } const Constants = fn(1074); ({ BasicPermissions: closure_19, ChannelTypes: closure_20, MessageFlags: closure_21, MessageReferenceTypes: closure_22, MessageStates: closure_23, MessageTypes: closure_24, Permissions: closure_25 } = Constants); const set = new Set(); const map = new Map(); const logger = new LoggerDefault("MessageStore"); let c29 = false; const Store = initializeDefault.Store; class MessageStore extends Store { } const prototype = MessageStore.prototype; prototype["initialize"] = function initialize() { this.waitFor(AuthenticationStore, ChannelStore, DimensionStore, EphemeralMessageStore, GuildChannelStore, GuildMemberStore, GuildStore, ImpersonateStore, LocaleStore, PermissionStore, RelationshipStore, SelectedChannelStore, SelectedGuildStore, UserStore); const items = [ImpersonateStore]; this.syncWith(items, () => { }); }; prototype["getMessages"] = function getMessages(arg0) { if (ImpersonateStore.hasViewingRoles()) { const channel = ChannelStore.getChannel(arg0); let guildId; if (channel != null) { guildId = channel.getGuildId(); } if (ImpersonateStore.isViewingRoles(guildId)) { if (!PermissionStore.can(constants7.VIEW_CHANNEL, channel)) { const tmp11 = new ChannelMessagesDefault(arg0); return tmp11; } } } return ChannelMessagesDefault.getOrCreate(arg0); }; prototype["getMessage"] = function getMessage(arg0, arg1) { const orCreate = ChannelMessagesDefault.getOrCreate(arg0); return orCreate.get(arg1); }; prototype["getAutomodRemovalNotice"] = function getAutomodRemovalNotice(id) { return map.get(id); }; prototype["getLastEditableMessage"] = function getLastEditableMessage(id) { id = UserStore.getCurrentUser(); const messages = this.getMessages(id); const reversed = _modDef12(messages.toArray()).reverse(); return reversed.find((item) => { id = undefined; if (id != null) { id = id.id; } return canEditMessageDefault(item, id); }); }; prototype["getLastChatCommandMessage"] = function getLastChatCommandMessage(arg0) { let id = UserStore.getCurrentUser(); const messages = this.getMessages(arg0); const reversed = messages.toArray().reverse(); return reversed.find((interaction) => { interaction = interaction.interaction; let type; if (interaction != null) { type = interaction.type; } let tmp4 = type === Server.InteractionTypes.APPLICATION_COMMAND; if (tmp4) { const interactionData = interaction.interactionData; let type1; if (interactionData != null) { type1 = interactionData.type; } tmp4 = type1 === Server.ApplicationCommandType.CHAT; } if (tmp4) { id = undefined; if (id != null) { id = id.id; } tmp4 = interaction.interaction.user.id === id; } return tmp4; }); }; prototype["getLastMessage"] = function getLastMessage(channelId) { const messages = this.getMessages(channelId); const reversed = _modDef12(messages.toArray()).reverse(); return reversed.get(0); }; prototype["getLastNonCurrentUserMessage"] = function getLastNonCurrentUserMessage(arg0) { let id = UserStore.getCurrentUser(); const messages = this.getMessages(arg0); const reversed = _modDef12(messages.toArray()).reverse(); return reversed.find((author) => { id = undefined; if (id != null) { id = id.id; } return author.author.id !== id; }); }; prototype["jumpedMessageId"] = function jumpedMessageId(arg0) { value = ChannelMessagesDefault.get(arg0); let jumpTargetId; if (value != null) { jumpTargetId = value.jumpTargetId; } return jumpTargetId; }; prototype["focusedMessageId"] = function focusedMessageId(arg0) { value = ChannelMessagesDefault.get(arg0); let focusTargetId; if (value != null) { focusTargetId = value.focusTargetId; } return focusTargetId; }; prototype["hasPresent"] = function hasPresent(arg0) { value = ChannelMessagesDefault.get(arg0); return null != value && value.ready && value.hasPresent(); }; prototype["isReady"] = function isReady(arg0) { return ChannelMessagesDefault.getOrCreate(arg0).ready; }; prototype["whenReady"] = function whenReady(arg0, arg1) { const self = this; closure_1 = arg0; closure_0 = arg1; const result = this.addConditionalChangeListener(() => { if (self.isReady(closure_1)) { const _setImmediate = setImmediate; setImmediate(closure_0); return false; } }); }; prototype["isLoadingMessages"] = function isLoadingMessages(channelId) { return ChannelMessagesDefault.getOrCreate(channelId).loadingMore; }; prototype["hasCurrentUserSentMessage"] = function hasCurrentUserSentMessage(arg0) { let id = UserStore.getCurrentUser(); const messages = this.getMessages(arg0); return null != messages.findNewest((author) => { id = undefined; if (id != null) { id = id.id; } return author.author.id === id; }); }; prototype["hasCurrentUserSentWaveBlockingMessage"] = function hasCurrentUserSentWaveBlockingMessage(id) { id = UserStore.getCurrentUser(); const messages = this.getMessages(id); return null != messages.findNewest((type) => { let tmp = type.type !== constants6.FRIEND_REQUEST_ACCEPTED; if (tmp) { id = undefined; if (id != null) { id = id.id; } tmp = type.author.id === id; } return tmp; }); }; prototype["hasCurrentUserSentMessageSinceAppStart"] = function hasCurrentUserSentMessageSinceAppStart() { return c29; }; MessageStore.displayName = "MessageStore"; const messageStore = new MessageStore(DispatcherDefault, { BACKGROUND_SYNC_CHANNEL_MESSAGES: function handleBackgroundSyncChannelMessages(changesByChannelId) { changesByChannelId = changesByChannelId.changesByChannelId; for (const key10012 in changesByChannelId) { let tmp8 = key10012; let obj = ChannelMessagesDefault; value = obj.get(key10012); if (null == value) { continue; } else { let _default = GatewayConnectionStore.default; let isConnectedResult = _default.isConnected(); if (!value.cached) { if (isConnectedResult) { let _HermesInternal = HermesInternal; let str = "Skipping background message sync for "; let str2 = " cached:"; let str3 = " ready:"; let str4 = " hasMoreAfter:"; let str5 = " isConnected:"; let logResult = logger.log("Skipping background message sync for " + tmp8 + " cached:" + value.cached + " ready:" + value.ready + " hasMoreAfter:" + value.hasMoreAfter + " isConnected:" + isConnectedResult); continue; } continue; } let mergeDeltaResult = value.mergeDelta(changesByChannelId[key10012].new_messages, changesByChannelId[key10012].modified_messages, changesByChannelId[key10012].deleted_message_ids); continue; } continue; } }, CONNECTION_OPEN: handleConnectionOpen, OVERLAY_INITIALIZE: handleConnectionOpen, CACHE_LOADED: function handleCacheLoaded(messages) { const entries = SnowflakeUtilsDefault.entries(messages.messages); while (tmp2 !== undefined) { let tmp5 = _slicedToArray(tmp3, 2); [tmp6, tmp7] = tmp5; let obj2 = ChannelMessagesDefault; let orCreate = obj2.getOrCreate(tmp6); let addCachedMessagesResult = orCreate.addCachedMessages(tmp7, true); let obj4 = ChannelMessagesDefault; let commitResult = obj4.commit(addCachedMessagesResult); continue; } }, LOAD_MESSAGES: function handleLoadMessages() { return true; }, LOAD_MESSAGES_SUCCESS: function handleLoadMessagesSuccess(arg0) { ({ channelId, isBefore, isAfter, messages } = arg0); ({ jump, hasMoreBefore, hasMoreAfter, isStale, truncate, avoidInitialScroll, requestStartTime } = arg0); const orCreate = ChannelMessagesDefault.getOrCreate(channelId); const complete = orCreate.loadComplete({ newMessages: messages, isBefore, isAfter, jump, hasMoreBefore, hasMoreAfter, cached: isStale, hasFetched: true, avoidInitialScroll, requestStartTime }); let tmp3 = null == truncate; if (!tmp3) { let tmp4 = !isBefore; if (!isBefore) { tmp4 = !isAfter; } tmp3 = tmp4; } if (!tmp3) { let tmp5 = isBefore; if (isBefore) { tmp5 = isAfter; } tmp3 = tmp5; } let truncateResult = complete; if (!tmp3) { truncateResult = complete.truncate(isBefore, isAfter); } const tmp7 = reinjectEphemerals(channelId, truncateResult); ChannelMessagesDefault.commit(tmp7); for (const item10038 of messages) { let tmp10 = receiveMediaMentionMessage(item10038); continue; } }, LOAD_MESSAGES_FAILURE: function handleLoadMessagesFailure(channelId) { const orCreate = ChannelMessagesDefault.getOrCreate(channelId.channelId); ChannelMessagesDefault.commit(orCreate.mutate({ loadingMore: false, error: true })); }, LOAD_MESSAGES_SUCCESS_CACHED: function handleLoadMessagesSuccessCached(truncate) { ({ channelId, jump, focus, before, after, limit } = truncate); const orCreate = require("ChannelMessages").getOrCreate(channelId); let present; if (jump != null) { present = jump.present; } if (present) { let jumpToPresentResult = orCreate.jumpToPresent(limit); } else { let messageId; if (focus != null) { messageId = focus.messageId; } if (null != messageId) { jumpToPresentResult = orCreate.focusOnMessage(focus.messageId); } else { let messageId1; if (jump != null) { messageId1 = jump.messageId; } if (null != messageId1) { ({ messageId: obj4.messageId, flash: obj4.flash, offset: obj4.offset, returnMessageId: obj4.returnTargetId, jumpType: obj4.jumpType, onJumpComplete: obj4.onJumpComplete } = jump); jumpToPresentResult = orCreate.jumpToMessage({ messageId: null, flash: null, offset: null, returnTargetId: null, jumpType: null, onJumpComplete: null }); const obj2 = { messageId: null, flash: null, offset: null, returnTargetId: null, jumpType: null, onJumpComplete: null }; } else { jumpToPresentResult = orCreate; if (!tmp6) { jumpToPresentResult = orCreate.loadFromCache(null != before, limit); } tmp6 = null == before && null == after; } } } let tmp7 = null == truncate.truncate; if (!tmp7) { tmp7 = null == before && null == after; const tmp8 = null == before && null == after; } if (!tmp7) { tmp7 = null != before && null != after; const tmp9 = null != before && null != after; } let truncateResult = jumpToPresentResult; if (!tmp7) { truncateResult = jumpToPresentResult.truncate(null != before, null != after); } require = truncateResult; let tmp10 = truncateResult; if (!truncateResult.hasMoreAfter) { const messages = EphemeralMessageStore.getMessages(channelId); tmp10 = truncateResult; if (0 !== messages.length) { let firstResult = null; if (truncateResult.hasMoreBefore) { firstResult = truncateResult.first(); } importDefault = firstResult; found = messages.filter((id) => { const hasItem = truncateResult.has(id.id); let tmp2 = !hasItem; if (!hasItem) { let tmp5 = null == firstResult; if (!tmp5) { tmp5 = SnowflakeUtilsDefault.compare(id.id, tmp3.id) > 0; } tmp2 = tmp5; } return tmp2; }); let mutation = truncateResult; if (0 !== found.length) { mutation = truncateResult.mutate((_merge) => { _merge._merge(found); const _array = _merge._array; const sorted = _array.sort((id, id2) => closure_1_1(found[18]).compare(id.id, id2.id)); }, true); } tmp10 = mutation; } } let obj = require("ChannelMessages"); require("ChannelMessages").commit(tmp10); }, LOCAL_MESSAGES_LOADED: function handleLocalMessagesLoaded(channelId) { const orCreate = ChannelMessagesDefault.getOrCreate(channelId.channelId); const addCachedMessagesResult = orCreate.addCachedMessages(channelId.messages, channelId.stale); let isForegroundCacheLoad = channelId.isForegroundCacheLoad; if (isForegroundCacheLoad) { isForegroundCacheLoad = channelId.messages.length > 0; } if (isForegroundCacheLoad) { isForegroundCacheLoad = null == addCachedMessagesResult.jumpTargetId; } let mutation = addCachedMessagesResult; if (isForegroundCacheLoad) { const obj2 = { initialScrollSequenceId: addCachedMessagesResult.initialScrollSequenceId + 1, suppressRowAnimationSequenceId: addCachedMessagesResult.suppressRowAnimationSequenceId + 1 }; mutation = addCachedMessagesResult.mutate(obj2); } ChannelMessagesDefault.commit(mutation); }, LOAD_MESSAGE_INTERACTION_DATA_SUCCESS: function handleLoadMessageInteractionDataSuccess(messageId) { messageId = messageId.messageId; value = ChannelMessagesDefault.get(messageId.channelId); if (null != value) { if (value.has(messageId)) { const updateResult = value.update(messageId, (set) => set.set("interactionData", messageId.interactionData)); ChannelMessagesDefault.commit(updateResult); } } return false; }, TRUNCATE_MESSAGES: function handleTruncateMessages(arg0) { ({ channelId, truncateBottom, truncateTop } = arg0); logger.log("Truncating messages for " + channelId + " bottom:" + truncateBottom + " top:" + truncateTop); const orCreate = ChannelMessagesDefault.getOrCreate(channelId); const truncateResult = orCreate.truncate(truncateBottom, truncateTop); ChannelMessagesDefault.commit(truncateResult); }, CLEAR_MESSAGES: function handleClearMessages(channelId) { channelId = channelId.channelId; logger.log("Clearing messages for " + channelId); ChannelMessagesDefault.clear(channelId); set.clear(); }, MESSAGE_CREATE: function handleIncomingMessage(isPushNotification) { ({ channelId, message, optimistic } = isPushNotification); const orCreate = ChannelMessagesDefault.getOrCreate(channelId); const isConnectedResult = GatewayConnectionStore.default.isConnected(); if (isPushNotification.isPushNotification) { if (tmp3Result.isIOSPushNotificationRawPayloadFixExperimentEnabled()) { (function addPushNotificationMessageIfNotCached() { const self = this; const apply = closure_1_31.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; })(channelId, message, isConnectedResult); } else { logger.log("Inserting message tapped on from a push notification", message.id, message.channel_id); tmp(5521).commit(orCreate.receivePushNotification(message, isConnectedResult)); const tmpResult = tmp(5521); } tmp3Result = IOSPushNotificationRawPayloadFixExperiment; } else { let ready = orCreate.ready; if (ready) { let tmp6 = !optimistic; if (optimistic) { tmp6 = !orCreate.has(message.id); } if (tmp6) { let hasItem = null != message.nonce; if (hasItem) { hasItem = message.state !== constants5.SENDING; } if (hasItem) { hasItem = set.has(message.nonce); } let removeResult = orCreate; if (hasItem) { removeResult = orCreate.remove(message.nonce); set.delete(message.nonce); } const receiveMessageResult = removeResult.receiveMessage(message, true === DimensionStore.isAtBottom(channelId)); tmp(5521).commit(receiveMessageResult); receiveMediaMentionMessage(message); const tmpResult2 = tmp(5521); } ready = tmp6; } return ready; } }, MESSAGE_SEND_FAILED: function handleSendFailed(channelId) { ({ messageId, reason: require } = channelId); const orCreate = ChannelMessagesDefault.getOrCreate(channelId.channelId); if (null != orCreate) { if (orCreate.has(messageId)) { value = orCreate.get(messageId, true); let isPollResult; if (value != null) { isPollResult = value.isPoll(); } if (true === isPollResult) { let removeResult = orCreate.remove(messageId); } else { removeResult = orCreate.update(messageId, (set) => { const result = set.set("state", constants5.SEND_FAILED); if (result.isCommandType()) { let str3 = closure_1_0; if (closure_1_0 == null) { str3 = ""; } const result1 = result.set("interactionError", str3); let result2 = result1.set("flags", FlagUtils.addFlag(result1.flags, constants3.EPHEMERAL)); } else { let str = closure_1_0; result2 = result; if (null != closure_1_0) { if (str == null) { str = ""; } result2 = result.set("interactionError", str); } } return result2; }); } ChannelMessagesDefault.commit(removeResult); } } return false; }, MESSAGE_SEND_FAILED_AUTOMOD: handleMessageSendFailedAutomod, AUTO_MODERATION_CONTENT_DELETED: function handleAutomodContentDeleted(message) { message = message.message; if (null != message) { if (null == message.thread) { const channel_id = message.channel_id; const orCreate = ChannelMessagesDefault.getOrCreate(channel_id); let ready = orCreate.ready; if (ready) { const hasItem = orCreate.has(message.id); let tmp3 = !hasItem; let obj = orCreate; if (!hasItem) { const receiveMessageResult = orCreate.receiveMessage(message, true === DimensionStore.isAtBottom(channel_id)); tmp3 = !receiveMessageResult.has(message.id); obj = receiveMessageResult; } if (!tmp3) { const updateResult = obj.update(message.id, (set) => set.set("flags", FlagUtils.addFlag(set.flags, constants.EPHEMERAL))); ChannelMessagesDefault.commit(updateResult); const result = map.set(message.id, tmp); const tmp11Result = ChannelMessagesDefault; } ready = !tmp3; const tmp5 = !tmp3; } return ready; } } return false; }, MESSAGE_EDIT_FAILED_AUTOMOD: handleMessageSendFailedAutomod, MESSAGE_UPDATE: function handleMessageUpdate(message) { const id = message.message.id; const orCreate = ChannelMessagesDefault.getOrCreate(message.message.channel_id); if (null != orCreate) { if (orCreate.has(id)) { const updateResult = orCreate.update(id, (message) => MessageRecordUtils.updateMessageRecord(message, message.message)); tmp(5521).commit(updateResult); message = message.message; closure_129_0 = message; const media_mention = message.media_mention; let message_id; if (media_mention != null) { message_id = media_mention.message_id; } if (null != message_id) { if ("content" in message) { const orCreate1 = tmp(5521).getOrCreate(message.media_mention.attachment_id); const tmpResult3 = tmp(5521); const updateResult1 = orCreate1.update(message.media_mention.message_id, (message) => MessageRecordUtils.updateMessageRecord(message, { content: message.content })); tmp(5521).commit(updateResult1); const tmpResult4 = tmp(5521); } } } } return false; }, MESSAGE_EXPLICIT_CONTENT_SCAN_TIMEOUT: function handleMessageExplicitContentScanTimeout(messageId) { messageId = messageId.messageId; value = ChannelMessagesDefault.get(messageId.channelId); if (null != value) { if (value.has(messageId)) { const updateResult = value.update(messageId, ExplicitMediaRedactionUtils.handleExplicitMediaScanTimeoutForMessage); ChannelMessagesDefault.commit(updateResult); } } return false; }, MESSAGE_DELETE: function handleMessageDelete(id) { id = id.id; ({ channelId, local } = id); const orCreate = ChannelMessagesDefault.getOrCreate(channelId); if (null != orCreate) { if (orCreate.has(id)) { if (map.has(id)) { if (true !== local) { return false; } else { obj3.delete(id); } } if (orCreate.revealedMessageId !== id) { value = orCreate.get(id); if (null != value) { const mediaMention = value.mediaMention; let attachment_id; if (mediaMention != null) { attachment_id = mediaMention.attachment_id; } if (null != attachment_id) { value2 = tmp(5521).get(attachment_id); if (null != value2) { const mediaMention2 = value.mediaMention; let message_id; if (mediaMention2 != null) { message_id = mediaMention2.message_id; } if (null != message_id) { const removeResult = value2.remove(message_id); tmp(5521).commit(removeResult); const tmpResult3 = tmp(5521); } } const tmpResult = tmp(5521); } } const removeResult1 = orCreate.remove(id); tmp(5521).commit(removeResult1); set.delete(id); } else { let id2 = orCreate.getAfter(id); if (null == id2) { let mutation = orCreate.mutate({ revealedMessageId: null }); } const obj2 = { revealedMessageId: null }; id2 = id2.id; obj2.revealedMessageId = id2; mutation = orCreate.mutate(obj2); } obj3 = map; } } return false; }, MESSAGE_DELETE_BULK: function handleMessageDeleteBulk(ids) { ids = ids.ids; let mutation; const orCreate = mutation(5521).getOrCreate(ids.channelId); if (null == orCreate) { return false; } else { const item = ids.forEach((item) => { value = orCreate.get(item); if (null != value) { const mediaMention = value.mediaMention; let attachment_id; if (mediaMention != null) { attachment_id = mediaMention.attachment_id; } if (null != attachment_id) { value2 = ChannelMessagesDefault.get(attachment_id); if (null != value2) { const mediaMention2 = value.mediaMention; let message_id; if (mediaMention2 != null) { message_id = mediaMention2.message_id; } if (null != message_id) { const removeResult = value2.remove(message_id); tmp3(5521).commit(removeResult); const tmp3Result = tmp3(5521); } } tmp3 = importDefault; } } }); const removeManyResult = orCreate.removeMany(ids); mutation = removeManyResult; if (orCreate === removeManyResult) { return false; } else { let tmp3 = removeManyResult; if (null != removeManyResult.revealedMessageId) { tmp3 = removeManyResult; if (tmpResult.some(ids, (arg0) => mutation.revealedMessageId === arg0)) { let id = removeManyResult.getAfter(removeManyResult.revealedMessageId); if (null == id) { mutation = removeManyResult.mutate({ revealedMessageId: null }); } const obj2 = { revealedMessageId: null }; id = id.id; obj2.revealedMessageId = id; mutation = removeManyResult.mutate(obj2); } tmpResult = tmp(12); } tmp(5521).commit(tmp3); const item1 = ids.forEach((item) => { set.delete(item); }); } } let obj = mutation(5521); }, MESSAGE_REVEAL: function handleMessageReveal(arg0) { ({ channelId, messageId } = arg0); const orCreate = ChannelMessagesDefault.getOrCreate(channelId); ChannelMessagesDefault.commit(orCreate.mutate({ revealedMessageId: messageId })); }, THREAD_CREATE_LOCAL: function handleThreadCreateLocal(channelId) { const orCreate = ChannelMessagesDefault.getOrCreate(channelId.channelId); const complete = orCreate.loadComplete({ newMessages: [], hasMoreAfter: false, hasMoreBefore: false }); ChannelMessagesDefault.commit(complete); }, CHANNEL_UPDATES: function handleChannelUpdates(channels) { channels = channels.channels; let flag = false; const uniqResult = _modDef12.uniq(channels.map((guild_id) => guild_id.guild_id)); while (tmp2 !== undefined) { if (invalidateInaccessibleMessages(tmp3)) { flag = true; } continue; } return flag; }, GUILD_ROLE_UPDATE: handleRoleUpdate, GUILD_ROLE_DELETE: handleRoleUpdate, GUILD_MEMBER_UPDATE: function handleMemberUpdate(user) { const currentUser = UserStore.getCurrentUser(); let id; if (currentUser != null) { id = currentUser.id; } let tmp3 = user.user.id === id; if (tmp3) { const guildId = user.guildId; importDefault = false; const item = ChannelMessagesDefault.forEach((cached) => { if (!cached.cached) { const basicChannel = ChannelStore.getBasicChannel(cached.channelId); let guild_id; if (basicChannel != null) { guild_id = basicChannel.guild_id; } if (guild_id === guildId) { if (!PermissionStore.canBasicChannel(constants.VIEW_CHANNEL, basicChannel)) { ChannelMessagesDefault.commit(cached.mutate({ cached: true })); c1 = true; } } } }); tmp3 = importDefault; } return tmp3; }, CHANNEL_DELETE: handleCleanup, THREAD_DELETE: handleCleanup, GUILD_DELETE: handleCleanup, RELATIONSHIP_ADD: handleRelationshipUpdate, RELATIONSHIP_UPDATE: handleRelationshipUpdate, RELATIONSHIP_REMOVE: handleRelationshipUpdate, GUILD_MEMBERS_CHUNK_BATCH: function handleGuildMembersChunkBatch(arg0) { while (tmp !== undefined) { let tmp4 = performAuthorUpdate(tmp2.guildId); continue; } }, THREAD_MEMBER_LIST_UPDATE: function handleThreadMemberListUpdate(guildId) { guildId = guildId.guildId; let item = ChannelMessagesDefault.forEach((channelId) => { const channel = ChannelStore.getChannel(channelId.channelId); let guild_id; if (channel != null) { guild_id = channel.guild_id; } if (guild_id === guildId) { const items = []; c1 = false; const item = channelId.forEach((nick) => { const messageAuthor = guildId(dependencyMap[27]).getMessageAuthor(nick); ({ nick, colorString } = messageAuthor); if (nick === nick.nick) { if (colorString === nick.colorString) { items.push(nick); } } c1 = true; items.push(nick.merge({ nick, colorString })); }); if (c1) { ChannelMessagesDefault.commit(channelId.reset(items)); } } }); }, MESSAGE_REACTION_ADD: handleReaction, MESSAGE_REACTION_ADD_MANY: function handleReactionBatch(reactions) { reactions = reactions.reactions; ({ channelId, messageId } = reactions); value = ChannelMessagesDefault.get(channelId); if (null == value) { return false; } else { const updateResult = value.update(messageId, (addReactionBatch) => { const currentUser = UserStore.getCurrentUser(); let id; if (currentUser != null) { id = currentUser.id; } return addReactionBatch.addReactionBatch(reactions, id); }); ChannelMessagesDefault.commit(updateResult); } }, MESSAGE_REACTION_REMOVE: handleReaction, MESSAGE_REACTION_REMOVE_ALL: function handleRemoveAllReactions(arg0) { ({ channelId, messageId } = arg0); value = ChannelMessagesDefault.get(channelId); if (null == value) { return false; } else { const updateResult = value.update(messageId, (set) => set.set("reactions", [])); ChannelMessagesDefault.commit(updateResult); } }, MESSAGE_REACTION_REMOVE_EMOJI: function handleRemoveEmojiReactions(emoji) { emoji = emoji.emoji; ({ channelId, messageId } = emoji); value = ChannelMessagesDefault.get(channelId); if (null == value) { return false; } else { const updateResult = value.update(messageId, (removeReactionsForEmoji) => removeReactionsForEmoji.removeReactionsForEmoji(emoji)); ChannelMessagesDefault.commit(updateResult); } }, LOGOUT: function handleLogout() { const item = ChannelMessagesDefault.forEach((channelId) => { ChannelMessagesDefault.clear(channelId.channelId); }); set.clear(); }, UPLOAD_START: function handleUploadStart(message) { message = message.message; let nonce; if (message != null) { nonce = message.nonce; } if (null != nonce) { set.add(message.nonce); } }, UPLOAD_FAIL: function handleUploadFail(messageId) { messageId = messageId.messageId; if (null == messageId) { return false; } else { if (set.has(messageId)) { const orCreate = ChannelMessagesDefault.getOrCreate(tmp); value = orCreate.get(messageId); if (null == value) { return false; } else { const items = [value]; const removeResult = orCreate.remove(messageId); obj5.delete(messageId); const mergeResult = orCreate.remove(messageId).merge(items); tmp2(5521).commit(mergeResult); } tmp2 = importDefault; } else { return false; } obj5 = set; } }, LOCAL_MESSAGE_CREATE: function handleLocalIncomingMesssage(message) { message = message.message; const currentUser = UserStore.getCurrentUser(); if (tmp2) { c29 = true; } } }); const size = fn(2); let result = size.fileFinishedImporting("stores/MessageStore.tsx"); export default messageStore;