141 lines
7.9 KiB
TypeScript
141 lines
7.9 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] */
|
|
import GuildStore from '../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
|
|
import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */
|
|
import RelationshipStore from '../../stores/RelationshipStore.tsx'; /* Metro dependency 3793 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as IndexNativeModule from '../../intl/index.native.tsx'; /* Metro dependency 1244 */
|
|
import * as MessageConstantsModule from '../messages/MessageConstants.tsx'; /* Metro dependency 4503 */
|
|
import * as MediaPostThumbnailUtilsModule from './MediaPostThumbnailUtils.tsx'; /* Metro dependency 4804 */
|
|
|
|
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 getMediaPostEmbedChannelPath2 = getMediaPostEmbedChannelPath;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/media_channel/MediaPostEmbedUtils.tsx');
|
|
exports.getMediaPostEmbedCommonData = getMediaPostEmbedCommonData;
|
|
exports.getMediaPostEmbedChannelId = getMediaPostEmbedChannelId;
|
|
exports.getMediaPostEmbedChannelPath = getMediaPostEmbedChannelPath2;
|
|
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 getThumbnailImage = MediaPostThumbnailUtilsModule.getThumbnailImage;
|
|
let thumbnail = mediaPostEmbedData.thumbnail;
|
|
const value4 = Reflect.apply(getThumbnailImage, MediaPostThumbnailUtilsModule, [thumbnail]);
|
|
const r6 = !canAccess && mediaPostEmbedData.has_media_attachment;
|
|
const intl = (IndexNativeModule).intl;
|
|
const string = intl.string;
|
|
const t = (IndexNativeModule).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 object = {};
|
|
object.title = mediaPostEmbedData.title ?? '';
|
|
object.subtitle = mediaPostEmbedData.description;
|
|
object.ctaText = r16;
|
|
object.coverImage = value4;
|
|
object.coverImageOverlayText = r6 ? intl.string(t.Yonlia) : value;
|
|
object.parentChannelId = mediaPostEmbedData.parent_channel_id;
|
|
object.threadId = mediaPostEmbedData.channel_id;
|
|
object.postThread = postThread;
|
|
object.messageId = mediaPostEmbedData.message_id;
|
|
object.canAccess = canAccess;
|
|
object.guildId = mediaPostEmbedData.guild_id;
|
|
object.guildName = (guild == null ? value : guild.name) ?? mediaPostEmbedData.guild_name;
|
|
object.authorId = mediaPostEmbedData == null ? value : mediaPostEmbedData.author_id;
|
|
object.authorName = r8;
|
|
if (parentChannel != null) {
|
|
value = require(4805) /* metro dependency 4805: useChannelName */;
|
|
value = value.computeChannelName(parentChannel, UserStore, RelationshipStore);
|
|
r8 = value;
|
|
} else {
|
|
r8 = value;
|
|
}
|
|
object.channelName = r8;
|
|
object.avatarUrl = r7;
|
|
object.shouldShowBlurredThumbnailImage = r6;
|
|
object.shouldContainMediaWithBackground = r5;
|
|
object.shouldSpoiler = r4;
|
|
object.obscureAwaitingScan = false;
|
|
object.flags = mediaPostEmbedData.flags;
|
|
object.contentScanVersion = mediaPostEmbedData.content_scan_version;
|
|
return object;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun41610, 4803, [1867, 3793, 1878, 661, 4503, 4804, 1244, 4617, 1423, 4805, 4096, 4246,
|
|
2]) /* metro module 4803, dependencies: [1867, 3793, 1878, 661, 4503, 4804, 1244, 4617, 1423, 4805, 4096, 4246, 2] */;
|