Files
discord-decomp/sources/modules/media_channel/MediaPostEmbedUtils.tsx
T
2026-07-27 16:20:00 +03:00

136 lines
7.1 KiB
TypeScript

/* Metro module 4803; source: modules/media_channel/MediaPostEmbedUtils.tsx; dependencies: [1867, 3793, 1878, 661, 4503, 4804, 1244, 4617, 1423, 4805, 4096, 4246, 2] */
function _fun41610(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#41610, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4981:6, offset: 0x01123713, size: 229 bytes, params: 8, frame: 20
const env0_0 = require;
const closure = getMediaPostEmbedChannelPath;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
const relationshipStore = importDefault(3793) /* metro dependency 3793: RelationshipStore */;
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
const env0_6 = (require(661) /* metro dependency 661: Constants */).GuildFeatures;
const env0_7 = (require(4503) /* metro dependency 4503: MessageConstants */).SPOILER_ATTACHMENT_PREFIX;
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/media_channel/MediaPostEmbedUtils.tsx');
exports.getMediaPostEmbedCommonData = getMediaPostEmbedCommonData;
exports.getMediaPostEmbedChannelId = getMediaPostEmbedChannelId;
exports.getMediaPostEmbedChannelPath = closure;
exports.canUseMediaPostEmbed = canUseMediaPostEmbed;
}
function getMediaPostEmbedChannelPath(a0) { // fn#41611, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4981:186, offset: 0x011237f8, size: 118 bytes, params: 2, frame: 15
if (a0 != null) {
var value;
var uRLSafely = (require(4096) /* metro dependency 4096: findCodedLinks */).parseURLSafely(a0);
if (uRLSafely == null) {
return undefined;
}
var value2 = (require(4096) /* metro dependency 4096: findCodedLinks */).remainingPathFromDiscordHostMatch(uRLSafely);
if (value2 != null) {
return (require(4246) /* metro dependency 4246: LinkUtils */).tryParseChannelPath(value2);
}
}
}
function getMediaPostEmbedCommonData({mediaPostEmbedData, guild, parentChannel, postThread, user, selectedGuildId, canAccess}) { // fn#41612, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4981:498, offset: 0x0112386e, size: 813 bytes, params: 2, frame: 31
var r8;
var r1;
var r5;
var defaultImport;
var height;
var width;
let value = undefined;
canAccess = !(canAccess === value) && canAccess;
if (mediaPostEmbedData == null) {
return null;
}
const mediaPostThumbnailUtilsModule = require(4804) /* metro dependency 4804: MediaPostThumbnailUtils */;
const getThumbnailImage = mediaPostThumbnailUtilsModule.getThumbnailImage;
let thumbnail = mediaPostEmbedData.thumbnail;
const value4 = Reflect.apply(getThumbnailImage, mediaPostThumbnailUtilsModule, [thumbnail]);
const r6 = !canAccess && mediaPostEmbedData.has_media_attachment;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
const string = intl.string;
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
const r16 = canAccess ? Reflect.apply(string, intl, [t.UsZEBI]) : Reflect.apply(string, intl, [t.ReFzYZ]);
if (user != null) {
defaultImport = importDefault(4617) /* metro dependency 4617: NicknameUtils */;
r8 = defaultImport.getName(mediaPostEmbedData.guild_id, mediaPostEmbedData.channel_id, user);
} else {
r8 = value;
}
let r7 = user == null ? value : user.getAvatarURL(guild == null ? value : guild.id, 40);
r7 = !(r7 != null && selectedGuildId === mediaPostEmbedData.guild_id) ? (importDefault(1423) /* metro dependency 1423: AvatarUtils */).getGuildIconURL({id: mediaPostEmbedData.guild_id,
icon: mediaPostEmbedData.guild_icon, size: 40, canAnimate: false}) : r7;
thumbnail = mediaPostEmbedData.thumbnail;
if (thumbnail == null) {
r5 = false;
} else {
height = thumbnail.height;
width = thumbnail.width;
r1 = height != null && width != null;
r1 = r1 && height >= width;
r5 = r1;
}
r5 = r5 && !r6;
thumbnail = mediaPostEmbedData.thumbnail;
const r4 = (thumbnail == null ? value : thumbnail.filename) != null && (mediaPostEmbedData.thumbnail == null || mediaPostEmbedData.thumbnail.filename == null ? value : mediaPostEmbedData.thumbnail.filename.startsWith(SPOILER_ATTACHMENT_PREFIX));
const object2 = {};
object2.title = mediaPostEmbedData.title ?? '';
object2.subtitle = mediaPostEmbedData.description;
object2.ctaText = r16;
object2.coverImage = value4;
object2.coverImageOverlayText = r6 ? intl.string(t.Yonlia) : value;
object2.parentChannelId = mediaPostEmbedData.parent_channel_id;
object2.threadId = mediaPostEmbedData.channel_id;
object2.postThread = postThread;
object2.messageId = mediaPostEmbedData.message_id;
object2.canAccess = canAccess;
object2.guildId = mediaPostEmbedData.guild_id;
object2.guildName = (guild == null ? value : guild.name) ?? mediaPostEmbedData.guild_name;
object2.authorId = mediaPostEmbedData == null ? value : mediaPostEmbedData.author_id;
object2.authorName = r8;
if (parentChannel != null) {
value = require(4805) /* metro dependency 4805: useChannelName */;
value = value.computeChannelName(parentChannel, UserStore, RelationshipStore);
r8 = value;
} else {
r8 = value;
}
object2.channelName = r8;
object2.avatarUrl = r7;
object2.shouldShowBlurredThumbnailImage = r6;
object2.shouldContainMediaWithBackground = r5;
object2.shouldSpoiler = r4;
object2.obscureAwaitingScan = false;
object2.flags = mediaPostEmbedData.flags;
object2.contentScanVersion = mediaPostEmbedData.content_scan_version;
return object2;
}
function getMediaPostEmbedChannelId(a0) { // fn#41613, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4981:1943, offset: 0x01123b9b, size: 51 bytes, params: 2, frame: 12
const mediaPostEmbedChannelPath = getMediaPostEmbedChannelPath(a0);
if (mediaPostEmbedChannelPath == null) {
return undefined;
}
const r0 = mediaPostEmbedChannelPath.threadId ?? mediaPostEmbedChannelPath.channelId;
return r0 === mediaPostEmbedChannelPath.messageId ? r0 : undefined;
}
function canUseMediaPostEmbed(a0, a1) { // fn#41614, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4981:2188, offset: 0x01123bce, size: 117 bytes, params: 3, frame: 14
const guild = GuildStore.getGuild(a0);
if (guild == null) {
return false;
}
if (a1 == null) {
return false;
}
const features = guild.features;
const has = features.has;
const CREATOR_MONETIZABLE = GuildFeatures.CREATOR_MONETIZABLE;
const r1 = Reflect.apply(has, features,
[CREATOR_MONETIZABLE]) || guild.features.has(GuildFeatures.CREATOR_MONETIZABLE_PROVISIONAL);
let value = a1.isMediaChannel();
value = value === true;
return value && r1;
}