2216 lines
81 KiB
TypeScript
2216 lines
81 KiB
TypeScript
// Metro module 5713 (f5714).
|
|
import GatewayConnectionStore from "../modules/gateway/GatewayConnectionStore";
|
|
import "../modules/guild_member_verification/GuildJoinRequestStore";
|
|
import "../modules/guild_templates/GuildTemplateStore";
|
|
import MessageRoundtripTrackerStore from "../modules/messages/MessageRoundtripTrackerStore";
|
|
import PoggermodeSettingsStore from "../modules/poggermode/PoggermodeSettingsStore";
|
|
import "../modules/replies/PendingReplyStore";
|
|
import ReferencedMessageStore, { ReferencedMessageState } from "../modules/replies/ReferencedMessageStore";
|
|
import StickersStore from "../modules/stickers/StickersStore";
|
|
import ApplicationStreamingStore from "../stores/ApplicationStreamingStore";
|
|
import AuthenticationStore from "../stores/AuthenticationStore";
|
|
import ChannelStore from "../stores/ChannelStore";
|
|
import EditMessageStore from "../stores/EditMessageStore";
|
|
import GuildStore from "../stores/GuildStore";
|
|
import InviteStore from "../stores/InviteStore";
|
|
import MessageStore from "../stores/MessageStore";
|
|
import "../stores/PermissionStore";
|
|
import PresenceStore from "../stores/PresenceStore";
|
|
import ReadStateStore from "../stores/ReadStateStore";
|
|
import "../stores/SlowmodeStore";
|
|
import UserStore from "../stores/UserStore";
|
|
import { MessageTypes, AllowedMentionTypes, MessageFlags, LoggingInviteTypes, InviteStates, SendTypes, AnalyticEvents, AbortCodes, Permissions, HelpdeskArticles, MarketingURLs, LOCAL_BOT_ID, NON_USER_BOT_DISCRIMINATOR, MessageStates, MAX_MESSAGES_FOR_JUMP, Endpoints, ChannelTypes, MessageReferenceTypes, ActivityActionTypes } from "../Constants";
|
|
import { LinkType } from "../modules/applications/message_embed/MessageEmbedConstants";
|
|
import "../modules/guild_templates/GuildTemplatesConstants";
|
|
import { MessageSendLocation } from "../modules/messages/MessageConstants";
|
|
import { NativeModules } from "react-native";
|
|
import Logger from "../modules/debug/Logger";
|
|
import { trackAppEmbedLinkSent } from "../modules/applications/message_embed/web/appMessageEmbedTracking";
|
|
import AppAnalyticsUtils from "../modules/app_analytics/AppAnalyticsUtils";
|
|
import AnalyticsUtils from "../utils/AnalyticsUtils";
|
|
import { parseExtraDataFromInviteKey, getInviteInstanceId } from "../modules/instant_invite/InviteCodeUtils";
|
|
import { isEmbeddedApplicationInvite } from "../modules/instant_invite/InviteTypeUtils";
|
|
import { getStreamerApplication } from "../modules/go_live/utils/StreamerApplicationSelectors";
|
|
import { intl, t } from "../intl/index.native";
|
|
import HelpdeskUtils from "../utils/HelpdeskUtils";
|
|
import { getAttachmentPayload, MAX_TOTAL_ATTACHMENT_SIZE_MB } from "../utils/UploadUtils";
|
|
import Dispatcher from "../Dispatcher";
|
|
import createMessage, { createBotMessage } from "../modules/messages/createMessage";
|
|
import { match } from "../_bundle/Module4389";
|
|
import { createNonce } from "../modules/messages/createNonce";
|
|
import { trackMediaRedactionAction, TrackMediaRedactionActionType } from "../modules/explicit_media_redaction/ExplicitMediaRedactionUtils";
|
|
import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest";
|
|
import { createMessageRecord } from "../modules/messages/MessageRecordUtils";
|
|
import { FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID } from "../modules/channel/FakePlaceholderPrivateChannel";
|
|
import TTITracker from "../modules/tti_analytics/TTITracker";
|
|
import MessageCacheStats from "../modules/local_message_caching/MessageCacheStats";
|
|
import ChannelMessages from "../lib/ChannelMessages";
|
|
import SnowflakeUtils from "../utils/SnowflakeUtils";
|
|
import DatabaseDaos from "../modules/app_database/DatabaseDaos";
|
|
import { tryLoadAsync } from "../modules/app_database/app/TryLoad";
|
|
import Messages from "../modules/app_database/modules/Messages";
|
|
import { isIOSPushNotificationRawPayloadFixExperimentEnabled } from "../modules/notifications/IOSPushNotificationRawPayloadFixExperiment";
|
|
import maybeConvertPrivateChannel from "../modules/private_channel_creation/maybeConvertPrivateChannel";
|
|
import BackgroundTaskManager_native from "../modules/messages/BackgroundTaskManager.native";
|
|
import getInviteURL from "../modules/instant_invite/getInviteURL";
|
|
import SentMessageIntentsHandler_android from "../modules/messages/SentMessageIntentsHandler.android";
|
|
import PremiumUtils from "../utils/PremiumUtils";
|
|
import parseContentForSuppressNotifications from "../modules/suppress_notifications/parseContentForSuppressNotifications";
|
|
import { addFlag, hasFlag, setFlag } from "../_bundle/Module1384";
|
|
import { canSendGuildOfficialMessages } from "../modules/messages/GuildOfficialMessageUtils";
|
|
import { createPollServerDataFromCreateRequest } from "../modules/polls/PollsUtils";
|
|
import { updateComboOnMessageSend } from "../modules/poggermode/PoggermodeActionCreators";
|
|
import MessageQueue, { MessageDataType } from "../lib/MessageQueue";
|
|
import { uploadMessageAttachments } from "../modules/media_uploads/uploadMessageAttachments.native";
|
|
import { logMessageSendFailure } from "../modules/messages/logMessageSendFailure";
|
|
import { AUTOMOD_ERROR_CODES } from "../modules/guild_automod/AutomodErrorUtils";
|
|
import { ComponentType } from "../flow/Server";
|
|
import ThreadActionCreators from "../modules/threads/ThreadActionCreators";
|
|
import { AccessibilityAnnouncer } from "../design/shared";
|
|
import { logGiftIntentMessageDismissed } from "../modules/premium/gifting/PremiumGiftingIntentActionCreators";
|
|
import AlertActionCreators from "./AlertActionCreators";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
function $mk114782($env) {
|
|
return (a0) => SnowflakeUtils.compare(a0.id, $env[4]) > 0;
|
|
}
|
|
function $mk114783($env) {
|
|
return function _trySend() {
|
|
const r0 = $env;
|
|
return c3543_55._sendMessage(r0[0], r0[1], r0[3]);
|
|
};
|
|
}
|
|
function $mk114784($env) {
|
|
return (a0, a1) => {
|
|
let env31381 = {
|
|
$parent: $env
|
|
};
|
|
env31381[0] = a0;
|
|
env31381[1] = a1;
|
|
MessageStore.whenReady($env.$parent[0], () => {
|
|
env31381.$parent.$parent.$parent[50].info(`Channel ${env31381.$parent.$parent[0]} is ready for sending now.`);
|
|
(0, env31381.$parent[2])().then(env31381[0], env31381[1]);
|
|
});
|
|
};
|
|
}
|
|
function $mk114788($env) {
|
|
return (a0, a1) => getAttachmentPayload(a0, a1);
|
|
}
|
|
function $mk114789($env) {
|
|
return (a0, a1) => {
|
|
let env31382 = {
|
|
$parent: $env
|
|
};
|
|
env31382[0] = a0;
|
|
env31382[1] = a1;
|
|
env31382[2] = Date.now();
|
|
env31382[3] = MessageQueue.length;
|
|
const r21 = Math.floor(10000 * Math.random());
|
|
env31382[4] = r21;
|
|
c3543_50.info(`Queueing message to be sent LogId:${r21}`);
|
|
MessageQueue.enqueue($env[16], (a0) => {
|
|
let r43, reason;
|
|
let c31940_0 = a0;
|
|
const duration = Date.now() - env31382[2];
|
|
const ok = a0.ok;
|
|
const r34 = env31382.$parent.$parent.$parent;
|
|
if (ok) {
|
|
const r202 = (0, r34[1])(r34[3][65]);
|
|
const r204 = env31382.$parent;
|
|
const content2 = r204[0];
|
|
const r206 = env31382.$parent.$parent;
|
|
r202.donateSentMessage(content2, r206[0]);
|
|
r34[55].receiveMessage(r206[0], a0.body, true, {
|
|
sendAnalytics: {
|
|
duration,
|
|
queueSize: env31382[3]
|
|
},
|
|
poll: r204[6]
|
|
});
|
|
if (r206[2].alsoForwardToChannelId != null) {
|
|
(0, r34[1])(r34[3][75]).sendForward((0, r34[0])(r34[3][52]).createMessageRecord(a0.body), r206[2].alsoForwardToChannelId).then(() => {
|
|
const id2 = c31940_0.body?.id;
|
|
const guild_id = c31940_0.body?.guild_id;
|
|
const channel_id = c31940_0.body?.channel_id;
|
|
const alsoForwardToChannelId = env31382.$parent.$parent[2].alsoForwardToChannelId;
|
|
const r18 = env31382.$parent.$parent.$parent;
|
|
(0, r18[1])(r18[3][37]).track(r18[27].MESSAGE_ALSO_SEND_TO_CHANNEL_SENT, {
|
|
referenced_message_id: id2,
|
|
guild_id,
|
|
channel_id,
|
|
destination_channel_id: alsoForwardToChannelId
|
|
});
|
|
}).catch((a0) => {
|
|
const r5 = env31382.$parent.$parent.$parent[49];
|
|
const r13 = `Failed to forward thread message to parent channel LogId:${env31382[4]}`;
|
|
const id2 = c31940_0.body?.id;
|
|
const r20 = env31382.$parent.$parent;
|
|
r5.log(r13, {
|
|
referencedMessageId: id2,
|
|
channelId: r20[0],
|
|
destinationChannelId: r20[2].alsoForwardToChannelId,
|
|
error: a0.toString()
|
|
});
|
|
});
|
|
}
|
|
const request = r34[7].getRequest((0, r34[1])(r34[3][57]).cast(r206[0]));
|
|
if (request != null) {
|
|
const { guildId, userId, applicationStatus } = request;
|
|
(0, r34[0])(r34[3][76]).trackMemberApplicationInterviewMessage({
|
|
guildId,
|
|
channelId: r206[0],
|
|
messageId: a0.body.id,
|
|
joinRequestStatus: applicationStatus,
|
|
joinRequestUserId: userId
|
|
});
|
|
}
|
|
r34[9].recordMessageSendApiResponse(r204[13]);
|
|
if (r204[12] === r34[35].REPLY) {
|
|
const id2 = a0.body.id;
|
|
const channel_id = r206[0];
|
|
const message_id = r204[5]?.message_id;
|
|
const pendingReplyActionSource = r34[11].getPendingReplyActionSource(channel_id);
|
|
if (pendingReplyActionSource === "message_swipe") {
|
|
const r310 = message_id != null ? r34[21].getMessage(channel_id, message_id) : null;
|
|
const channel2 = r34[17].getChannel(channel_id);
|
|
const currentUser = r34[25].getCurrentUser();
|
|
(0, r34[1])(r34[3][37]).track(r34[27].MESSAGE_SWIPE_ACTION_SENT, {
|
|
message_id: id2,
|
|
channel_id,
|
|
guild_id: channel2?.guild_id,
|
|
swipe_action: "reply",
|
|
is_own_message: currentUser != null && currentUser.id === (r310 == null ? void 0 : r310.author.id)
|
|
});
|
|
} else if (pendingReplyActionSource === "message_shortcut") {
|
|
const channel = r34[17].getChannel(channel_id);
|
|
(0, r34[1])(r34[3][37]).track(r34[27].MESSAGE_SHORTCUT_ACTION_SENT, {
|
|
message_id: id2,
|
|
channel_id,
|
|
guild_id: channel?.guild_id,
|
|
original_message_id: message_id,
|
|
action: "reply",
|
|
...(0, r34[0])(r34[3][33]).collectGuildAnalyticsMetadata(channel?.guild_id),
|
|
...(0, r34[0])(r34[3][33]).collectChannelAnalyticsMetadata(channel)
|
|
});
|
|
}
|
|
}
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "SLOWMODE_RESET_COOLDOWN",
|
|
slowmodeType: r34[24].SendMessage,
|
|
channelId: r206[0]
|
|
});
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "EMOJI_TRACK_USAGE",
|
|
emojiUsed: r204[1]
|
|
});
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "STICKER_TRACK_USAGE",
|
|
stickerIds: r204[4]
|
|
});
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "LOCAL_MESSAGE_CREATE",
|
|
message: {
|
|
channel_id: r206[0],
|
|
author: r34[25].getCurrentUser()
|
|
}
|
|
});
|
|
let location2 = r204[2];
|
|
const location3 = location2 == null ? "chat_input" : location2;
|
|
const r373 = {
|
|
content: content2,
|
|
channelId: r206[0],
|
|
messageId: a0.body.id,
|
|
location: location3,
|
|
inviteAnalyticsMetadata: r204[3]
|
|
};
|
|
let env31941 = {
|
|
$parent: r34
|
|
};
|
|
const content = r373.content;
|
|
env31941[0] = r373.channelId;
|
|
env31941[1] = r373.messageId;
|
|
env31941[2] = r373.location;
|
|
env31941[3] = r373.inviteAnalyticsMetadata;
|
|
let overrideProperties = r373.overrideProperties;
|
|
if (overrideProperties === void 0) {
|
|
overrideProperties = {};
|
|
}
|
|
env31941[4] = overrideProperties;
|
|
env31941[5] = void 0;
|
|
env31941[5] = r34[16].getId();
|
|
(0, r34[1])(r34[3][28])(content).forEach((item) => {
|
|
L41: {
|
|
const { type, code, url } = item;
|
|
const r20 = env31941.$parent;
|
|
const r5 = r20[0];
|
|
const r4 = r20[3];
|
|
if (r5(r4[29]).isApplicationCodedLink(type)) {
|
|
const applicationCodedLinkData = r5(r4[29]).getApplicationCodedLinkData(type, code, url);
|
|
if (applicationCodedLinkData == null) {
|
|
return void 0;
|
|
}
|
|
const { applicationId, type: type2 } = applicationCodedLinkData;
|
|
if (r5(r4[30]).CodedLinkType.APP_DIRECTORY_PROFILE === type2) {
|
|
r5(r4[31]).trackAppDirectoryProfileEmbed(applicationId);
|
|
r5(r4[32]).trackAppEmbedLinkSent(code, r20[44].APP_DISCOVERY, env31941[5]);
|
|
} else if (r5(r4[30]).CodedLinkType.APP_DIRECTORY_STOREFRONT === type2) {
|
|
r5(r4[31]).trackAppDirectoryProfileEmbed(applicationId, "storefront");
|
|
} else if (r5(r4[30]).CodedLinkType.APP_DIRECTORY_STOREFRONT_SKU === type2) {
|
|
r5(r4[31]).trackAppDirectoryProfileEmbed(applicationId, "storefront_sku");
|
|
} else if (r5(r4[30]).CodedLinkType.ACTIVITY_BOOKMARK === type2) {
|
|
const params = applicationCodedLinkData.params;
|
|
const r196 = r5(r4[32]);
|
|
const ACTIVITY = r20[44].ACTIVITY;
|
|
let referrerId = params.referrerId;
|
|
if (referrerId == null) {
|
|
referrerId = env31941[5];
|
|
}
|
|
r196.trackAppEmbedLinkSent(applicationId, ACTIVITY, referrerId, params.customId);
|
|
} else if (r5(r4[30]).CodedLinkType.APP_OAUTH2_LINK === type2) {
|
|
r5(r4[32]).trackAppEmbedLinkSent(applicationId, r20[44].OAUTH, env31941[5]);
|
|
(0, r20[1])(r4[33]).trackWithMetadata(r20[27].APP_OAUTH2_LINK_EMBED_URL_SENT, {
|
|
application_id: applicationId
|
|
});
|
|
}
|
|
} else if (r5(r4[30]).CodedLinkType.INVITE === type) {
|
|
(0, r20[53])({
|
|
inviteKey: code,
|
|
channelId: env31941[0],
|
|
messageId: env31941[1],
|
|
location: env31941[2],
|
|
inviteAnalyticsMetadata: env31941[3],
|
|
overrideProperties: env31941[4]
|
|
});
|
|
} else {
|
|
if (r5(r4[30]).CodedLinkType.TEMPLATE === type) {
|
|
const guildTemplate = r20[8].getGuildTemplate(code);
|
|
if (guildTemplate != null && guildTemplate.state !== r20[45].RESOLVING) {
|
|
(0, r20[1])(r4[33]).trackWithMetadata(r20[27].GUILD_TEMPLATE_LINK_SENT, {
|
|
guild_template_code: code,
|
|
guild_template_name: guildTemplate.name,
|
|
guild_template_description: guildTemplate.description,
|
|
guild_template_guild_id: guildTemplate.sourceGuildId
|
|
});
|
|
break L41;
|
|
}
|
|
return void 0;
|
|
}
|
|
if (r5(r4[30]).CodedLinkType.BUILD_OVERRIDE !== type && r5(r4[30]).CodedLinkType.EXPERIMENT !== type && r5(r4[30]).CodedLinkType.MANUAL_BUILD_OVERRIDE !== type && r5(r4[30]).CodedLinkType.EVENT !== type && r5(r4[30]).CodedLinkType.CHANNEL_LINK !== type) {
|
|
if (r5(r4[30]).CodedLinkType.EMBEDDED_ACTIVITY_INVITE === type) {
|
|
r5(r4[32]).trackAppEmbedLinkSent(code, r20[44].ACTIVITY_INVITE, env31941[5]);
|
|
} else if (r5(r4[30]).CodedLinkType.GUILD_PRODUCT !== type && r5(r4[30]).CodedLinkType.SERVER_SHOP !== type && r5(r4[30]).CodedLinkType.SOCIAL_LAYER_STOREFRONT !== type && r5(r4[30]).CodedLinkType.SOCIAL_LAYER_STOREFRONT_APP !== type) {
|
|
if (r5(r4[30]).CodedLinkType.QUESTS_EMBED === type) {
|
|
const adMetadataSealed = r5(r4[34]).getAdMetadataSealed(r5(r4[35]).QuestContent.QUESTS_EMBED);
|
|
r5(r4[36]).trackQuestEvent({
|
|
questId: code,
|
|
event: r20[27].QUEST_LINK_SHARED,
|
|
properties: {
|
|
metadata_sealed: adMetadataSealed ?? null
|
|
},
|
|
trackGuildAndChannelMetadata: true,
|
|
sourceQuestContent: r5(r4[35]).QuestContent.QUESTS_EMBED
|
|
});
|
|
} else if (r5(r4[30]).CodedLinkType.GAME_PROFILE === type) {
|
|
(0, r20[1])(r4[37]).track(r20[27].GAME_PROFILE_LINK_EMBED_SENT, {
|
|
game_id: code
|
|
});
|
|
} else if (r5(r4[30]).CodedLinkType.COLLECTIBLES_SHOP !== type && r5(r4[30]).CodedLinkType.GAME_SERVER_SHARE !== type) {
|
|
throw Error(`Unknown coded link type: ${type}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
const r397 = r206[0];
|
|
const id3 = a0.body.id;
|
|
const r400 = location2 == null ? "chat_input" : location2;
|
|
const r403 = !r206[2].isGiftLinkSentOnBehalfOfUser;
|
|
let env31942 = {
|
|
$parent: r34
|
|
};
|
|
env31942[0] = r397;
|
|
env31942[1] = id3;
|
|
env31942[2] = r400;
|
|
env31942[3] = !r403;
|
|
(0, r34[0])(r34[3][41]).findGiftCodes(content2).forEach((item) => {
|
|
const r1 = env31942.$parent;
|
|
const channel = r1[17].getChannel(env31942[0]);
|
|
if (channel != null) {
|
|
(0, r1[1])(r1[3][33]).trackWithMetadata(r1[27].GIFT_CODE_SENT, {
|
|
location: env31942[2],
|
|
gift_code: item,
|
|
guild_id: channel.getGuildId(),
|
|
channel_id: channel.id,
|
|
channel_type: channel.type,
|
|
message_id: env31942[1],
|
|
automatic_send: env31942[3]
|
|
});
|
|
}
|
|
});
|
|
if (r206[2].gifMetadata != null) {
|
|
const gifMetadata = r206[2].gifMetadata;
|
|
const r419 = r206[0];
|
|
const id4 = a0.body.id;
|
|
if (location2 == null) {
|
|
location2 = "chat_input";
|
|
}
|
|
const channel3 = r34[17].getChannel(r419);
|
|
if (channel3 != null) {
|
|
(0, r34[1])(r34[3][37]).track(r34[27].MESSAGE_SENT_WITH_GIF, {
|
|
location: location2,
|
|
message_id: id4,
|
|
gif_provider: gifMetadata.gif_provider,
|
|
load_id: gifMetadata.load_id,
|
|
source_object: gifMetadata.source_object,
|
|
gif_url: gifMetadata.gif_url,
|
|
gif_id: gifMetadata.gif_id,
|
|
...(0, r34[0])(r34[3][33]).collectGuildAnalyticsMetadata(channel3.getGuildId()),
|
|
...(0, r34[0])(r34[3][33]).collectChannelAnalyticsMetadata(channel3)
|
|
});
|
|
}
|
|
}
|
|
const r457 = r206[0];
|
|
const id5 = a0.body.id;
|
|
let attachments = a0.body.attachments;
|
|
if (attachments == null) {
|
|
attachments = [];
|
|
}
|
|
let r462 = r204[8];
|
|
if (r462 == null) {
|
|
r462 = [];
|
|
}
|
|
const r463 = r204[5];
|
|
let env31943 = {
|
|
$parent: r34
|
|
};
|
|
env31943[0] = r457;
|
|
env31943[1] = id5;
|
|
env31943[2] = attachments;
|
|
if (attachments.length === r462.length) {
|
|
const channel4 = r34[17].getChannel(r457);
|
|
env31943[3] = channel4;
|
|
if (channel4 != null) {
|
|
env31943[4] = r34[12].getMessageByReference(r463);
|
|
r462.forEach(({ clip }, index) => {
|
|
if (clip != null) {
|
|
const r15 = env31943[4];
|
|
const state = r15.state;
|
|
const r10 = env31943.$parent;
|
|
const is_distributed_clip_reply = state === r10[13].LOADED && r15.message.attachments.some((attachment) => attachment.clip_remote_id === clip.remoteClipId);
|
|
const r21 = r10[1];
|
|
const r9 = r10[3];
|
|
const r24 = r21(r9[37]);
|
|
const CLIP_SHARED = r10[27].CLIP_SHARED;
|
|
const r28 = {};
|
|
const r29 = r10[2];
|
|
HermesBuiltin.copyDataProperties(r28, r29(r9[42]).getClipBaseProperties(clip));
|
|
HermesBuiltin.copyDataProperties(r28, r29(r9[42]).getClipContextProperties("trackClipsShared"));
|
|
r28.channel_id = env31943[0];
|
|
const r40 = env31943[3];
|
|
r28.guild_id = r40.getGuildId();
|
|
r28.channel_type = r40.type;
|
|
r28.application_id = clip.applicationId;
|
|
r28.clip_uuid = clip.id;
|
|
r28.remote_clip_id = clip.remoteClipId;
|
|
r28.message_id = env31943[1];
|
|
r28.attachment_id = env31943[2][index].id;
|
|
r28.is_distributed_clip_reply = is_distributed_clip_reply;
|
|
r24.track(CLIP_SHARED, r28);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
if (r204[15] != null) {
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "UPLOAD_COMPLETE",
|
|
channelId: r206[0],
|
|
file: r204[15]._file,
|
|
aborted: false
|
|
});
|
|
}
|
|
(0, env31382[0])(a0);
|
|
} else {
|
|
r34[49].log("Failed to send message", {
|
|
hasErr: a0.hasErr,
|
|
status: a0.status,
|
|
code: a0.body?.code,
|
|
error: a0.err
|
|
});
|
|
if (a0.hasErr) {
|
|
const code2 = a0.err.code;
|
|
r43 = false;
|
|
reason = void 0;
|
|
if (code2 === "ABORTED") {
|
|
r43 = true;
|
|
reason = void 0;
|
|
}
|
|
} else {
|
|
const r3 = a0.status >= 400;
|
|
r43 = false;
|
|
reason = void 0;
|
|
if (r3) {
|
|
const r46 = a0.status < 500;
|
|
r43 = false;
|
|
reason = void 0;
|
|
if (r46) {
|
|
const body = a0.body;
|
|
r43 = false;
|
|
reason = void 0;
|
|
if (body) {
|
|
const code = a0.body.code;
|
|
const r50 = r34[26];
|
|
if (code === r50.SLOWMODE_RATE_LIMITED) {
|
|
const retry_after = a0.body.retry_after;
|
|
const r102 = retry_after != null && retry_after > 0;
|
|
r43 = false;
|
|
reason = void 0;
|
|
if (r102) {
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "SLOWMODE_SET_COOLDOWN",
|
|
channelId: env31382.$parent.$parent[0],
|
|
slowmodeType: r34[24].SendMessage,
|
|
cooldownMs: retry_after * (0, r34[1])(r34[3][77]).Millis.SECOND
|
|
});
|
|
r43 = false;
|
|
reason = void 0;
|
|
}
|
|
} else if ((0, r34[0])(r34[3][78]).AUTOMOD_ERROR_CODES.has(a0.body.code)) {
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "MESSAGE_SEND_FAILED_AUTOMOD",
|
|
messageData: env31382.$parent[16],
|
|
errorResponseBody: {
|
|
code: a0.body.code,
|
|
message: a0.body.message
|
|
}
|
|
});
|
|
r43 = false;
|
|
reason = void 0;
|
|
} else if (a0.body.code === r50.POGGERMODE_TEMPORARILY_DISABLED) {
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "POGGERMODE_TEMPORARILY_DISABLED"
|
|
});
|
|
r43 = false;
|
|
reason = void 0;
|
|
} else if (a0.body.code === r50.EXPLICIT_CONTENT) {
|
|
reason = r34[46].EXPLICIT_CONTENT;
|
|
r43 = false;
|
|
} else {
|
|
const r67 = env31382.$parent;
|
|
const r69 = r67[6] != null || r67[11] || r67[7] != null;
|
|
r43 = false;
|
|
reason = void 0;
|
|
if (!r69) {
|
|
r34[55].sendClydeError(env31382.$parent.$parent[0], a0.body.code);
|
|
r43 = false;
|
|
reason = void 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const r124 = env31382.$parent;
|
|
if (r43) {
|
|
r34[55].deleteMessage(env31382.$parent.$parent[0], r124[14], true);
|
|
} else {
|
|
if (r124[15] != null) {
|
|
(0, r34[1])(r34[3][46]).dispatch({
|
|
type: "UPLOAD_FAIL",
|
|
channelId: env31382.$parent.$parent[0],
|
|
file: r124[15]._file,
|
|
messageId: r124[14],
|
|
reason,
|
|
noSendFailed: true
|
|
});
|
|
}
|
|
if (!(a0.hasErr || reason !== r34[46].EXPLICIT_CONTENT)) {
|
|
r34[55].sendExplicitMediaClydeError(env31382.$parent.$parent[0], a0.body?.attachments, (0, r34[0])(r34[3][50]).TrackMediaRedactionContext.EXPLICIT_MEDIA_MESSAGE_SEND_BLOCKED);
|
|
}
|
|
const r157 = (0, r34[1])(r34[3][46]);
|
|
const r161 = env31382.$parent.$parent;
|
|
r157.dispatch({
|
|
type: "MESSAGE_SEND_FAILED",
|
|
messageId: r124[14],
|
|
channelId: r161[0],
|
|
shouldNotify: !r161[2].doNotNotifyOnError,
|
|
reason
|
|
});
|
|
(0, r34[0])(r34[3][74]).logMessageSendFailure({
|
|
failureCode: a0.hasErr ? void 0 : a0.status,
|
|
errorMessage: a0.hasErr ? a0.err.message : void 0
|
|
});
|
|
(0, r34[1])(r34[3][72]).cancelPendingSendRequests(r161[0]).forEach($mk118738(r34));
|
|
}
|
|
(0, env31382[1])(a0);
|
|
}
|
|
}, r21);
|
|
};
|
|
}
|
|
function $mk114791($env) {
|
|
return function getAllowedMentionsForMessageEdit(a0, a1) {
|
|
const message = MessageStore.getMessage(a0, a1);
|
|
if (message != null && message.type === MessageTypes.REPLY) {
|
|
const messageByReference = ReferencedMessageStore.getMessageByReference(message.messageReference);
|
|
if (messageByReference.state === ReferencedMessageState.LOADED && !message.mentions.includes(messageByReference.message.author.id)) {
|
|
return {
|
|
parse: Object.values(AllowedMentionTypes),
|
|
replied_user: false
|
|
};
|
|
}
|
|
}
|
|
};
|
|
}
|
|
function $mk114792($env) {
|
|
return function getIsCrosspostedForMessageEdit(a0, a1) {
|
|
const message = MessageStore.getMessage(a0, a1);
|
|
return message != null && message.hasFlag(MessageFlags.CROSSPOSTED);
|
|
};
|
|
}
|
|
function $mk114793($env) {
|
|
return (a0) => {
|
|
const hasErr = a0.hasErr;
|
|
let r8 = !hasErr;
|
|
if (!hasErr) {
|
|
r8 = AUTOMOD_ERROR_CODES.has(a0.body.code);
|
|
}
|
|
if (r8) {
|
|
const r18 = $env;
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_EDIT_FAILED_AUTOMOD",
|
|
messageData: {
|
|
type: MessageDataType.EDIT,
|
|
message: r18[2]
|
|
},
|
|
errorResponseBody: {
|
|
code: a0.body.code,
|
|
message: a0.body.message
|
|
}
|
|
});
|
|
}
|
|
const hasErr2 = a0.hasErr;
|
|
if (hasErr2) {
|
|
AccessibilityAnnouncer.announce(intl.string(t.Atp7FP));
|
|
} else if (r8) {
|
|
AccessibilityAnnouncer.announce(intl.string(t.Hym4ix));
|
|
} else {
|
|
AccessibilityAnnouncer.announce(intl.string(t["0x1HBD"]));
|
|
}
|
|
const r67 = $env.$parent;
|
|
const channelId5 = r67[0];
|
|
c3543_55.endEditMessage(channelId5, a0.hasErr ? void 0 : a0);
|
|
c3543_55.focusMessage({
|
|
channelId: channelId5,
|
|
messageId: r67[1]
|
|
});
|
|
};
|
|
}
|
|
function $mk114795($env) {
|
|
return () => {
|
|
const r1 = $env.$parent;
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_DELETE",
|
|
id,
|
|
channelId: channelId4
|
|
}).then($mk117922(r1));
|
|
};
|
|
}
|
|
function $mk117922($env) {
|
|
return () => {
|
|
AccessibilityAnnouncer.announce(intl.string(t.RYMs7s));
|
|
};
|
|
}
|
|
function $mk118738($env) {
|
|
return (a0) => {
|
|
const r1 = $env;
|
|
r1[49].log("Cancelling pending message", a0.nonce);
|
|
(0, r1[1])(r1[3][46]).dispatch({
|
|
type: "MESSAGE_SEND_FAILED",
|
|
messageId: a0.nonce,
|
|
channelId: a0.channelId
|
|
});
|
|
};
|
|
}
|
|
let MediaPlayerManager, c3543_49, c3543_50, c3543_54, c3543_55;
|
|
let env3543 = {};
|
|
const trackInvite = function trackInvite({ inviteKey, channelId: channelId5, messageId: messageId3, location: location2, inviteAnalyticsMetadata, overrideProperties = {} }) {
|
|
const id2 = AuthenticationStore.getId();
|
|
const invite = InviteStore.getInvite(inviteKey);
|
|
const r29 = parseExtraDataFromInviteKey(inviteKey);
|
|
const r30 = invite != null && isEmbeddedApplicationInvite(invite);
|
|
const r17 = invite == null ? void 0 : invite.target_application?.id;
|
|
if (r17 != null && r30) {
|
|
trackAppEmbedLinkSent(r17, LinkType.ACTIVITY_INVITE, id2);
|
|
}
|
|
const channel = ChannelStore.getChannel(channelId5);
|
|
if (channel != null) {
|
|
const r83 = channel.isMultiUserDM() ? LoggingInviteTypes.GDM_INVITE : channel.isPrivate() ? null : LoggingInviteTypes.SERVER_INVITE;
|
|
const r86 = {};
|
|
let invite_type = r83;
|
|
if (invite != null) {
|
|
const state = invite.state;
|
|
const RESOLVED = InviteStates.RESOLVED;
|
|
invite_type = r83;
|
|
if (state === RESOLVED) {
|
|
const channel2 = invite.channel;
|
|
invite_type = r83;
|
|
if (channel2 != null) {
|
|
const channel3 = invite.channel;
|
|
r86.invite_channel_id = channel3.id;
|
|
r86.invite_guild_id = invite.guild?.id;
|
|
r86.invite_channel_type = channel3.type;
|
|
if (invite.inviter != null) {
|
|
r86.invite_inviter_id = invite.inviter.id;
|
|
}
|
|
if (invite.target_application != null) {
|
|
r86.application_id = invite.target_application.id;
|
|
}
|
|
const lastActiveStream = ApplicationStreamingStore.getLastActiveStream();
|
|
invite_type = r83;
|
|
if (lastActiveStream != null) {
|
|
const channelId6 = lastActiveStream.channelId;
|
|
const id3 = channel3.id;
|
|
invite_type = r83;
|
|
if (channelId6 === id3) {
|
|
const STREAM = LoggingInviteTypes.STREAM;
|
|
r86.destination_user_id = lastActiveStream.ownerId;
|
|
const streamerApplication = getStreamerApplication(lastActiveStream, PresenceStore);
|
|
r86.application_id = streamerApplication != null ? streamerApplication.id : null;
|
|
invite_type = STREAM;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (inviteAnalyticsMetadata != null) {
|
|
if (inviteAnalyticsMetadata.suggestionData != null) {
|
|
r86.is_suggested = inviteAnalyticsMetadata.suggestionData.isAffinitySuggestion;
|
|
r86.row_num = inviteAnalyticsMetadata.suggestionData.rowNum;
|
|
r86.num_total = inviteAnalyticsMetadata.suggestionData.numTotal;
|
|
r86.num_affinity_connections = inviteAnalyticsMetadata.suggestionData.numAffinityConnections;
|
|
r86.is_filtered = inviteAnalyticsMetadata.suggestionData.isFiltered;
|
|
}
|
|
r86.source = inviteAnalyticsMetadata.source;
|
|
}
|
|
const r130 = {
|
|
...r86,
|
|
location: location2,
|
|
invite_type,
|
|
invite_code: r29.baseCode,
|
|
guild_id: channel.getGuildId(),
|
|
channel_id: channel.id,
|
|
message_id: messageId3,
|
|
send_type: SendTypes.DIRECT_MESSAGE,
|
|
invite_guild_scheduled_event_id: r29.guildScheduledEventId
|
|
};
|
|
let invite_instance_id2 = getInviteInstanceId(r29.baseCode, messageId3);
|
|
if (invite_instance_id2 == null) {
|
|
invite_instance_id2 = null;
|
|
}
|
|
r130.invite_instance_id = invite_instance_id2;
|
|
HermesBuiltin.copyDataProperties(r130, overrideProperties);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.INVITE_SENT, r130);
|
|
} else if (invite != null && invite.state === InviteStates.RESOLVED && invite.inviter != null) {
|
|
const r50 = {
|
|
invite_inviter_id: invite.inviter.id
|
|
};
|
|
if (invite.target_application != null) {
|
|
r50.application_id = invite.target_application.id;
|
|
}
|
|
let invite_instance_id = getInviteInstanceId(r29.baseCode, messageId3);
|
|
if (invite_instance_id == null) {
|
|
invite_instance_id = null;
|
|
}
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.INVITE_SENT, {
|
|
...r50,
|
|
location: location2,
|
|
invite_type: LoggingInviteTypes.FRIEND_INVITE,
|
|
invite_code: r29.baseCode,
|
|
message_id: messageId3,
|
|
send_type: SendTypes.DIRECT_MESSAGE,
|
|
invite_guild_scheduled_event_id: r29.guildScheduledEventId,
|
|
invite_instance_id,
|
|
...overrideProperties
|
|
});
|
|
}
|
|
};
|
|
const AbortCodes2 = AbortCodes;
|
|
Permissions;
|
|
MediaPlayerManager = NativeModules.MediaPlayerManager;
|
|
c3543_49 = new Logger("MessageActionCreators");
|
|
c3543_50 = new Logger("MessageQueue");
|
|
env3543[51] = false;
|
|
class RemoteFetch {
|
|
constructor() {
|
|
return {
|
|
__proto__: new.target.prototype,
|
|
completed: false
|
|
};
|
|
}
|
|
markComplete() {
|
|
this.completed = true;
|
|
}
|
|
}
|
|
const r119 = {};
|
|
r119[AbortCodes2.SLOWMODE_RATE_LIMITED] = {
|
|
messageName: "SLOWMODE_RATE_LIMITED",
|
|
messageGetter: (a0) => intl.formatToPlainString(t.IWntYg, {
|
|
seconds: a0.rateLimitPerUser
|
|
})
|
|
};
|
|
r119[AbortCodes2.INVALID_MESSAGE_SEND_NO_MUTUAL_GUILDS] = {
|
|
messageName: "INVALID_MESSAGE_SEND_NO_MUTUAL_GUILDS",
|
|
messageGetter: (a0) => {
|
|
const articleURL = HelpdeskUtils.getArticleURL(HelpdeskArticles.DM_COULD_NOT_BE_DELIVERED);
|
|
let rawRecipients = a0.rawRecipients;
|
|
if (rawRecipients == null) {
|
|
rawRecipients = [];
|
|
}
|
|
return a0.isDM() && (rawRecipients.length === 1 && rawRecipients.some((rawRecipient) => rawRecipient.bot)) ? intl.formatToPlainString(t.SkGL7l, {
|
|
helpUrl: articleURL
|
|
}) : intl.formatToPlainString(t.llTkqr, {
|
|
helpUrl: articleURL
|
|
});
|
|
}
|
|
};
|
|
r119[AbortCodes2.INVALID_MESSAGE_SEND_USER] = {
|
|
messageName: "INVALID_MESSAGE_SEND_USER",
|
|
messageGetter: () => intl.formatToPlainString(t.SkGL7l, {
|
|
helpUrl: HelpdeskUtils.getArticleURL(HelpdeskArticles.DM_COULD_NOT_BE_DELIVERED)
|
|
})
|
|
};
|
|
r119[AbortCodes2.TOO_MANY_THREADS] = {
|
|
messageName: "TOO_MANY_THREADS",
|
|
messageGetter: (a0) => !a0.isForumLikeChannel() && !a0.isForumPost() ? intl.string(t["5EMPA7"]) : intl.string(t["/jUd2+"])
|
|
};
|
|
r119[AbortCodes2.TOO_MANY_ANNOUNCEMENT_THREADS] = {
|
|
messageName: "TOO_MANY_ANNOUNCEMENT_THREADS",
|
|
messageGetter: () => intl.string(t["aY+lLC"])
|
|
};
|
|
r119[AbortCodes2.HARMFUL_LINK_MESSAGE_BLOCKED] = {
|
|
messageName: "HARMFUL_LINK_MESSAGE_BLOCKED",
|
|
messageGetter: () => intl.formatToPlainString(t.zSG3Qy, {
|
|
helpUrl: MarketingURLs.HARMFUL_LINKS
|
|
})
|
|
};
|
|
r119[AbortCodes2.HARMFUL_URL_BLOCKED] = {
|
|
messageName: "HARMFUL_URL_BLOCKED",
|
|
messageGetter: () => intl.string(t.WxX2Fd)
|
|
};
|
|
r119[AbortCodes2.EMAIL_VERIFICATION_REQUIRED] = {
|
|
messageName: "BOT_REQUIRES_EMAIL_VERIFICATION",
|
|
messageGetter: () => intl.string(t.k1Cjqr)
|
|
};
|
|
r119[AbortCodes2.GUILD_MESSAGE_UPDATE_RATE_LIMIT_EXCEEDED] = {
|
|
messageName: "GUILD_MESSAGE_UPDATE_RATE_LIMIT_EXCEEDED",
|
|
messageGetter: () => intl.string(t.Z5SUuv)
|
|
};
|
|
r119[AbortCodes2.RATE_LIMIT_DM_OPEN] = {
|
|
messageName: "BOT_DM_RATE_LIMITED",
|
|
messageGetter: () => intl.string(t.E8nbNb)
|
|
};
|
|
r119[AbortCodes2.SEND_MESSAGE_TEMPORARILY_DISABLED] = {
|
|
messageName: "BOT_DM_SEND_MESSAGE_TEMPORARILY_DISABLED",
|
|
messageGetter: () => intl.string(t.aRUbah)
|
|
};
|
|
r119[AbortCodes2.INVALID_MESSAGE_SEND_GAME_FRIEND_DM] = {
|
|
messageName: "BOT_DM_SEND_MESSAGE_INVALID_FOR_GAME_FRIEND",
|
|
messageGetter: () => intl.string(t["/meGhR"])
|
|
};
|
|
r119[AbortCodes2.INVALID_MESSAGE_SEND_PROVISIONAL_ACCOUNT_OFFLINE] = {
|
|
messageName: "BOT_DM_SEND_MESSAGE_INVALID_OFFLINE_PROVISIONAL_ACCOUNT",
|
|
messageGetter: () => intl.string(t.Oc1Zjw)
|
|
};
|
|
r119[AbortCodes2.TOTAL_ATTACHMENT_SIZE_TOO_LARGE] = {
|
|
messageName: "TOTAL_ATTACHMENT_SIZE_TOO_LARGE",
|
|
messageGetter: () => intl.formatToPlainString(t.DYFPg2, {
|
|
maxSizeMb: MAX_TOTAL_ATTACHMENT_SIZE_MB
|
|
})
|
|
};
|
|
r119[AbortCodes2.CLOUD_UPLOAD_NOT_FOUND] = {
|
|
messageName: "CLOUD_UPLOAD_NOT_FOUND",
|
|
messageGetter: () => intl.string(t.bQldfH)
|
|
};
|
|
r119[AbortCodes2.INVALID_PERMISSIONS] = {
|
|
messageName: "INVALID_PERMISSIONS",
|
|
messageGetter: () => intl.string(t.zl4Weq)
|
|
};
|
|
c3543_54 = r119;
|
|
c3543_55 = {
|
|
receiveMessage: function receiveMessage(a0, a1, optimistic = false, sendMessageOptions = {}) {
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_CREATE",
|
|
channelId: a0,
|
|
message: a1,
|
|
optimistic,
|
|
sendMessageOptions,
|
|
isPushNotification: false
|
|
});
|
|
},
|
|
sendBotMessage: (a0, a1, a2, a3) => {
|
|
if (a2 != null) {
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.AUTOMATED_MESSAGE_RECEIVED, {
|
|
message_author: "Clyde",
|
|
message_name: a2
|
|
});
|
|
}
|
|
c3543_55.receiveMessage(a0, createBotMessage({
|
|
messageId: a3,
|
|
channelId: a0,
|
|
content: a1,
|
|
loggingName: a2
|
|
}));
|
|
},
|
|
sendNitroSystemMessage: (a0, a1, a2) => {
|
|
c3543_55.receiveMessage(a0, {
|
|
...createMessage({
|
|
channelId: a0,
|
|
nonce: a2,
|
|
type: MessageTypes.NITRO_NOTIFICATION,
|
|
content: a1,
|
|
flags: MessageFlags.EPHEMERAL,
|
|
author: {
|
|
id: LOCAL_BOT_ID,
|
|
username: "Nitro Notification",
|
|
discriminator: NON_USER_BOT_DISCRIMINATOR,
|
|
avatar: "nitro",
|
|
bot: true
|
|
}
|
|
}),
|
|
state: MessageStates.SENT,
|
|
channel_id: a0
|
|
}, true);
|
|
},
|
|
sendGiftingPromptSystemMessage: (a0, a1) => {
|
|
c3543_55.receiveMessage(a0, {
|
|
...createMessage({
|
|
channelId: a0,
|
|
type: MessageTypes.GIFTING_PROMPT,
|
|
content: "",
|
|
flags: MessageFlags.EPHEMERAL,
|
|
author: {
|
|
id: LOCAL_BOT_ID,
|
|
username: "Gifting Prompt",
|
|
discriminator: NON_USER_BOT_DISCRIMINATOR,
|
|
avatar: "gifting_prompt",
|
|
bot: true
|
|
},
|
|
giftingPrompt: a1
|
|
}),
|
|
state: MessageStates.SENT
|
|
}, true);
|
|
},
|
|
sendGuildBoostUpsellSystemMessage: (a0, a1) => {
|
|
c3543_55.receiveMessage(a0, {
|
|
...createMessage({
|
|
channelId: a0,
|
|
type: MessageTypes.GUILD_BOOST_UPSELL,
|
|
content: "",
|
|
flags: MessageFlags.EPHEMERAL,
|
|
author: {
|
|
id: LOCAL_BOT_ID,
|
|
username: "Guild Boost Upsell",
|
|
discriminator: NON_USER_BOT_DISCRIMINATOR,
|
|
avatar: "guild_boost_upsell",
|
|
bot: true
|
|
},
|
|
boostingPrompt: a1
|
|
}),
|
|
state: MessageStates.SENT
|
|
}, true);
|
|
},
|
|
sendClydeError: function sendClydeError(a0, r13 = 0) {
|
|
const channel = ChannelStore.getChannel(a0);
|
|
if (channel != null) {
|
|
const r18 = c3543_54[r13];
|
|
if (r18 != null) {
|
|
c3543_55.sendBotMessage(a0, r18.messageGetter(channel), r18.messageName);
|
|
} else {
|
|
c3543_55.sendBotMessage(a0, intl.formatToPlainString(t.SkGL7l, {
|
|
helpUrl: HelpdeskUtils.getArticleURL(HelpdeskArticles.DM_COULD_NOT_BE_DELIVERED)
|
|
}), `SEND_FAILED (${r13})`);
|
|
}
|
|
}
|
|
},
|
|
sendExplicitMediaClydeError: (a0, a1, a2) => {
|
|
const channel = ChannelStore.getChannel(a0);
|
|
if (channel != null) {
|
|
const r37 = match({
|
|
isDM: channel.isDM(),
|
|
isGDM: channel.isGroupDM()
|
|
}).with({
|
|
isDM: true
|
|
}, () => ({
|
|
message: intl.string(t["mktny/"]),
|
|
messageName: "BOT_DM_EXPLICIT_CONTENT"
|
|
})).with({
|
|
isDM: false,
|
|
isGDM: true
|
|
}, () => ({
|
|
message: intl.string(t["mktny/"]),
|
|
messageName: "BOT_GDM_EXPLICIT_CONTENT"
|
|
})).otherwise(() => ({
|
|
message: intl.string(t.i4AbAS),
|
|
messageName: "BOT_GUILD_EXPLICIT_CONTENT"
|
|
}));
|
|
const { message, messageName } = r37;
|
|
const nonce3 = createNonce();
|
|
c3543_55.sendBotMessage(a0, message, messageName, nonce3);
|
|
trackMediaRedactionAction({
|
|
action: TrackMediaRedactionActionType.EXPLICIT_MEDIA_FALSE_POSITIVE_CLYDE_MESSAGE_SENT,
|
|
messageId: nonce3,
|
|
channelId: a0,
|
|
context: a2
|
|
});
|
|
if (a1 != null && a1.length > 0) {
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_EXPLICIT_CONTENT_FP_CREATE",
|
|
messageId: nonce3,
|
|
channelId: a0,
|
|
attachments: a1
|
|
});
|
|
}
|
|
}
|
|
},
|
|
truncateMessages: (a0, a1, a2) => {
|
|
Dispatcher.dispatch({
|
|
type: "TRUNCATE_MESSAGES",
|
|
channelId: a0,
|
|
truncateBottom: a1,
|
|
truncateTop: a2
|
|
});
|
|
},
|
|
clearChannel: (a0) => {
|
|
Dispatcher.dispatch({
|
|
type: "CLEAR_MESSAGES",
|
|
channelId: a0
|
|
});
|
|
},
|
|
jumpToPresent: (a0, a1) => {
|
|
c3543_55.trackJump(a0, null, "Present");
|
|
const jump2 = {
|
|
present: true
|
|
};
|
|
if (MessageStore.hasPresent(a0)) {
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES_SUCCESS_CACHED",
|
|
jump: jump2,
|
|
channelId: a0,
|
|
limit: a1
|
|
});
|
|
} else {
|
|
c3543_55.fetchMessages({
|
|
channelId: a0,
|
|
limit: a1,
|
|
jump: jump2
|
|
});
|
|
}
|
|
},
|
|
trackJump: (a0, a1, a2, a3) => {
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.JUMP, {
|
|
context: a2,
|
|
channel_id: a0,
|
|
message_id: a1,
|
|
...a3
|
|
});
|
|
},
|
|
jumpToMessage: ({ channelId: channelId5, messageId: messageId3, flash = false, offset, context, extraProperties = null, isPreload, returnMessageId, skipLocalFetch, jumpType, avoidInitialScroll: avoidInitialScroll2, onJumpComplete }) => {
|
|
if (typeof context === "string") {
|
|
c3543_55.trackJump(channelId5, messageId3, context, extraProperties);
|
|
}
|
|
if (MediaPlayerManager != null) {
|
|
const pauseAllMediaPlayers = MediaPlayerManager.pauseAllMediaPlayers;
|
|
if (pauseAllMediaPlayers != null) {
|
|
pauseAllMediaPlayers.call(MediaPlayerManager);
|
|
}
|
|
}
|
|
return c3543_55.fetchMessages({
|
|
channelId: channelId5,
|
|
limit: MAX_MESSAGES_FOR_JUMP,
|
|
jump: {
|
|
messageId: messageId3,
|
|
flash,
|
|
offset,
|
|
returnMessageId,
|
|
jumpType,
|
|
onJumpComplete
|
|
},
|
|
isPreload,
|
|
skipLocalFetch,
|
|
avoidInitialScroll: avoidInitialScroll2
|
|
});
|
|
},
|
|
focusMessage: (a0) => {
|
|
c3543_55.fetchMessages({
|
|
channelId: a0.channelId,
|
|
limit: MAX_MESSAGES_FOR_JUMP,
|
|
focus: {
|
|
messageId: a0.messageId
|
|
}
|
|
});
|
|
},
|
|
fetchMessage: async ({ channelId, messageId }) => {
|
|
let messageRecord;
|
|
let c25563_1;
|
|
let c29576_0;
|
|
L12: {
|
|
c25563_1 = void 0;
|
|
c29576_0 = void 0;
|
|
c29576_0 = await HTTP.get({
|
|
url: Endpoints.MESSAGES(channelId),
|
|
query: {
|
|
limit: 1,
|
|
around: messageId
|
|
},
|
|
retries: 2,
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
if (c29576_0.body.length > 0) {
|
|
messageRecord = createMessageRecord(c29576_0.body[0]);
|
|
break L12;
|
|
}
|
|
return void 0;
|
|
}
|
|
return messageRecord;
|
|
},
|
|
fetchMessages: function fetchMessages(a0) {
|
|
let messageId2, c15046_12;
|
|
const { channelId: channelId2, before, after, limit } = a0;
|
|
let jump2 = a0.jump;
|
|
const jump = jump2;
|
|
const { focus, isPreload, skipLocalFetch, truncate, forICYMI, avoidInitialScroll, feature } = a0;
|
|
let fetchKey2 = a0.fetchKey;
|
|
const fetchKey = fetchKey2;
|
|
messageId2 = void 0;
|
|
c15046_12 = void 0;
|
|
const channel = ChannelStore.getChannel(channelId2);
|
|
const isConnectedOrOverlay = GatewayConnectionStore.isConnectedOrOverlay();
|
|
const r19 = Date.now();
|
|
let c15046_10 = r19;
|
|
if (channel != null && channel.type === ChannelTypes.GUILD_STORE) {
|
|
return false;
|
|
}
|
|
if (channelId2 !== FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID) {
|
|
c3543_49.log(`Fetching messages for ${channelId2} between ${after} and ${before}. jump=${JSON.stringify(jump)}`);
|
|
if (!c3543_55._tryFetchMessagesCached({
|
|
channelId: channelId2,
|
|
before,
|
|
after,
|
|
limit,
|
|
jump,
|
|
focus,
|
|
truncate
|
|
})) {
|
|
TTITracker.fetchMessages.recordStart();
|
|
MessageCacheStats.recordChannelFetchStart(channelId2, fetchKey == null ? r19 : fetchKey, before, after, limit);
|
|
if (jump == null) {
|
|
jump2 = void 0;
|
|
}
|
|
if (jump2 == null && focus != null) {
|
|
jump2 = {
|
|
...focus
|
|
};
|
|
}
|
|
ChannelMessages.commit(ChannelMessages.getOrCreate(channelId2).loadStart(jump2));
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES"
|
|
});
|
|
messageId2 = jump2?.messageId;
|
|
const r103 = {
|
|
__proto__: RemoteFetch.prototype,
|
|
completed: false
|
|
};
|
|
c15046_12 = r103;
|
|
if (!skipLocalFetch) {
|
|
const fetchLocalMessages2 = this.fetchLocalMessages;
|
|
if (fetchKey == null) {
|
|
fetchKey2 = r19;
|
|
}
|
|
fetchLocalMessages2.call(this, channelId2, fetchKey2, before, after, limit, r103);
|
|
}
|
|
return HTTP.get({
|
|
url: Endpoints.MESSAGES(channelId2),
|
|
query: {
|
|
before,
|
|
after,
|
|
limit,
|
|
around: messageId2,
|
|
preload: isPreload,
|
|
feature
|
|
},
|
|
retries: 2,
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then((c25564_0) => {
|
|
TTITracker.fetchMessages.recordEnd();
|
|
TTITracker.dispatchMessages.measure(() => {
|
|
const body = c25564_0.body;
|
|
const isBefore = before != null;
|
|
const isAfter = after != null;
|
|
let r5 = messageId2 != null || body.length === limit && (isBefore || before == null && after == null);
|
|
let r35 = messageId2 != null || isAfter && body.length === limit;
|
|
let hasMoreAfter = r35;
|
|
let hasMoreBefore = r5;
|
|
if (messageId2 != null) {
|
|
const r44 = Math.floor(limit / 2);
|
|
const r57 = [messageId2, ...body.map((item) => item.id)].filter((item, index, a2) => a2.indexOf(item) === index).sort(SnowflakeUtils.compare).indexOf(messageId2);
|
|
if (r57 < r44 + limit % 2 - 1) {
|
|
r5 = false;
|
|
}
|
|
if (body.length - r57 < r44) {
|
|
r35 = false;
|
|
}
|
|
hasMoreAfter = r35;
|
|
hasMoreBefore = r5;
|
|
if (r35) {
|
|
const length = body.length;
|
|
hasMoreAfter = r35;
|
|
hasMoreBefore = r5;
|
|
if (length > 0) {
|
|
const r68 = ReadStateStore.lastMessageId(channelId2);
|
|
const id2 = body[0].id;
|
|
hasMoreAfter = r35;
|
|
hasMoreBefore = r5;
|
|
if (id2 === r68) {
|
|
hasMoreAfter = false;
|
|
hasMoreBefore = r5;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
c3543_49.log(`Fetched ${body.length} messages for ${channelId2} isBefore:${isBefore} isAfter:${isAfter}`);
|
|
c15046_12.markComplete();
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES_SUCCESS",
|
|
channelId: channelId2,
|
|
messages: body,
|
|
isBefore,
|
|
isAfter,
|
|
hasMoreBefore,
|
|
hasMoreAfter,
|
|
limit,
|
|
jump,
|
|
forICYMI,
|
|
isStale: isConnectedOrOverlay ? GatewayConnectionStore.lastTimeConnectedChanged() >= c15046_10 : !isConnectedOrOverlay,
|
|
truncate,
|
|
avoidInitialScroll
|
|
});
|
|
let r109 = fetchKey;
|
|
if (fetchKey == null) {
|
|
r109 = c15046_10;
|
|
}
|
|
MessageCacheStats.recordChannelFetchedNetwork(channelId2, r109, before, after, limit, body);
|
|
});
|
|
return true;
|
|
}, () => {
|
|
c3543_49.log(`Failed to fetch messages for ${channelId2}`);
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES_FAILURE",
|
|
channelId: channelId2
|
|
});
|
|
return false;
|
|
});
|
|
}
|
|
}
|
|
},
|
|
fetchLocalMessages: async (a0, a1, a2, a3, a4, a5) => {
|
|
let env15047 = {
|
|
$parent: env3543
|
|
};
|
|
env15047[0] = a0;
|
|
env15047[1] = a1;
|
|
env15047[2] = a2;
|
|
env15047[3] = a3;
|
|
env15047[4] = a4;
|
|
env15047[5] = a5;
|
|
let c25565_0, c25565_1;
|
|
L16: {
|
|
L22: {
|
|
let env29577;
|
|
const r11 = env15047;
|
|
c25565_1 = r11;
|
|
const r38 = env29577 = {
|
|
$parent: r11
|
|
};
|
|
c25565_0 = r38;
|
|
env29577[0] = void 0;
|
|
env29577[1] = void 0;
|
|
env29577[2] = void 0;
|
|
env29577[3] = void 0;
|
|
const basicChannel = ChannelStore.getBasicChannel(env15047[0]);
|
|
env29577[0] = basicChannel;
|
|
const orCreate = ChannelMessages.getOrCreate(env15047[0]);
|
|
const r51 = DatabaseDaos.database();
|
|
env29577[1] = r51;
|
|
if (r51 != null && basicChannel != null && env15047[2] == null && env15047[3] == null) {
|
|
if (orCreate.ready && !orCreate.cached) {
|
|
TTITracker.addLocalMessages(env15047[0], -2);
|
|
break L16;
|
|
}
|
|
env29577[2] = await tryLoadAsync(() => Messages.load(env29577[1], env15047[0], env15047[4]));
|
|
if (env29577[2] != null) {
|
|
const length = env29577[2].messages.length;
|
|
const r26 = env15047[0];
|
|
const r103 = env15047[5];
|
|
c3543_49.log(`fetched ${length} messages from local database (channel_id: ${r26}, remote_fetch_completed: ${r103.completed})`);
|
|
TTITracker.addLocalMessages(env15047[0], env29577[2].messages.length);
|
|
if (r103.completed) {
|
|
break L22;
|
|
}
|
|
if (!(env29577[2].messages.length > 0)) {
|
|
break L22;
|
|
}
|
|
env29577[3] = env29577[2].messages.length >= env15047[4] && env29577[2].connectionId === GatewayConnectionStore.lastTimeConnectedChanged();
|
|
MessageCacheStats.recordChannelFetchedLocal(env15047[0], env15047[1], env15047[2], env15047[3], env15047[4], env29577[2].messages);
|
|
Dispatcher.dispatch({
|
|
type: "LOCAL_MESSAGES_LOADED",
|
|
guildId: env29577[0].guild_id,
|
|
channelId: env15047[0],
|
|
users: env29577[2].users,
|
|
members: env29577[2].members,
|
|
messages: env29577[2].messages,
|
|
stale: !env29577[3]
|
|
});
|
|
break L22;
|
|
}
|
|
TTITracker.addLocalMessages(env15047[0], -3);
|
|
break L22;
|
|
}
|
|
TTITracker.addLocalMessages(env15047[0], -1);
|
|
break L16;
|
|
}
|
|
return void 0;
|
|
}
|
|
},
|
|
fetchNewLocalMessages: async (a0, a1) => {
|
|
let env15048 = {
|
|
$parent: env3543
|
|
};
|
|
env15048[0] = a0;
|
|
env15048[1] = a1;
|
|
let c25566_0, c25566_1;
|
|
L22: {
|
|
L21: {
|
|
let env29578;
|
|
const r11 = env15048;
|
|
c25566_1 = r11;
|
|
const r32 = env29578 = {
|
|
$parent: r11
|
|
};
|
|
c25566_0 = r32;
|
|
env29578[0] = void 0;
|
|
env29578[1] = void 0;
|
|
env29578[2] = void 0;
|
|
env29578[3] = void 0;
|
|
env29578[4] = void 0;
|
|
env29578[5] = void 0;
|
|
const basicChannel = ChannelStore.getBasicChannel(env15048[0]);
|
|
env29578[0] = basicChannel;
|
|
const r39 = DatabaseDaos.database();
|
|
env29578[1] = r39;
|
|
if (r39 == null) {
|
|
break L22;
|
|
}
|
|
if (basicChannel == null) {
|
|
break L22;
|
|
}
|
|
env29578[2] = ChannelMessages.getOrCreate(env15048[0]);
|
|
if (env29578[2].hasMoreAfter) {
|
|
break L22;
|
|
}
|
|
env29578[3] = await tryLoadAsync(() => Messages.load(env29578[1], env15048[0], env15048[1]));
|
|
if (env29578[3] == null) {
|
|
break L21;
|
|
}
|
|
env29578[2] = ChannelMessages.getOrCreate(env15048[0]);
|
|
env29578[4] = env29578[2].last()?.id;
|
|
env29578[5] = env29578[4] == null ? env29578[3].messages : env29578[3].messages.filter($mk114782(c25566_0));
|
|
c3543_49.log(`Fetched ${env29578[3].messages.length} messages from the cache after foregrounding. ${env29578[5].length} are new`);
|
|
if (env29578[5].length === 0) {
|
|
break L21;
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "LOCAL_MESSAGES_LOADED",
|
|
guildId: env29578[0].guild_id,
|
|
channelId: env15048[0],
|
|
users: env29578[3].users,
|
|
members: env29578[3].members,
|
|
messages: env29578[5],
|
|
stale: true,
|
|
isForegroundCacheLoad: isIOSPushNotificationRawPayloadFixExperimentEnabled()
|
|
});
|
|
}
|
|
return void 0;
|
|
}
|
|
},
|
|
_tryFetchMessagesCached: ({ channelId: channelId5, before: before2, after: after2, limit: limit2, jump: jump2, focus, truncate: truncate2 }) => {
|
|
let r31;
|
|
const messages = MessageStore.getMessages(channelId5);
|
|
if (!messages.cached && messages.ready) {
|
|
if (jump2?.messageId == null && focus?.messageId == null) {
|
|
if (before2 != null && messages.hasBeforeCached(before2)) {
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES_SUCCESS_CACHED",
|
|
channelId: channelId5,
|
|
before: before2,
|
|
limit: limit2,
|
|
truncate: truncate2
|
|
});
|
|
r31 = true;
|
|
} else {
|
|
const r1 = after2 == null || !messages.hasAfterCached(after2);
|
|
r31 = !r1;
|
|
if (!r1) {
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES_SUCCESS_CACHED",
|
|
channelId: channelId5,
|
|
after: after2,
|
|
limit: limit2,
|
|
truncate: truncate2
|
|
});
|
|
r31 = true;
|
|
}
|
|
}
|
|
return r31;
|
|
}
|
|
if (jump2?.messageId != null && messages.has(jump2.messageId, false)) {
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES_SUCCESS_CACHED",
|
|
channelId: channelId5,
|
|
jump: jump2,
|
|
limit: limit2,
|
|
truncate: truncate2
|
|
});
|
|
return true;
|
|
}
|
|
const messageId3 = focus?.messageId;
|
|
let jump3 = jump2;
|
|
if (messageId3 != null) {
|
|
if (messages.has(focus.messageId, false)) {
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES_SUCCESS_CACHED",
|
|
channelId: channelId5,
|
|
focus,
|
|
limit: limit2,
|
|
truncate: truncate2
|
|
});
|
|
return true;
|
|
}
|
|
jump3 = {
|
|
...focus
|
|
};
|
|
}
|
|
const r63 = jump3?.messageId != null ? SnowflakeUtils.extractTimestamp(jump3?.messageId) : 0;
|
|
const r72 = messages.first();
|
|
const r74 = messages.last();
|
|
const hasMoreBefore = messages.hasMoreBefore;
|
|
let r76 = (hasMoreBefore ? !hasMoreBefore : r72 != null) && SnowflakeUtils.extractTimestamp(r72.id) >= r63;
|
|
if (!r76) {
|
|
const hasMoreAfter = messages.hasMoreAfter;
|
|
r76 = (hasMoreAfter ? !hasMoreAfter : r74 != null) && SnowflakeUtils.extractTimestamp(r74.id) <= r63;
|
|
}
|
|
if (!r76) {
|
|
r76 = r72 != null && r74 != null && SnowflakeUtils.extractTimestamp(r72.id) < r63 && SnowflakeUtils.extractTimestamp(r74.id) > r63;
|
|
}
|
|
if (r76) {
|
|
Dispatcher.dispatch({
|
|
type: "LOAD_MESSAGES_SUCCESS_CACHED",
|
|
channelId: channelId5,
|
|
jump: jump3,
|
|
limit: MAX_MESSAGES_FOR_JUMP
|
|
});
|
|
r76 = true;
|
|
}
|
|
return r76;
|
|
}
|
|
return false;
|
|
},
|
|
sendMessage: async function sendMessage(a0, a1) {
|
|
let r41, r69, r111;
|
|
let env15049 = {
|
|
$parent: env3543
|
|
};
|
|
env15049[0] = a0;
|
|
env15049[1] = a1;
|
|
let r4 = arguments[2];
|
|
if (r4 === void 0) {
|
|
r4 = true;
|
|
}
|
|
env15049[2] = r4;
|
|
env15049[3] = arguments[3];
|
|
let nonce, c25567_1, c25567_2;
|
|
L24: {
|
|
L23: {
|
|
L22: {
|
|
let env29579;
|
|
const r35 = env15049;
|
|
c25567_2 = r35;
|
|
const r14 = env29579 = {
|
|
$parent: r35
|
|
};
|
|
c25567_1 = r14;
|
|
env29579[0] = void 0;
|
|
env29579[1] = void 0;
|
|
env29579[2] = void 0;
|
|
if (env15049[1].reaction) {
|
|
r41 = Promise.resolve();
|
|
break L24;
|
|
}
|
|
env29579[0] = await maybeConvertPrivateChannel(env15049[0]);
|
|
if (env29579[0] != null) {
|
|
r69 = c3543_55.sendMessage(env29579[0], env15049[1], env15049[2], env15049[3]);
|
|
break L23;
|
|
}
|
|
nonce = env15049[3].nonce;
|
|
if (nonce == null) {
|
|
nonce = createNonce();
|
|
}
|
|
env29579[1] = nonce;
|
|
env15049[3] = {
|
|
...env15049[3],
|
|
nonce: env29579[1]
|
|
};
|
|
env29579[2] = BackgroundTaskManager_native.backgroundify($mk114783(env15049), void 0);
|
|
MessageRoundtripTrackerStore.recordMessageSendAttempt(env15049[0], env29579[1], env15049[3]);
|
|
if (MessageStore.isReady(env15049[0])) {
|
|
r111 = (0, env29579[2])();
|
|
} else {
|
|
if (env15049[2]) {
|
|
if (env15049[0] !== FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID) {
|
|
const r123 = c25567_1;
|
|
c3543_50.info(`Waiting for channel ${env15049[0]} to be ready before sending.`);
|
|
r111 = new Promise($mk114784(r123));
|
|
break L22;
|
|
}
|
|
}
|
|
r111 = (0, env29579[2])();
|
|
}
|
|
}
|
|
return r111;
|
|
}
|
|
return r69;
|
|
}
|
|
return r41;
|
|
},
|
|
getSendMessageOptionsForReply: (a0) => {
|
|
let r13;
|
|
if (a0 == null) {
|
|
r13 = {};
|
|
} else {
|
|
let guild_id = a0.channel.getGuildId();
|
|
if (guild_id == null) {
|
|
guild_id = void 0;
|
|
}
|
|
r13 = {
|
|
messageReference: {
|
|
guild_id,
|
|
channel_id: a0.channel.id,
|
|
message_id: a0.message.id
|
|
},
|
|
allowedMentions: a0.shouldMention ? void 0 : {
|
|
parse: Object.values(AllowedMentionTypes),
|
|
replied_user: false
|
|
},
|
|
mediaMention: a0.mediaMention
|
|
};
|
|
}
|
|
return r13;
|
|
},
|
|
getSendMessageOptionsForStickers: ({ isGif, stickers }) => stickers != null && (stickers.length !== 0 && !isGif) ? {
|
|
stickerIds: stickers
|
|
} : {},
|
|
getSendMessageOptionsForScheduledMessage: ({ scheduledTimestamp }) => scheduledTimestamp == null ? {} : {
|
|
scheduledTimestamp
|
|
},
|
|
getSendMessageOptionsForAlsoForwardToChannel: (a0) => ({
|
|
alsoForwardToChannelId: a0.alsoForwardToChannelId
|
|
}),
|
|
getSendMessageOptions: (a0) => {
|
|
const r0 = {};
|
|
HermesBuiltin.copyDataProperties(r0, c3543_55.getSendMessageOptionsForReply(a0.pendingReply));
|
|
HermesBuiltin.copyDataProperties(r0, c3543_55.getSendMessageOptionsForStickers({
|
|
...a0
|
|
}));
|
|
HermesBuiltin.copyDataProperties(r0, c3543_55.getSendMessageOptionsForScheduledMessage({
|
|
...a0
|
|
}));
|
|
HermesBuiltin.copyDataProperties(r0, c3543_55.getSendMessageOptionsForAlsoForwardToChannel({
|
|
...a0
|
|
}));
|
|
return r0;
|
|
},
|
|
sendInvite: (a0, a1, a2, a3, a4) => {
|
|
const inviteURL = getInviteURL(a1);
|
|
return c3543_55._sendMessage(a0, {
|
|
content: a4 != null ? `${a4}
|
|
${inviteURL}` : inviteURL,
|
|
tts: false,
|
|
validNonShortcutEmojis: [],
|
|
invalidEmojis: []
|
|
}, {
|
|
location: a2,
|
|
inviteAnalyticsMetadata: a3
|
|
});
|
|
},
|
|
sendActivityBookmark: (a0, a1, a2, a3) => c3543_55._sendMessage(a0, {
|
|
content: a1,
|
|
tts: false,
|
|
validNonShortcutEmojis: [],
|
|
invalidEmojis: []
|
|
}, {
|
|
location: a2,
|
|
inviteAnalyticsMetadata: a3
|
|
}),
|
|
sendStickers: function sendStickers(a0, a1, content = "") {
|
|
let r5;
|
|
let tts2 = arguments[4];
|
|
if (tts2 === void 0) {
|
|
tts2 = false;
|
|
}
|
|
if (typeof content === "string") {
|
|
r5 = {
|
|
content,
|
|
invalidEmojis: [],
|
|
validNonShortcutEmojis: [],
|
|
tts: tts2
|
|
};
|
|
} else {
|
|
let tts = content.tts;
|
|
if (tts == null) {
|
|
tts = tts2;
|
|
}
|
|
r5 = {
|
|
...content,
|
|
tts
|
|
};
|
|
}
|
|
return c3543_55._sendMessage(a0, r5, {
|
|
...arguments[3],
|
|
stickerIds: a1
|
|
});
|
|
},
|
|
sendGreetMessage: function sendGreetMessage(a0, a1) {
|
|
const channelId3 = a0;
|
|
let r2 = arguments[2];
|
|
if (r2 === void 0) {
|
|
r2 = {};
|
|
}
|
|
const { messageReference, allowedMentions } = r2;
|
|
return HTTP.post({
|
|
url: Endpoints.MESSAGES_GREET(a0),
|
|
body: {
|
|
sticker_ids: [a1],
|
|
allowed_mentions: allowedMentions,
|
|
message_reference: messageReference
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError(),
|
|
context: {
|
|
location: MessageSendLocation.GREET
|
|
}
|
|
}).then((result) => {
|
|
SentMessageIntentsHandler_android.donateSentMessage(result.body.content, channelId3);
|
|
c3543_55.receiveMessage(channelId3, result.body);
|
|
Dispatcher.dispatch({
|
|
type: "STICKER_TRACK_USAGE",
|
|
stickerIds: [a1]
|
|
});
|
|
return result;
|
|
}, (a0) => {
|
|
c3543_49.log("Failed to send greeting");
|
|
if (a0.status !== 429) {
|
|
c3543_55.sendClydeError(channelId3, a0.body.code);
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_SEND_FAILED",
|
|
messageId: a0.body.id,
|
|
channelId: channelId3
|
|
});
|
|
throw a0;
|
|
});
|
|
},
|
|
sendPollMessage: function sendPollMessage(a0, a1, r8 = {}) {
|
|
return c3543_55._sendMessage(a0, {
|
|
content: "",
|
|
tts: false,
|
|
validNonShortcutEmojis: [],
|
|
invalidEmojis: []
|
|
}, {
|
|
...r8,
|
|
poll: a1,
|
|
location: MessageSendLocation.POLL_CREATION
|
|
});
|
|
},
|
|
validateMessage: (a0, a1, a2) => {
|
|
let errorMessage, errorMessageName;
|
|
L4: {
|
|
if (a0.some((item) => item.animated)) {
|
|
if (!PremiumUtils.canUseAnimatedEmojis(a1)) {
|
|
errorMessage = intl.string(t["V5/GgC"]);
|
|
errorMessageName = "INVALID_ANIMATED_EMOJI_BODY";
|
|
break L4;
|
|
}
|
|
}
|
|
errorMessage = intl.string(t["Q87rI/"]);
|
|
errorMessageName = "INVALID_EXTERNAL_EMOJI_BODY";
|
|
}
|
|
return {
|
|
errorMessage,
|
|
errorMessageName
|
|
};
|
|
},
|
|
_sendMessage: async (a0, a1, a2) => {
|
|
let r68, r123, promise, promise2;
|
|
let env15051 = {
|
|
$parent: env3543
|
|
};
|
|
env15051[0] = a0;
|
|
env15051[1] = a1;
|
|
env15051[2] = a2;
|
|
let flags, nonce2, publish, c25568_3, c25568_4, c25568_5;
|
|
let c25568_6 = 0;
|
|
const r11 = env15051;
|
|
L113: {
|
|
L112: {
|
|
L111: {
|
|
L110: {
|
|
L106: {
|
|
L37: {
|
|
try {
|
|
let env29580;
|
|
c25568_4 = r11;
|
|
const r38 = env29580 = {
|
|
$parent: r11
|
|
};
|
|
c25568_3 = r38;
|
|
env29580[0] = void 0;
|
|
env29580[1] = void 0;
|
|
env29580[2] = void 0;
|
|
env29580[3] = void 0;
|
|
env29580[4] = void 0;
|
|
env29580[5] = void 0;
|
|
env29580[6] = void 0;
|
|
env29580[7] = void 0;
|
|
env29580[8] = void 0;
|
|
env29580[9] = void 0;
|
|
env29580[10] = void 0;
|
|
env29580[11] = void 0;
|
|
env29580[12] = void 0;
|
|
env29580[13] = void 0;
|
|
env29580[14] = void 0;
|
|
env29580[15] = void 0;
|
|
env29580[16] = void 0;
|
|
env29580[17] = void 0;
|
|
env29580[18] = void 0;
|
|
env29580[19] = void 0;
|
|
env29580[20] = void 0;
|
|
env29580[21] = void 0;
|
|
env29580[22] = void 0;
|
|
env29580[23] = void 0;
|
|
const channelId5 = env15051[0];
|
|
const r23 = maybeConvertPrivateChannel(channelId5);
|
|
if (r23 != null) {
|
|
c3543_50.info("Converting channel to a private channel");
|
|
r68 = r23.then((result) => {
|
|
c3543_50.info("Finished converting channel to a private channel");
|
|
return c3543_55._sendMessage(result, env15051[1], env15051[2]);
|
|
});
|
|
break L113;
|
|
}
|
|
const r37 = env15051[1];
|
|
const content = r37.content;
|
|
env29580[0] = content;
|
|
const invalidEmojis = r37.invalidEmojis;
|
|
env29580[1] = r37.validNonShortcutEmojis;
|
|
const tts = r37.tts;
|
|
const tts2 = tts !== void 0 && tts;
|
|
const r25 = env15051[2];
|
|
const { activityAction, location: location2 } = r25;
|
|
env29580[2] = location2;
|
|
env29580[3] = r25.inviteAnalyticsMetadata;
|
|
const stickerIds = r25.stickerIds;
|
|
env29580[4] = stickerIds;
|
|
const messageReference = r25.messageReference;
|
|
env29580[5] = messageReference;
|
|
const { allowedMentions, poll } = r25;
|
|
env29580[6] = poll;
|
|
const { sharedCustomTheme, contentInventoryEntry } = r25;
|
|
env29580[7] = contentInventoryEntry;
|
|
const { attachments, attachmentsToUpload } = r25;
|
|
env29580[8] = attachmentsToUpload;
|
|
env29580[9] = r25.onAttachmentUploadError;
|
|
const { announcementSendOptions, withCheckpoint, mediaMention } = r25;
|
|
flags = r25.flags;
|
|
if (flags == null) {
|
|
flags = 0;
|
|
}
|
|
const [r81, r82] = parseContentForSuppressNotifications(content);
|
|
let r47 = flags;
|
|
let content2 = content;
|
|
if (r81) {
|
|
env29580[0] = r82;
|
|
r47 = addFlag(flags, MessageFlags.SUPPRESS_NOTIFICATIONS);
|
|
content2 = r82;
|
|
}
|
|
const channel = ChannelStore.getChannel(channelId5);
|
|
const flags3 = canSendGuildOfficialMessages(GuildStore.getGuild(channel?.guild_id), channel, "_sendMessage") ? addFlag(r47, MessageFlags.IS_GUILD_OFFICIAL) : r47;
|
|
env29580[10] = false;
|
|
const type = r25.messageReference?.type;
|
|
L21: {
|
|
const r116 = type === MessageReferenceTypes.FORWARD;
|
|
env29580[11] = r116;
|
|
if (content2 === "" && activityAction == null && stickerIds == null && poll == null && sharedCustomTheme == null && contentInventoryEntry == null && !r116) {
|
|
if (attachments != null && attachments.length !== 0) {
|
|
break L21;
|
|
}
|
|
if (!withCheckpoint) {
|
|
if (r37.components != null && r37.components.length !== 0) {
|
|
break L21;
|
|
}
|
|
if (attachmentsToUpload != null && attachmentsToUpload.length > 0) {
|
|
env29580[10] = true;
|
|
break L21;
|
|
}
|
|
r123 = Promise.resolve();
|
|
break L37;
|
|
}
|
|
}
|
|
}
|
|
const type4 = messageReference != null ? MessageTypes.REPLY : MessageTypes.DEFAULT;
|
|
env29580[12] = type4;
|
|
nonce2 = r25.nonce;
|
|
if (nonce2 == null) {
|
|
nonce2 = createNonce();
|
|
}
|
|
env29580[13] = nonce2;
|
|
env29580[14] = nonce2;
|
|
const message = createMessage({
|
|
channelId: channelId5,
|
|
content: content2,
|
|
tts: tts2,
|
|
type: type4,
|
|
messageReference,
|
|
allowedMentions,
|
|
flags: flags3 !== 0 ? flags3 : void 0,
|
|
nonce: nonce2,
|
|
poll: createPollServerDataFromCreateRequest(poll),
|
|
sharedCustomTheme,
|
|
mediaMention,
|
|
mentionGames: r37.mentionGames
|
|
});
|
|
if (r25.eagerDispatch !== false) {
|
|
updateComboOnMessageSend(channelId5, message.id);
|
|
if (stickerIds != null) {
|
|
message.sticker_items = stickerIds.map((stickerId) => StickersStore.getStickerById(stickerId)).filter((item) => item != null);
|
|
}
|
|
c3543_55.receiveMessage(channelId5, message, true, r25);
|
|
}
|
|
if (!env3543[51] && invalidEmojis != null && invalidEmojis.length > 0) {
|
|
env3543[51] = true;
|
|
const currentUser = UserStore.getCurrentUser();
|
|
const r174 = c3543_55.validateMessage(invalidEmojis, currentUser, channelId5);
|
|
c3543_55.sendBotMessage(channelId5, r174.errorMessage, r174.errorMessageName);
|
|
}
|
|
const r190 = {
|
|
type: announcementSendOptions != null ? MessageDataType.SEND_ANNOUNCEMENT : MessageDataType.SEND,
|
|
message: {
|
|
channelId: channelId5,
|
|
content: content2,
|
|
nonce: nonce2,
|
|
tts: tts2,
|
|
message_reference: messageReference,
|
|
allowed_mentions: allowedMentions,
|
|
flags: flags3,
|
|
analyticsLocation: location2
|
|
}
|
|
};
|
|
env29580[16] = r190;
|
|
if (r37.components != null) {
|
|
r190.message.components = r37.components;
|
|
}
|
|
if (announcementSendOptions != null) {
|
|
r190.message.create_thread = announcementSendOptions.createThread;
|
|
r190.message.title = announcementSendOptions.threadName;
|
|
const message2 = r190.message;
|
|
const publish2 = announcementSendOptions.publish;
|
|
publish = publish2;
|
|
if (publish2 == null) {
|
|
publish = false;
|
|
}
|
|
message2.publish = publish;
|
|
}
|
|
if (activityAction != null) {
|
|
const r203 = activityAction == null ? void 0 : activityAction.activity.session_id;
|
|
const type2 = activityAction.type;
|
|
const JOIN_REQUEST = ActivityActionTypes.JOIN_REQUEST;
|
|
let session_id = r203;
|
|
if (type2 !== JOIN_REQUEST) {
|
|
const type3 = activityAction.type;
|
|
const STREAM_REQUEST = ActivityActionTypes.STREAM_REQUEST;
|
|
session_id = r203;
|
|
if (type3 !== STREAM_REQUEST) {
|
|
session_id = r203;
|
|
if (session_id == null) {
|
|
session_id = AuthenticationStore.getSessionId();
|
|
}
|
|
}
|
|
}
|
|
if (session_id != null) {
|
|
const activity2 = {
|
|
type: activityAction.type,
|
|
session_id,
|
|
target_user_id: activityAction.targetUserId
|
|
};
|
|
const activity = activityAction.activity;
|
|
if (activity.party != null && activity.party.id != null) {
|
|
activity2.party_id = activity.party.id;
|
|
}
|
|
r190.message.application_id = activity.application_id;
|
|
r190.message.activity = activity2;
|
|
}
|
|
}
|
|
if (poll != null) {
|
|
r190.message.poll = poll;
|
|
}
|
|
if (sharedCustomTheme != null) {
|
|
r190.message.shared_client_theme = sharedCustomTheme;
|
|
}
|
|
if (stickerIds != null) {
|
|
r190.message.sticker_ids = stickerIds;
|
|
}
|
|
if (PoggermodeSettingsStore.isEnabled()) {
|
|
r190.message.has_poggermode_enabled = true;
|
|
}
|
|
if (withCheckpoint) {
|
|
r190.message.with_checkpoint = true;
|
|
}
|
|
if (contentInventoryEntry != null) {
|
|
r190.message.content_inventory_entry = contentInventoryEntry;
|
|
}
|
|
if (mediaMention != null) {
|
|
r190.message.media_mention = mediaMention;
|
|
}
|
|
if (attachments != null && attachments.length > 0) {
|
|
r190.message.attachments = attachments;
|
|
}
|
|
if (attachmentsToUpload != null && attachmentsToUpload.length > 0) {
|
|
c25568_6 = 1;
|
|
const doNotNotifyOnError = r25.doNotNotifyOnError;
|
|
env29580[17] = await uploadMessageAttachments({
|
|
channelId: channelId5,
|
|
nonce: nonce2,
|
|
items: attachmentsToUpload,
|
|
message,
|
|
shouldUploadFailureSendNotification: doNotNotifyOnError ? !doNotNotifyOnError : void 0
|
|
});
|
|
if (env29580[17] == null) {
|
|
c25568_6 = 0;
|
|
break L111;
|
|
}
|
|
L102: {
|
|
env29580[18] = env29580[17].attachments;
|
|
env29580[15] = env29580[17].uploader;
|
|
if (env29580[10]) {
|
|
if (env29580[18] != null && env29580[18].length !== 0) {
|
|
break L102;
|
|
}
|
|
c25568_6 = 0;
|
|
break L106;
|
|
}
|
|
}
|
|
if (env29580[18] != null) {
|
|
env29580[16].message.attachments = env29580[18].map($mk114788(env3543));
|
|
}
|
|
c25568_6 = 0;
|
|
promise2 = new Promise($mk114789(c25568_3));
|
|
break L110;
|
|
}
|
|
promise = new Promise($mk114789(c25568_3));
|
|
break L112;
|
|
} catch ($e) {
|
|
const r59 = $e;
|
|
let r8 = r59;
|
|
c25568_5 = r59;
|
|
if (c25568_6 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r320 = c25568_5;
|
|
c25568_6 = 0;
|
|
env29580[19] = r320;
|
|
env29580[20] = env29580[19].file;
|
|
env29580[21] = env29580[19].code;
|
|
env29580[22] = env29580[19].reason;
|
|
env29580[23] = env29580[19].responseBody;
|
|
logMessageSendFailure({
|
|
fileItems: env29580[20].items,
|
|
failureCode: env29580[21],
|
|
errorMessage: env29580[22]?.msg
|
|
});
|
|
const r345 = env29580[9];
|
|
if (r345 != null) {
|
|
r345(env29580[20], env29580[21], env29580[22], env29580[23]);
|
|
}
|
|
} catch (r316) {
|
|
r8 = r316;
|
|
c25568_5 = r316;
|
|
if (c25568_6 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
}
|
|
return r123;
|
|
}
|
|
return void 0;
|
|
}
|
|
return promise2;
|
|
}
|
|
return void 0;
|
|
}
|
|
return promise;
|
|
}
|
|
return r68;
|
|
},
|
|
startEditMessage: (a0, a1, a2, a3) => {
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_START_EDIT",
|
|
channelId: a0,
|
|
messageId: a1,
|
|
content: a2,
|
|
source: a3
|
|
});
|
|
},
|
|
startEditMessageRecord: (a0, a1, a2) => {
|
|
if (hasFlag(a1.flags, MessageFlags.IS_COMPONENTS_V2)) {
|
|
const r19 = a1.components.filter((component) => component.type === ComponentType.TEXT_DISPLAY);
|
|
if (r19.length > 0) {
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_START_EDIT",
|
|
channelId: a0,
|
|
messageId: a1.id,
|
|
content: r19.map((item) => item.content).join("\n"),
|
|
source: a2
|
|
});
|
|
return void 0;
|
|
}
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_START_EDIT",
|
|
channelId: a0,
|
|
messageId: a1.id,
|
|
content: a1.content,
|
|
source: a2
|
|
});
|
|
},
|
|
updateEditMessage: (a0, a1, a2) => {
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_UPDATE_EDIT",
|
|
channelId: a0,
|
|
textValue: a1,
|
|
richValue: a2
|
|
});
|
|
},
|
|
endEditMessage: (a0, a1) => {
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_END_EDIT",
|
|
channelId: a0,
|
|
response: a1
|
|
});
|
|
},
|
|
editMessage: async (a0, a1, a2) => {
|
|
let env15052 = {
|
|
$parent: env3543
|
|
};
|
|
env15052[0] = a0;
|
|
env15052[1] = a1;
|
|
env15052[2] = a2.content;
|
|
env15052[3] = a2.components;
|
|
let env29581;
|
|
const r9 = env15052;
|
|
let c25569_1 = r9;
|
|
const r10 = env29581 = {
|
|
$parent: r9
|
|
};
|
|
let c25569_0 = r10;
|
|
env29581[0] = void 0;
|
|
env29581[1] = void 0;
|
|
env29581[2] = void 0;
|
|
(function tryTrackEditMessageSwipeSend(a0, a1) {
|
|
if (EditMessageStore.getEditActionSource(a1) === "message_swipe") {
|
|
AnalyticsUtils.track(AnalyticEvents.MESSAGE_SWIPE_ACTION_SENT, {
|
|
message_id: a0,
|
|
channel_id: a1,
|
|
guild_id: ChannelStore.getChannel(a1)?.guild_id,
|
|
swipe_action: "edit",
|
|
is_own_message: true
|
|
});
|
|
}
|
|
})(env15052[1], env15052[0]);
|
|
await ThreadActionCreators.unarchiveThreadIfNecessary(env15052[0]);
|
|
const r50 = env3543;
|
|
const r51 = env15052[0];
|
|
const r52 = env15052[1];
|
|
env29581[0] = $mk114791(r50)(r51, r52);
|
|
const r55 = env15052[0];
|
|
const r56 = env15052[1];
|
|
env29581[1] = $mk114792(r50)(r55, r56);
|
|
env29581[2] = {
|
|
channelId: env15052[0],
|
|
messageId: env15052[1],
|
|
content: env15052[2],
|
|
isCrossposted: env29581[1],
|
|
allowed_mentions: env29581[0],
|
|
components: env15052[3]
|
|
};
|
|
MessageQueue.enqueue({
|
|
type: MessageDataType.EDIT,
|
|
message: env29581[2]
|
|
}, $mk114793(c25569_0));
|
|
},
|
|
suppressEmbeds: async (c15053_0, c15053_1) => {
|
|
let c25570_1;
|
|
c25570_1 = void 0;
|
|
await ThreadActionCreators.unarchiveThreadIfNecessary(c15053_0);
|
|
let c29582_0 = MessageStore.getMessage(c15053_0, c15053_1);
|
|
if (c29582_0 != null) {
|
|
HTTP.patch({
|
|
url: Endpoints.MESSAGE(c15053_0, c15053_1),
|
|
body: {
|
|
flags: setFlag(c29582_0.flags, MessageFlags.SUPPRESS_EMBEDS, true)
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
}
|
|
},
|
|
patchMessageGuildOfficial: async (c15054_0, c15054_1, c15054_2) => {
|
|
let c25571_1;
|
|
c25571_1 = void 0;
|
|
await ThreadActionCreators.unarchiveThreadIfNecessary(c15054_0);
|
|
let c29583_0 = MessageStore.getMessage(c15054_0, c15054_1);
|
|
if (c29583_0 != null) {
|
|
HTTP.patch({
|
|
url: Endpoints.MESSAGE(c15054_0, c15054_1),
|
|
body: {
|
|
flags: setFlag(c29583_0.flags, MessageFlags.IS_GUILD_OFFICIAL, c15054_2)
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
}
|
|
},
|
|
patchMessageAttachments: async (c15055_0, c15055_1, c15055_2) => {
|
|
let c25572_0;
|
|
c25572_0 = void 0;
|
|
await ThreadActionCreators.unarchiveThreadIfNecessary(c15055_0);
|
|
HTTP.patch({
|
|
url: Endpoints.MESSAGE(c15055_0, c15055_1),
|
|
body: {
|
|
attachments: c15055_2
|
|
},
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
},
|
|
deleteMessage: async function deleteMessage(channelId4, id, r4 = false) {
|
|
let c15056_2 = r4;
|
|
let c25573_0, c25573_1;
|
|
L14: {
|
|
const r33 = void 0;
|
|
c25573_1 = r33;
|
|
c25573_0 = r33;
|
|
if (c15056_2) {
|
|
(function dispatchDelete() {
|
|
const r1 = env3543;
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_DELETE",
|
|
id,
|
|
channelId: channelId4
|
|
}).then($mk117922(r1));
|
|
})();
|
|
break L14;
|
|
}
|
|
await ThreadActionCreators.unarchiveThreadIfNecessary(channelId4);
|
|
const r56 = c25573_0;
|
|
HTTP.del({
|
|
url: Endpoints.MESSAGE(channelId4, id),
|
|
oldFormErrors: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
}).then($mk114795(r56));
|
|
return void 0;
|
|
}
|
|
},
|
|
dismissAutomatedMessage: function dismissAutomatedMessage(a0) {
|
|
if (a0.loggingName != null) {
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.AUTOMATED_MESSAGE_DISMISSED, {
|
|
message_name: a0.loggingName,
|
|
message_author: a0.author.username
|
|
});
|
|
}
|
|
logGiftIntentMessageDismissed(a0.channel_id, a0.id);
|
|
this.deleteMessage(a0.channel_id, a0.id, true);
|
|
},
|
|
revealMessage: (a0, a1) => {
|
|
Dispatcher.dispatch({
|
|
type: "MESSAGE_REVEAL",
|
|
channelId: a0,
|
|
messageId: a1
|
|
});
|
|
},
|
|
crosspostMessage: async (c15057_0, c15057_1) => {
|
|
let r54;
|
|
let c25574_2;
|
|
let c25574_3 = 0;
|
|
let c29584_0, c29584_1;
|
|
try {
|
|
c29584_0 = void 0;
|
|
c25574_3 = 1;
|
|
r54 = await HTTP.post({
|
|
url: Endpoints.MESSAGE_CROSSPOST(c15057_0, c15057_1),
|
|
oldFormErrors: true,
|
|
failImmediatelyWhenRateLimited: true,
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
c25574_3 = 0;
|
|
} catch ($e) {
|
|
const r33 = $e;
|
|
let r8 = r33;
|
|
c25574_2 = r33;
|
|
if (c25574_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r75 = c25574_2;
|
|
c25574_3 = 0;
|
|
c29584_1 = r75;
|
|
c29584_0 = c29584_1.status === 429 ? intl.formatToPlainString(t["77cuqz"], {
|
|
retryAfter: Math.floor(c29584_1.body.retry_after / 60)
|
|
}) : intl.string(t.z2gyNF);
|
|
AlertActionCreators.show({
|
|
title: intl.string(t.Vd1hs6),
|
|
body: c29584_0,
|
|
confirmText: intl.string(t.BddRzS)
|
|
});
|
|
} catch (r72) {
|
|
r8 = r72;
|
|
c25574_2 = r72;
|
|
if (c25574_3 === 0) {
|
|
break;
|
|
}
|
|
continue;
|
|
}
|
|
return void 0;
|
|
}
|
|
}
|
|
throw r8;
|
|
}
|
|
return r54;
|
|
},
|
|
trackInvite
|
|
};
|
|
export default c3543_55;
|