Files
2026-07-28 01:06:53 +03:00

219 lines
12 KiB
TypeScript

/* Metro module 10921; source: modules/in_app_notifications/InAppNotificationUtils.tsx; dependencies: [31, 3793, 1878, 10922, 661, 4805, 1244, 22, 491, 4845, 4863, 2] */
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 ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as Module00491Module from '../../by-id/module-00491.js'; /* Metro dependency 491 */
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as UseChannelNameModule from '../channel/useChannelName.tsx'; /* Metro dependency 4805 */
import * as InAppNotificationConstantsModule from './InAppNotificationConstants.tsx'; /* Metro dependency 10922 */
function _fun83687(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#83687, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:6, offset: 0x01f24bb2, size: 330 bytes, params: 8, frame: 20
const env0_0 = require;
const extractGuildAndChannelAndMessageIdFromNotification2 = extractGuildAndChannelAndMessageIdFromNotification;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/in_app_notifications/InAppNotificationUtils.tsx');
exports.getNotificationTitle = getNotificationTitle;
exports.getNotificationBodyText = getNotificationBodyText;
exports.isReactionMilestoneNotification = function(a0, a1) {
if (a1 == null) {
return false;
}
if (a1 === ChannelTypes.GUILD_ANNOUNCEMENT) {
return false;
}
return REACTION_MILESTONE_COUNTS.has(require(dependencyMap[7]).sumBy(a0, _fun83694));
};
exports.generateInAppNotificationId = generateInAppNotificationId;
exports.useHasPreviewableMedia = useHasPreviewableMedia;
exports.extractGuildAndChannelAndMessageIdFromNotification = extractGuildAndChannelAndMessageIdFromNotification2;
exports.trackInAppNotificationAccessoryClicked = function(a0, a1) {
var {guildId, channelId, messageId} = extractGuildAndChannelAndMessageIdFromNotification(a0);
var defaultImport = importDefault(dependencyMap[10]);
var IN_APP_NOTIFICATION_ACCESSORY_CLICKED = AnalyticEvents.IN_APP_NOTIFICATION_ACCESSORY_CLICKED;
defaultImport.trackWithMetadata(IN_APP_NOTIFICATION_ACCESSORY_CLICKED, {type: a0.type,
in_app_notification_id: a0.inAppNotificationId, notif_guild_id: guildId, notif_channel_id: channelId,
message_id: messageId, accessory: a1});
};
function hasMedia(a0) { // fn#83688, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:274, offset: 0x01f24cfc, size: 121 bytes, params: 2, frame: 14
const hasFlag = a0.hasFlag;
const IS_VOICE_MESSAGE = MessageFlags.IS_VOICE_MESSAGE;
let r0 = Reflect.apply(hasFlag, a0, [IS_VOICE_MESSAGE]) || a0.attachments.length > 0;
r0 = !r0 ? a0.embeds.length > 0 && a0.embeds.every(function({type}) {
return type === MessageEmbedTypes.GIFV;
}) : r0;
r0 = !r0 ? a0.stickerItems.length > 0 : r0;
return r0;
}
function extractGuildAndChannelAndMessageIdFromNotification(a0) { // fn#83690, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:438, offset: 0x01f24d90, size: 421 bytes, params: 2, frame: 10
var guild_id;
var id;
var r5;
var r1;
var r2;
var r3;
var MESSAGE_REMINDER;
var channel;
var channelId;
var thread;
var guild;
var message;
const type = a0.type;
var value;
const MESSAGE = InAppNotificationTypes.MESSAGE;
if (MESSAGE === type) {
guild = a0.guild;
value = undefined;
id = guild == null ? value : guild.id;
r5 = id ?? (a0.channel == null ? value : a0.channel.guild_id);
channel = a0.channel;
id = channel == null ? value : channel.id;
message = a0.message;
r1 = message == null ? value : message.id;
r2 = id;
r3 = r5;
} else if (InAppNotificationTypes.REACTION === type) {
guild = a0.guild;
value = undefined;
id = guild == null ? value : guild.id;
r5 = id ?? (a0.channel == null ? value : a0.channel.guild_id);
channel = a0.channel;
id = channel == null ? value : channel.id;
message = a0.message;
r1 = message == null ? value : message.id;
r2 = id;
r3 = r5;
} else if (InAppNotificationTypes.ALERT === type) {
guild = a0.guild;
value = undefined;
id = guild == null ? value : guild.id;
r5 = id ?? (a0.channel == null ? value : a0.channel.guild_id);
channel = a0.channel;
id = channel == null ? value : channel.id;
r1 = value;
r2 = id;
r3 = r5;
} else if (InAppNotificationTypes.FORUM_THREAD_CREATED === type) {
thread = a0.thread;
value = undefined;
guild_id = thread == null ? value : thread.guild_id;
thread = a0.thread;
id = thread == null ? value : thread.id;
r1 = value;
r2 = id;
r3 = guild_id;
} else if (InAppNotificationTypes.MESSAGE_FAILED_TO_SEND === type) {
channelId = a0.channelId;
value = undefined;
r1 = value;
r2 = channelId;
r3 = value;
} else {
MESSAGE_REMINDER = InAppNotificationTypes.MESSAGE_REMINDER;
value = undefined;
if (MESSAGE_REMINDER !== type) {
r1 = value;
r2 = value;
r3 = value;
} else {
channel = a0.channel;
guild_id = channel == null ? value : channel.guild_id;
channel = a0.channel;
id = channel == null ? value : channel.id;
r1 = value;
r2 = id;
r3 = guild_id;
}
}
return {guildId: r3, channelId: r2, messageId: r1};
}
function getNotificationTitle(a0, {nick}, a2, a3) { // fn#83691, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:1283, offset: 0x01f24f35, size: 476 bytes, params: 5, frame: 26
var r11;
var moduleValue2;
const channelName = UseChannelNameModule.computeChannelName(a0, UserStore, RelationshipStore, true);
if (a2 != null) {
moduleValue2 = UseChannelNameModule;
r11 = moduleValue2.computeChannelName(a2, UserStore, RelationshipStore);
} else {
r11 = null;
}
const type = a0.type;
const GROUP_DM = ChannelTypes.GROUP_DM;
return GROUP_DM === type ? '' + nick + ' (' + channelName + ')' : ChannelTypes.GUILD_TEXT === type || ChannelTypes.GUILD_ANNOUNCEMENT === type ? a3 == null ? nick : '' + nick + ' (' + channelName + ', ' + a3.name + ')' : ChannelTypes.ANNOUNCEMENT_THREAD === type || ChannelTypes.PUBLIC_THREAD === type ? a2 != null ? '' + nick + ' (' + channelName + ', ' + r11 + ')' : a3 != null ? '' + nick + ' (' + channelName + ', ' + a3.name + ')' : '' + nick + ' (' + channelName + ')' : ChannelTypes.PRIVATE_THREAD !== type ? nick : a2 != null ? '' + nick + ' (' + channelName + ', ' + r11 + ')' : a3 != null ? '' + nick + ' (' + channelName + ', ' + a3.name + ')' : '' + nick + ' (' + channelName + ')';
}
function getNotificationBodyText({notificationMessageContent, isGdmAllReactionNotification, messageAuthor, emojiHook}) { // fn#83692, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:1747, offset: 0x01f25111, size: 229 bytes, params: 2, frame: 19
var r1;
let value = notificationMessageContent != null;
if (value) {
value = notificationMessageContent.trim();
value = value !== '';
r1 = value;
} else {
r1 = value;
}
const intl = (IndexNativeModule).intl;
const format = intl.format;
const t = (IndexNativeModule).t;
return isGdmAllReactionNotification ? r1 ? Reflect.apply(format, intl, [t.MJPwfg, {emojiHook: emojiHook,
username: messageAuthor.nick}]) : Reflect.apply(format, intl, [t.FpJqb0, {emojiHook: emojiHook,
username: messageAuthor.nick}]) : r1 ? Reflect.apply(format, intl, [t.sHV43G,
{emojiHook: emojiHook}]) : Reflect.apply(format, intl, [t.ZOzpKt, {emojiHook: emojiHook}]);
}
function isReactionMilestoneNotification(a0, a1) { // fn#83693, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2188, offset: 0x01f251f6, size: 92 bytes, params: 3, frame: 14
if (a1 == null) {
return false;
}
const GUILD_ANNOUNCEMENT = ChannelTypes.GUILD_ANNOUNCEMENT;
if (a1 === GUILD_ANNOUNCEMENT) {
return false;
}
return REACTION_MILESTONE_COUNTS.has((require(22) /* metro dependency 22 */).sumBy(a0, function({count_details}) {
var r5;
var value = undefined;
r5 = count_details == null ? value : count_details.burst;
var value2 = 0;
return (r5 ?? value2) + ((count_details == null ? value : count_details.normal) ?? value2);
}));
}
function generateInAppNotificationId() { // fn#83695, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2468, offset: 0x01f25299, size: 37 bytes, params: 1, frame: 11
return (Module00491Module).v4();
}
function useHasPreviewableMedia(a0) { // fn#83696, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2553, offset: 0x01f252be, size: 44 bytes, params: 2, frame: 14
const env0_0 = a0;
return ReactModule.useMemo(_fun83697, [a0]);
function _fun83697() { // fn#83697, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2606, offset: 0x01f252ea, size: 91 bytes, params: 1, frame: 14
var environment;
var r0;
let value = environment.__proto__;
const hasMedia2 = hasMedia(env0_0);
if (hasMedia2) {
r0 = hasMedia2;
} else {
value = importDefault(4845) /* metro dependency 4845: isForwardMessage */;
value = value(env0_0);
r0 = value && env0_0.messageSnapshots.some(function(a0) {
return hasMedia(a0.message);
});
}
return r0;
}
}
}
function _fun83694({count_details}) { // fn#83694, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11107:2303, offset: 0x01f25252, size: 71 bytes, params: 2, frame: 7
return (count_details?.burst ?? 0) + (count_details?.normal ?? 0);
}
global.__d(_fun83687, 10921, [31, 3793, 1878, 10922, 661, 4805, 1244, 22, 491, 4845, 4863,
2]) /* metro module 10921, dependencies: [31, 3793, 1878, 10922, 661, 4805, 1244, 22, 491, 4845, 4863, 2] */;