128 lines
6.4 KiB
TypeScript
128 lines
6.4 KiB
TypeScript
/* Metro module 7141; source: modules/messages/createMessage.tsx; dependencies: [4833, 1885, 1878, 661, 44, 7142, 2] */
|
|
import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */
|
|
import UserRecord from '../../records/UserRecord.tsx'; /* Metro dependency 1885 */
|
|
import ReferencedMessageStore from '../replies/ReferencedMessageStore.tsx'; /* Metro dependency 4833 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as ReferencedMessageStoreModule from '../replies/ReferencedMessageStore.tsx'; /* Metro dependency 4833 */
|
|
|
|
function _fun57133(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#57133, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7319:6, offset: 0x013dd58b, size: 255 bytes, params: 8, frame: 20
|
|
const env0_0 = require;
|
|
const closure = function({id, username, avatar, discriminator, bot, globalName, primaryGuild}) {
|
|
return {id: id, username: username, avatar: avatar, discriminator: discriminator, bot: bot,
|
|
global_name: globalName,
|
|
primary_guild: primaryGuild};
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/messages/createMessage.tsx');
|
|
exports.default = createMessage;
|
|
exports.userRecordToServer = closure;
|
|
exports.createBotMessage = createBotMessage;
|
|
function createMessage({channelId, content, tts, type, messageReference, allowedMentions, author, flags, nonce, poll, sharedCustomTheme, changelogId, giftingPrompt, boostingPrompt, state, mediaMention}) { // fn#57135, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7319:538, offset: 0x013dd6dc, size: 579 bytes, params: 2, frame: 33
|
|
var messageByReference;
|
|
let value = undefined;
|
|
tts = !(tts === value) && tts;
|
|
const r18 = type !== value ? type : MessageTypes.DEFAULT;
|
|
const items2 = [];
|
|
const REPLY = MessageTypes.REPLY;
|
|
if (r18 === REPLY) {
|
|
(importDefault(44) /* metro dependency 44 */)(messageReference != null,
|
|
'Replies must have a message reference');
|
|
if (allowedMentions == null) {
|
|
messageByReference = ReferencedMessageStore.getMessageByReference(messageReference);
|
|
state = messageByReference == null ? value : messageByReference.state;
|
|
if (state === ReferencedMessageState.LOADED) {
|
|
items2.push(userRecordToServer(messageByReference.message.author));
|
|
}
|
|
} else if (allowedMentions.replied_user) {
|
|
messageByReference = ReferencedMessageStore.getMessageByReference(messageReference);
|
|
state = messageByReference == null ? value : messageByReference.state;
|
|
if (state === ReferencedMessageState.LOADED) {
|
|
items2.push(userRecordToServer(messageByReference.message.author));
|
|
}
|
|
}
|
|
}
|
|
let r19 = author ?? UserStore.getCurrentUser();
|
|
const r14 = r19 instanceof UserRecord ? userRecordToServer(r19) : r19;
|
|
(importDefault(44) /* metro dependency 44 */)(r14 != null, 'createMessage: author cannot be undefined');
|
|
const object = {};
|
|
if (nonce != null) {
|
|
r19 = nonce;
|
|
} else {
|
|
value = require(7142) /* metro dependency 7142: createNonce */;
|
|
value = value.createNonce();
|
|
r19 = value;
|
|
}
|
|
object.id = r19;
|
|
object.type = r18;
|
|
object.content = content;
|
|
object.channel_id = channelId;
|
|
object.author = r14;
|
|
object.attachments = [];
|
|
object.embeds = [];
|
|
object.pinned = false;
|
|
object.mentions = items2;
|
|
object.mention_channels = [];
|
|
object.mention_roles = [];
|
|
object.mention_everyone = false;
|
|
const Date = global.Date;
|
|
object.timestamp = new Date().toISOString();
|
|
object.state = state ?? MessageStates.SENDING;
|
|
object.tts = tts;
|
|
object.message_reference = messageReference;
|
|
object.message_snapshots = [];
|
|
object.flags = flags;
|
|
object.nonce = nonce;
|
|
object.poll = poll;
|
|
object.shared_client_theme = sharedCustomTheme;
|
|
object.changelog_id = changelogId;
|
|
object.gifting_prompt = giftingPrompt;
|
|
object.boosting_prompt = boostingPrompt;
|
|
object.media_mention = mediaMention;
|
|
return object;
|
|
}
|
|
|
|
function createBotMessage({messageId, channelId, content, embeds, loggingName}) { // fn#57136, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7319:1595, offset: 0x013dd91f, size: 285 bytes, params: 2, frame: 18
|
|
var r3;
|
|
var value;
|
|
const object = {};
|
|
if (messageId != null) {
|
|
r3 = messageId;
|
|
} else {
|
|
value = require(7142) /* metro dependency 7142: createNonce */;
|
|
value = value.createNonce();
|
|
r3 = value;
|
|
}
|
|
object.id = r3;
|
|
const DEFAULT = MessageTypes.DEFAULT;
|
|
object.type = DEFAULT;
|
|
const EPHEMERAL = MessageFlags.EPHEMERAL;
|
|
object.flags = EPHEMERAL;
|
|
object.content = content;
|
|
object.channel_id = channelId;
|
|
object.author = {'id': null, 'username': 'Clyde', 'discriminator': null, 'avatar': 'clyde', 'bot': true,
|
|
id: LOCAL_BOT_ID, discriminator: NON_USER_BOT_DISCRIMINATOR};
|
|
object.attachments = [];
|
|
object.embeds = embeds ?? [];
|
|
object.pinned = false;
|
|
object.mentions = [];
|
|
object.mention_channels = [];
|
|
object.mention_roles = [];
|
|
object.mention_everyone = false;
|
|
const Date = global.Date;
|
|
const value2 = Object.create(Date.prototype, {constructor: {value: Date}});
|
|
const date = new Date();
|
|
object.timestamp = (date instanceof Object ? date : value2).toISOString();
|
|
const SENT = MessageStates.SENT;
|
|
object.state = SENT;
|
|
object.tts = false;
|
|
object.loggingName = loggingName;
|
|
return object;
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun57133, 7141, [4833, 1885, 1878, 661, 44, 7142,
|
|
2]) /* metro module 7141, dependencies: [4833, 1885, 1878, 661, 44, 7142, 2] */;
|