This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,95 @@
// Metro module 11066 (f11067).
import { Endpoints } from "../../Constants";
import Dispatcher from "../../Dispatcher";
import { HTTP } from "../../_bundle/sendRequest";
import { APIError } from "../../errors/index";
export function dismissMediaPostSharePrompt(a0) {
Dispatcher.dispatch({
type: "DISMISS_MEDIA_POST_SHARE_PROMPT",
threadId: a0
});
}
export async function fetchMediaPostEmbed(threadId) {
let c26928_4 = 0;
let c30340_0, c30340_1;
L10: {
try {
c30340_0 = threadId;
c30340_1 = void 0;
Dispatcher.dispatch({
type: "MEDIA_POST_EMBED_FETCH",
threadId
});
c26928_4 = 1;
c30340_1 = (await HTTP.get({
url: Endpoints.MEDIA_POST_RESHARE_GET_PREVIEW(threadId),
rejectWithError: true
})).body;
Dispatcher.dispatch({
type: "MEDIA_POST_EMBED_FETCH_SUCCESS",
threadId: c30340_0,
mediaPostEmbed: c30340_1
});
c26928_4 = 0;
} catch ($e) {
let r8 = $e;
if (c26928_4 !== 0) {
while (true) {
try {
c26928_4 = 0;
Dispatcher.dispatch({
type: "MEDIA_POST_EMBED_FETCH_FAILURE",
threadId: c30340_0
});
break L10;
} catch ($e) {
r8 = $e;
if (c26928_4 === 0) {
break;
}
}
}
}
throw r8;
}
}
}
export async function unfurlEmbedUrl(urls) {
let body;
let c26929_3;
let c26929_4 = 0;
let c30341_0;
try {
c26929_4 = 1;
body = (await HTTP.post({
url: Endpoints.UNFURL_EMBED_URLS,
body: {
urls
},
rejectWithError: false
})).body;
c26929_4 = 0;
} catch ($e) {
const r25 = $e;
let r8 = r25;
c26929_3 = r25;
if (c26929_4 !== 0) {
while (true) {
try {
const r60 = c26929_3;
c26929_4 = 0;
c30341_0 = r60;
throw new APIError(c30341_0);
} catch (r56) {
r8 = r56;
c26929_3 = r56;
if (c26929_4 === 0) {
break;
}
}
}
}
throw r8;
}
return body;
}
@@ -0,0 +1,17 @@
// Metro module 8273 (f8274).
import { GuildFeatures } from "../../Constants";
export function useGuildEligibleForMediaChannels(a0) {
if (a0?.id == null) {
return false;
}
const features = a0.features;
let r10 = features.has(GuildFeatures.CREATOR_MONETIZABLE) || features.has(GuildFeatures.CREATOR_MONETIZABLE_PROVISIONAL);
const r14 = features.has(GuildFeatures.COMMUNITY);
if (r10) {
r10 = r14;
}
if (!r10) {
r10 = features.has(GuildFeatures.INTERNAL_EMPLOYEE_ONLY);
}
return r10;
}
@@ -0,0 +1,132 @@
// Metro module 16641 (f16642).
import "../channel/GatedChannelStore";
import "../../stores/AuthenticationStore";
import "../../stores/GuildMemberStore";
import "./MediaPostEmbedStore";
import "../../Constants";
import { MessageEmbedTypes } from "../../_bundle/Module693";
import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager";
import setupLoadFromMessageManagerHandlers from "../messages/setupLoadFromMessageManagerHandlers";
import { $callWithNewTarget } from "../../_hermes/prelude";
function $mk100205($env) {
return (a0) => {
if (a0.url != null) {
const r7 = $env.$parent;
const r6 = r7[0];
const r14 = r7[2];
const mediaPostEmbedChannelPath = r6(r14[6]).getMediaPostEmbedChannelPath(a0.url);
if (mediaPostEmbedChannelPath != null && mediaPostEmbedChannelPath?.threadId != null && mediaPostEmbedChannelPath?.channelId != null && r7[6].getEmbedFetchState(mediaPostEmbedChannelPath.threadId) === r7[7].NOT_FETCHED) {
const r26 = r7[9];
if (!r26.has(mediaPostEmbedChannelPath.threadId)) {
r26.add(mediaPostEmbedChannelPath.threadId);
const id = r7[4].getId();
const r11 = r7[5];
const guildId = mediaPostEmbedChannelPath?.guildId;
const r38 = $env;
const isMember = r11.isMember(guildId, id);
const isChannelGated = r7[3].isChannelGated(mediaPostEmbedChannelPath.guildId, mediaPostEmbedChannelPath.channelId);
const r45 = r6(r14[7]);
let flags = r38[0].flags;
if (flags == null) {
flags = 0;
}
const hasFlag = r45.hasFlag(flags, r7[8].IS_CROSSPOST);
if (!(isMember && isChannelGated === false || (isMember ? !isMember : hasFlag))) {
r6(r14[8]).fetchMediaPostEmbed(mediaPostEmbedChannelPath.threadId);
}
}
}
}
};
}
function $mk100206($env) {
return () => c11980_9.clear();
}
let c11980_9, c11980_11;
let env11980, $mk100204 = function() {
return (a0) => a0.type === MessageEmbedTypes.POST_PREVIEW;
};
const r8 = env11980 = {};
const resolveMediaPostEmbeds = function resolveMediaPostEmbeds(a0) {
let env23356;
const r4 = env23356 = {
$parent: env11980
};
env23356[0] = a0;
const embeds = a0.embeds;
const r6 = embeds == null ? void 0 : embeds.filter($mk100204());
if (r6 != null && r6.length !== 0) {
r6.forEach($mk100205(r4));
}
};
c11980_9 = new Set();
class MediaPostEmbedManager extends AutomaticLifecycleManager {
constructor() {
const r5 = env11980;
super();
this.actions = {
LOAD_THREADS_SUCCESS: this.handleLoadThreadsSuccess,
LOAD_ARCHIVED_THREADS_SUCCESS: this.handleLoadThreadsSuccess,
LOAD_FORUM_POSTS: this.handleLoadForumPosts
};
setupLoadFromMessageManagerHandlers(this, resolveMediaPostEmbeds, {
onBeforeBatch: $mk100206(r5)
});
}
handleLoadThreadsSuccess({ firstMessages }) {
if (firstMessages == null) {
return false;
}
c11980_9.clear();
if (firstMessages != null) {
firstMessages.forEach((firstMessage) => {
let env28476;
const r4 = env28476 = {
$parent: env11980
};
env28476[0] = firstMessage;
const embeds = firstMessage.embeds;
const r6 = embeds == null ? void 0 : embeds.filter($mk100204());
if (r6 != null && r6.length !== 0) {
r6.forEach($mk100205(r4));
}
});
}
}
handleLoadForumPosts({ threads }) {
c11980_9.clear();
Object.values(threads).map(({ first_message }) => {
let r2 = first_message != null;
if (r2) {
let env28477;
const r10 = env28477 = {
$parent: env11980
};
env28477[0] = first_message;
const embeds = first_message.embeds;
const r7 = embeds == null ? void 0 : embeds.filter($mk100204());
const r13 = r7 != null && r7.length !== 0;
r2 = void 0;
if (r13) {
r7.forEach($mk100205(r10));
r2 = void 0;
}
}
return r2;
});
}
}
c11980_11 = MediaPostEmbedManager;
const prototypeOf = Object.getPrototypeOf(MediaPostEmbedManager);
const r45 = Object.create(MediaPostEmbedManager.prototype);
const r47 = $callWithNewTarget(prototypeOf, r45, MediaPostEmbedManager);
const r48 = r47 instanceof Object ? r47 : r45;
r48.actions = {
LOAD_THREADS_SUCCESS: r48.handleLoadThreadsSuccess,
LOAD_ARCHIVED_THREADS_SUCCESS: r48.handleLoadThreadsSuccess,
LOAD_FORUM_POSTS: r48.handleLoadForumPosts
};
setupLoadFromMessageManagerHandlers(r48, resolveMediaPostEmbeds, {
onBeforeBatch: $mk100206(r8)
});
export default r48;
@@ -0,0 +1,61 @@
// Metro module 10469 (f10470).
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c7016_0 = {
NOT_FETCHED: 0,
0: "NOT_FETCHED",
FETCHING: 1,
1: "FETCHING",
FETCHED: 2,
2: "FETCHED",
FAILED: 3,
3: "FAILED"
};
let c7016_1 = {};
let c7016_2 = {};
class MediaPostEmbedStore extends Module589.Store {
static displayName = "MediaPostEmbedStore";
getMediaPostEmbed(a0) {
if (a0 != null) {
return c7016_1[a0];
}
}
getEmbedFetchState(a0) {
let r4 = c7016_2[a0];
if (r4 == null) {
r4 = c7016_0.NOT_FETCHED;
}
return r4;
}
getMediaPostEmbeds() {
return c7016_1;
}
}
const mediaPostEmbedStore = new MediaPostEmbedStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c7016_1 = {};
c7016_2 = {};
},
MEDIA_POST_EMBED_FETCH: function handleFetchMediaPostEmbed(a0) {
c7016_2[a0.threadId] = c7016_0.FETCHING;
},
MEDIA_POST_EMBED_FETCH_SUCCESS: function handleFetchMediaPostEmbedSuccess({ threadId, mediaPostEmbed }) {
const r8 = {
...c7016_1
};
r8[threadId] = mediaPostEmbed;
c7016_1 = r8;
c7016_2[threadId] = c7016_0.FETCHED;
},
MEDIA_POST_EMBED_FETCH_FAILURE: function handleFetchMediaPostFailure(a0) {
c7016_2[a0.threadId] = c7016_0.FAILED;
},
LOGOUT: function handleLogout(a0) {
if (!a0.isSwitchingAccount) {
c7016_1 = {};
c7016_2 = {};
}
}
});
export default mediaPostEmbedStore;
export { c7016_0 as FetchState };
@@ -0,0 +1,120 @@
// Metro module 4375 (f4376).
import GuildStore from "../../stores/GuildStore";
import RelationshipStore from "../../stores/RelationshipStore";
import UserStore from "../../stores/UserStore";
import { GuildFeatures, MessageAttachmentFlags } from "../../Constants";
import { getThumbnailImage } from "./MediaPostThumbnailUtils";
import { intl, t } from "../../intl/index.native";
import NicknameUtils from "../../utils/NicknameUtils";
import AvatarUtils from "../../utils/AvatarUtils";
import * as _Module1384 from "../../_bundle/Module1384";
import { computeChannelName } from "../channel/useChannelName";
import { parseURLSafely, remainingPathFromDiscordHostMatch } from "../coded_links/findCodedLinks";
import { tryParseChannelPath } from "../links/LinkUtils";
export function getMediaPostEmbedCommonData({ mediaPostEmbedData, guild, parentChannel, postThread, user, selectedGuildId, canAccess = false }) {
if (mediaPostEmbedData == null) {
return null;
}
const thumbnailImage = getThumbnailImage(mediaPostEmbedData.thumbnail);
const shouldShowBlurredThumbnailImage = canAccess ? !canAccess : mediaPostEmbedData.has_media_attachment;
const ctaText = canAccess ? intl.string(t.UsZEBI) : intl.string(t.ReFzYZ);
const authorName = user != null ? NicknameUtils.getName(mediaPostEmbedData.guild_id, mediaPostEmbedData.channel_id, user) : void 0;
let avatarUrl = user == null ? void 0 : user.getAvatarURL(guild?.id, 40);
if (!(avatarUrl != null && selectedGuildId === mediaPostEmbedData.guild_id)) {
avatarUrl = AvatarUtils.getGuildIconURL({
id: mediaPostEmbedData.guild_id,
icon: mediaPostEmbedData.guild_icon,
size: 40,
canAnimate: false
});
}
const thumbnail = mediaPostEmbedData.thumbnail;
const r2 = thumbnail == null;
let shouldContainMediaWithBackground = false;
if (!r2) {
const { height, width } = thumbnail;
shouldContainMediaWithBackground = height != null && width != null && height >= width;
}
if (shouldContainMediaWithBackground) {
shouldContainMediaWithBackground = !shouldShowBlurredThumbnailImage;
}
let r64 = mediaPostEmbedData.thumbnail?.flags;
if (r64 == null) {
r64 = 0;
}
const hasFlag = _Module1384.hasFlag(r64, MessageAttachmentFlags.IS_SPOILER);
let title = mediaPostEmbedData.title;
if (title == null) {
title = "";
}
const coverImageOverlayText = shouldShowBlurredThumbnailImage ? intl.string(t.Yonlia) : void 0;
let guildName = guild?.name;
if (guildName == null) {
guildName = mediaPostEmbedData.guild_name;
}
return {
title,
subtitle: mediaPostEmbedData.description,
ctaText,
coverImage: thumbnailImage,
coverImageOverlayText,
parentChannelId: mediaPostEmbedData.parent_channel_id,
threadId: mediaPostEmbedData.channel_id,
postThread,
messageId: mediaPostEmbedData.message_id,
canAccess,
guildId: mediaPostEmbedData.guild_id,
guildName,
authorId: mediaPostEmbedData?.author_id,
authorName,
channelName: parentChannel != null ? computeChannelName(parentChannel, UserStore, RelationshipStore) : void 0,
avatarUrl,
shouldShowBlurredThumbnailImage,
shouldContainMediaWithBackground,
shouldSpoiler: hasFlag,
obscureAwaitingScan: false,
flags: mediaPostEmbedData.flags,
contentScanVersion: mediaPostEmbedData.content_scan_version
};
}
export function getMediaPostEmbedChannelId(a0) {
const r2 = a0 != null;
let r4 = void 0;
if (r2) {
const r11 = parseURLSafely(a0);
const r12 = r11 != null;
r4 = void 0;
if (r12) {
const r16 = remainingPathFromDiscordHostMatch(r11);
r4 = r16 != null ? tryParseChannelPath(r16) : void 0;
}
}
if (r4 != null) {
let threadId = r4.threadId;
if (threadId == null) {
threadId = r4.channelId;
}
if (threadId === r4.messageId) {
return threadId;
}
}
}
export function getMediaPostEmbedChannelPath(a0) {
if (a0 != null) {
const r9 = parseURLSafely(a0);
if (r9 != null) {
const r13 = remainingPathFromDiscordHostMatch(r9);
if (r13 != null) {
return tryParseChannelPath(r13);
}
}
}
}
export function canUseMediaPostEmbed(a0, a1) {
const guild = GuildStore.getGuild(a0);
if (guild != null && a1 != null) {
const r11 = guild.features.has(GuildFeatures.CREATOR_MONETIZABLE) || guild.features.has(GuildFeatures.CREATOR_MONETIZABLE_PROVISIONAL);
return a1.isMediaChannel() === true && r11;
}
return false;
}
@@ -0,0 +1,41 @@
// Metro module 7722 (f7723).
import GatedChannelStore from "../channel/GatedChannelStore";
import AuthenticationStore from "../../stores/AuthenticationStore";
import ChannelStore from "../../stores/ChannelStore";
import { isFirstMessageIdInMediaPost } from "./useIsFirstMessageInMediaPost";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c4855_6 = new Set();
class MediaPostSharePromptStore extends Module589.Store {
static displayName = "MediaPostSharePromptStore";
initialize() {
this.waitFor(AuthenticationStore, ChannelStore, GatedChannelStore);
}
shouldDisplayPrompt(a0) {
return c4855_6.has(a0);
}
}
const mediaPostSharePromptStore = new MediaPostSharePromptStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c4855_6 = new Set();
},
MESSAGE_CREATE: function handleMessageCreate(a0) {
if (!a0.isPushNotification) {
const message = a0.message;
if (AuthenticationStore.getId() === message.author?.id && isFirstMessageIdInMediaPost(message.id, message.channel_id)) {
const channel = ChannelStore.getChannel(message.channel_id);
if (channel != null && channel.parent_id != null && GatedChannelStore.isChannelGated(channel.guild_id, channel.parent_id)) {
c4855_6.add(SnowflakeUtils.castMessageIdAsChannelId(a0.message.id));
}
}
}
},
DISMISS_MEDIA_POST_SHARE_PROMPT: function handleDismissMediaPostSharePrompt(a0) {
c4855_6.delete(a0.threadId);
},
LOGOUT: function handleLogout() {
c4855_6.clear();
}
});
export default mediaPostSharePromptStore;
@@ -0,0 +1,36 @@
// Metro module 4376 (f4377).
import { isAnimatedImageUrl, isVideoUrl } from "../messages/MediaFormatTesters";
export const MAX_THUMBNAIL_COUNT = 4;
export function getEmbedPreviewImageUrl(a0) {
let r7;
if (a0 != null) {
const { thumbnail, image } = a0;
if (thumbnail != null) {
let proxy_url2 = thumbnail.proxy_url;
if (proxy_url2 == null) {
proxy_url2 = thumbnail.url;
}
r7 = proxy_url2;
} else {
const r6 = image != null;
r7 = void 0;
if (r6) {
let proxy_url = image.proxy_url;
if (proxy_url == null) {
proxy_url = image.url;
}
r7 = proxy_url;
}
}
return r7;
}
}
export function getBackgroundImageUrl(a0) {
return isAnimatedImageUrl(a0) ? `${a0}?format=webp` : isVideoUrl(a0) ? `${a0}?format=webp` : a0;
}
export function getThumbnailImage(a0) {
if (a0 != null) {
const { url, proxy_url } = a0;
return url != null ? proxy_url != null ? isVideoUrl(url) ? `${proxy_url}?format=webp` : proxy_url : url : url;
}
}
@@ -0,0 +1,43 @@
// Metro module 11188 (f11189).
import { ImageBackground, StyleSheet } from "react-native";
import { Fragment } from "react/jsx-runtime";
import { ForumPostMediaSpoiler } from "../../forums/native/posts/ForumPostMedia";
import FastImage from "../../../components_native/common/FastImage";
import { isAndroid } from "../../../utils/PlatformUtils";
let MediaPostGridThumbnailIOS;
const MediaPostGridThumbnailAndroid = function MediaPostGridThumbnailAndroid(props) {
const { shouldSpoiler, blurTheme, source, androidStyle, backgroundImagesource, resizeMode } = props;
return backgroundImagesource == null ? <ImageBackground style={androidStyle} source={source} blurRadius={shouldSpoiler ? 10 : 0} resizeMode="cover">
<ForumPostMediaSpoiler shouldSpoiler={shouldSpoiler} blurTheme={blurTheme} />
</ImageBackground> : <ImageBackground style={androidStyle} source={backgroundImagesource} resizeMode="cover" imageStyle={{
opacity: 0.2
}}>
<FastImage style={StyleSheet.absoluteFill} source={source} resizeMode={resizeMode} />
<ForumPostMediaSpoiler shouldSpoiler={shouldSpoiler} blurTheme={blurTheme} />
</ImageBackground>;
};
MediaPostGridThumbnailIOS = function MediaPostGridThumbnailIOS(props) {
const { shouldSpoiler, blurTheme, source, iosStyle, backgroundImagesource, resizeMode } = props;
return <Fragment {...backgroundImagesource == null ? {
children: [<FastImage style={iosStyle} source={source} resizeMode={resizeMode} />, <ForumPostMediaSpoiler shouldSpoiler={shouldSpoiler} blurTheme={blurTheme} />]
} : {
children: [<FastImage style={[StyleSheet.absoluteFill, {
opacity: 0.2
}]} source={backgroundImagesource} resizeMode="cover" />, <FastImage style={iosStyle} source={source} resizeMode={resizeMode} />, <ForumPostMediaSpoiler shouldSpoiler={shouldSpoiler} blurTheme={blurTheme} />]
}} />;
};
export default function MediaPostGridThumbnail(props) {
const r0 = props.isPortrait === true && props.shouldSpoiler === false;
let resizeMode = "cover";
let backgroundImagesource = void 0;
if (r0) {
backgroundImagesource = props.source;
resizeMode = "contain";
}
const props2 = {
...props,
backgroundImagesource,
resizeMode
};
return isAndroid() ? <MediaPostGridThumbnailAndroid {...props2} /> : <MediaPostGridThumbnailIOS {...props2} />;
};
@@ -0,0 +1,76 @@
// Metro module 9581 (f9582).
import { View } from "react-native";
import { ContentDismissActionType } from "../../dismissible_content/DismissibleContentConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import { BottomSheetScrollView } from "../../../_bundle/Module5245";
import { Text } from "../../../design/components/Text/native/Text";
import { intl, t } from "../../../intl/index.native";
import { Checkbox, Spacer } from "../../../design/void/native";
import { Button } from "../../../design/components/Button/native/Button.native";
const useStyles = createStyles({
container: {
flex: 1,
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
padding: 24
},
topContainer: {
flex: 1,
width: "100%",
paddingVertical: 40,
paddingHorizontal: 12,
backgroundColor: Module712.colors.TEXT_FEEDBACK_WARNING,
borderRadius: Module712.radii.sm
},
setAsThumbnailContainer: {
flex: 1,
flexDirection: "row",
padding: 12,
width: "100%",
backgroundColor: Module712.colors.BACKGROUND_MOD_NORMAL,
borderRadius: Module712.radii.sm,
alignItems: "center",
justifyContent: "space-between"
},
contentContainer: {
alignItems: "center",
flex: 1
},
title: {
marginTop: 24
},
description: {
textAlign: "center"
}
});
export default function MediaPostThumbnailActionSheet(props) {
const markAsDismissed = props.markAsDismissed;
const styles = useStyles();
return <BottomSheet backdropOpacity={0.8} onDismiss={() => markAsDismissed(ContentDismissActionType.UNKNOWN)}>
<View style={styles.container}>
<BottomSheetScrollView contentContainerStyle={[styles.contentContainer, {
paddingBottom: useSafeAreaInsets_native().bottom
}]}>
<View style={styles.topContainer}>
<View style={styles.setAsThumbnailContainer}>
<Text variant="text-md/semibold" color="mobile-text-heading-primary">
{intl.string(t.ews2pj)}
</Text>
<Checkbox selected />
</View>
</View>
<Text variant="heading-lg/semibold" color="mobile-text-heading-primary" style={styles.title}>
{intl.string(t.WJisip)}
</Text>
<Spacer size={12} />
<Text variant="text-md/normal" color="text-default" style={styles.description}>
{intl.string(t.X6ZH6d)}
</Text>
<Spacer size={48} />
<Button text={intl.string(t["NX+WJN"])} grow onPress={() => markAsDismissed(ContentDismissActionType.UNKNOWN)} />
</BottomSheetScrollView>
</View>
</BottomSheet>;
};
@@ -0,0 +1,118 @@
// Metro module 12387 (f12388).
import { Image as Image2, processColor } from "react-native";
import DevSettingsStore from "../../devtools/dev_settings/DevSettingsStore";
import ChannelStore from "../../../stores/ChannelStore";
import GuildStore from "../../../stores/GuildStore";
import SelectedGuildStore from "../../../stores/SelectedGuildStore";
import UserStore from "../../../stores/UserStore";
import MediaPostEmbedStore, { FetchState } from "../MediaPostEmbedStore";
import { getMediaPostEmbedChannelId, getMediaPostEmbedCommonData } from "../MediaPostEmbedUtils";
import { canViewChannel } from "../../links/LinkUtils";
import { intl, t } from "../../../intl/index.native";
import { getUserAuthorWithProcessedColor } from "../../messages/native/renderer/system_messages/useAuthorWithProcessedColor";
import formatUsernameOnClick from "../../messages/native/renderer/system_messages/formatUsernameOnClick";
import Module712 from "../../../_bundle/Module712";
import { isAnimatedImageUrl } from "../../messages/MediaFormatTesters";
import Module12388 from "../../../_bundle/Module12388";
import * as _ExplicitMediaRedactionUtils from "../../explicit_media_redaction/ExplicitMediaRedactionUtils";
import { shouldAgeVerifyForExplicitMedia } from "../../explicit_media_redaction/ExplicitMediaRedactionUtils";
import { isVerifiedTeen } from "../../age_assurance/AgeVerificationUtils";
import { getBackgroundImageUrl } from "../MediaPostThumbnailUtils";
export default function createMediaPostPreviewEmbedContent(a0, a1, a2, r10 = false) {
let r148;
const mediaPostEmbedChannelId = getMediaPostEmbedChannelId(a2);
if (mediaPostEmbedChannelId == null) {
return null;
}
if (MediaPostEmbedStore.getEmbedFetchState(mediaPostEmbedChannelId) !== FetchState.FETCHED) {
return null;
}
const media = MediaPostEmbedStore.getMediaPostEmbed(mediaPostEmbedChannelId)?.media;
if (media == null) {
return null;
}
const guild = GuildStore.getGuild(media.guild_id);
const user = UserStore.getUser(media.author_id);
const channel = ChannelStore.getChannel(media.parent_channel_id);
const mediaPostEmbedCommonData = getMediaPostEmbedCommonData({
mediaPostEmbedData: media,
guild,
parentChannel: channel,
postThread: ChannelStore.getChannel(media.channel_id),
user,
selectedGuildId: SelectedGuildStore.getGuildId(),
canAccess: channel != null && canViewChannel(channel)
});
if (mediaPostEmbedCommonData == null) {
return null;
}
const footer = mediaPostEmbedCommonData.authorName != null && (mediaPostEmbedCommonData.channelName != null && user != null) ? intl.formatToParts(t.mCytFr, {
username: mediaPostEmbedCommonData.authorName,
usernameOnClick: formatUsernameOnClick({
userId: user.id,
message: a0,
author: getUserAuthorWithProcessedColor(user, mediaPostEmbedCommonData.postThread),
roleStyle: a1,
messageChannelId: mediaPostEmbedCommonData.threadId
}),
channelName: mediaPostEmbedCommonData.channelName
}) : intl.formatToParts(t.p4VdWJ, {
guildName: mediaPostEmbedCommonData.guildName
});
const ctaButtonColor = mediaPostEmbedCommonData.canAccess === false ? processColor(Module712.unsafe_rawColors.TEAL_430) : processColor(Module712.unsafe_rawColors.BRAND_500);
const r109 = mediaPostEmbedCommonData.coverImage != null && isAnimatedImageUrl(mediaPostEmbedCommonData.coverImage);
if (mediaPostEmbedCommonData.coverImage != null && !mediaPostEmbedCommonData.shouldShowBlurredThumbnailImage && r109 && r10) {
mediaPostEmbedCommonData.coverImage = `${mediaPostEmbedCommonData.coverImage}?format=webp`;
}
if (mediaPostEmbedCommonData.shouldShowBlurredThumbnailImage) {
return {
...mediaPostEmbedCommonData,
blurredCoverImage: Image2.resolveAssetSource(Module12388).uri,
footer,
ctaButtonColor
};
}
const obscureIsOpaque = DevSettingsStore.get("obscure_blur_effect_explicit_content_enabled") || DevSettingsStore.get("obscure_blur_effect_gore_content_enabled") || DevSettingsStore.get("obscure_blur_effect_self_harm_content_enabled");
const isPendingScanVersion = _ExplicitMediaRedactionUtils.isPendingScanVersion(mediaPostEmbedCommonData.contentScanVersion);
const verifyAge = obscureIsOpaque ? shouldAgeVerifyForExplicitMedia() : obscureIsOpaque;
const obscureHideControls = obscureIsOpaque && isVerifiedTeen();
if (mediaPostEmbedCommonData.shouldContainMediaWithBackground && mediaPostEmbedCommonData.coverImage != null) {
const shouldSpoiler2 = mediaPostEmbedCommonData.shouldSpoiler;
let obscure2 = "";
const spoiler2 = shouldSpoiler2 === true ? intl.string(t["F+x38C"]).toUpperCase() : "";
if (obscureIsOpaque) {
obscure2 = intl.string(t.SpxcUR);
}
r148 = {
...mediaPostEmbedCommonData,
footer,
spoiler: spoiler2,
obscure: obscure2,
obscureAwaitingScan: isPendingScanVersion,
verifyAge,
obscureHideControls,
obscureIsOpaque,
ctaButtonColor,
backgroundImage: getBackgroundImageUrl(mediaPostEmbedCommonData.coverImage)
};
} else {
const shouldSpoiler = mediaPostEmbedCommonData.shouldSpoiler;
let obscure = "";
const spoiler = shouldSpoiler === true ? intl.string(t["F+x38C"]).toUpperCase() : "";
if (obscureIsOpaque) {
obscure = intl.string(t.SpxcUR);
}
r148 = {
...mediaPostEmbedCommonData,
footer,
spoiler,
obscure,
obscureAwaitingScan: isPendingScanVersion,
verifyAge,
obscureHideControls,
obscureIsOpaque,
ctaButtonColor
};
}
return r148;
};
@@ -0,0 +1,35 @@
// Metro module 9843 (f9844).
import { useCallback } from "react";
import { DraftType } from "../../../stores/DraftStore";
import UploadAttachmentStore from "../../../stores/UploadAttachmentStore";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import { UploadPlatform } from "../../../lib/uploader/Upload";
import UploadAttachmentActionCreators from "../../../actions/UploadAttachmentActionCreators";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
export default function useSetMediaPostThumbnail(a0, a1) {
const stateFromStores = useStateFromStores([UploadAttachmentStore], () => {
let r11 = UploadAttachmentStore.getUploads(a0, DraftType.ChannelMessage).find((item) => (item == null ? void 0 : item.item?.platform) === UploadPlatform.REACT_NATIVE && item.isThumbnail === true);
if (r11 == null) {
r11 = null;
}
return r11;
});
return useCallback(() => {
if (a1?.id != null) {
if (stateFromStores != null && stateFromStores.id !== a1?.id) {
UploadAttachmentActionCreators.update(a0, stateFromStores.id, DraftType.ChannelMessage, {
thumbnail: false
});
}
let r25 = a1?.isThumbnail;
if (r25 == null) {
r25 = false;
}
UploadAttachmentActionCreators.update(a0, a1?.id, DraftType.ChannelMessage, {
thumbnail: !r25,
spoiler: false
});
ActionSheetActionCreators.hideActionSheet();
}
}, [stateFromStores, a0, a1]);
};
@@ -0,0 +1,7 @@
// Metro module 9842 (f9843).
import ChannelStore from "../../stores/ChannelStore";
import { useStateFromStores } from "../../_bundle/defaultAreStatesEqual";
export default function useCanSetThumbnail(c17514_0, a1) {
const stateFromStores = useStateFromStores([ChannelStore], () => ChannelStore.getChannel(c17514_0));
return (stateFromStores == null ? void 0 : stateFromStores.isMediaChannel()) && a1?.isImage === true;
};
@@ -0,0 +1,63 @@
// Metro module 7723 (f7724).
import ChannelStore from "../../stores/ChannelStore";
import { useStateFromStores } from "../../_bundle/defaultAreStatesEqual";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
export function useIsFirstMessageInMediaPost(a0) {
return useStateFromStores([], () => {
let r1 = a0 != null;
if (r1) {
const { id, channel_id } = a0;
const r16 = SnowflakeUtils.castChannelIdAsMessageId(channel_id);
let r0 = false;
if (id === r16) {
const channel = ChannelStore.getChannel(channel_id);
const r5 = channel == null;
r0 = false;
if (!r5) {
const isForumPost = channel.isForumPost();
r0 = false;
if (isForumPost) {
const channel2 = ChannelStore.getChannel(channel.parent_id);
r0 = (channel2 == null ? void 0 : channel2.isMediaChannel()) === true;
}
}
}
r1 = r0;
}
return r1;
}, [a0]);
}
export function isFirstMessageInMediaPost(a0) {
let r1 = a0 != null;
if (r1) {
const { id, channel_id } = a0;
const r15 = SnowflakeUtils.castChannelIdAsMessageId(channel_id);
let r0 = false;
if (id === r15) {
const channel = ChannelStore.getChannel(channel_id);
const r5 = channel == null;
r0 = false;
if (!r5) {
const isForumPost = channel.isForumPost();
r0 = false;
if (isForumPost) {
const channel2 = ChannelStore.getChannel(channel.parent_id);
r0 = (channel2 == null ? void 0 : channel2.isMediaChannel()) === true;
}
}
}
r1 = r0;
}
return r1;
}
export function isFirstMessageIdInMediaPost(a0, a1) {
if (a0 !== SnowflakeUtils.castChannelIdAsMessageId(a1)) {
return false;
}
const channel = ChannelStore.getChannel(a1);
if (channel != null && channel.isForumPost()) {
const channel2 = ChannelStore.getChannel(channel.parent_id);
return (channel2 == null ? void 0 : channel2.isMediaChannel()) === true;
}
return false;
}
@@ -0,0 +1,11 @@
// Metro module 9558 (f9559).
import ChannelStore from "../../stores/ChannelStore";
import { ChannelFlags } from "../channel/ChannelConstants";
import { useStateFromStores } from "../../_bundle/defaultAreStatesEqual";
export default function useShouldHideMediaOptions(c17289_0) {
const stateFromStores = useStateFromStores([ChannelStore], () => {
const channel = ChannelStore.getChannel(c17289_0);
return channel?.parent_id != null ? channel.isForumPost() ? ChannelStore.getChannel(channel?.parent_id) : null : null;
});
return (stateFromStores == null ? void 0 : stateFromStores.hasFlag(ChannelFlags.HIDE_MEDIA_DOWNLOAD_OPTIONS)) === true;
};