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

406 lines
25 KiB
TypeScript

/* Metro module 12998; source: modules/notifications/native/NotificationTokenManager.tsx; dependencies: [6, 7, 15, 17, 18, 27, 1220, 11876, 1226, 12999, 661, 1244, 11875, 694, 10741, 13002, 13003, 1216, 2518, 477, 13004, 683, 4561, 2] */
import ClassCallCheck from '../../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import ApexExperimentStore from '../../experiments/apex/ApexExperimentStore.tsx'; /* Metro dependency 1220 */
import AuthenticationStore from '../../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */
import LifecycleManager from '../../../lib/LifecycleManager.tsx'; /* Metro dependency 4561 */
import MultiAccountStore from '../../multi_account/MultiAccountStore.tsx'; /* Metro dependency 11876 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as NotificationSettingsConstantsModule from '../NotificationSettingsConstants.tsx'; /* Metro dependency 12999 */
function _fun99146(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#99146, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:6, offset: 0x021bc33e, size: 344 bytes, params: 8, frame: 19
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = LifecycleManager;
value = _fun99150(value);
value = new value();
(FileImportTrackerModule).fileFinishedImporting('modules/notifications/native/NotificationTokenManager.tsx');
exports.default = value;
function _isNativeReflectConstruct_99147() { // fn#99147, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:253, offset: 0x021bc496, size: 98 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_99147_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _fun99150(a0) { // fn#99150, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:456, offset: 0x021bc4f8, size: 253 bytes, params: 2, frame: 16
const NotificationTokenManager2 = NotificationTokenManager;
Inherits(NotificationTokenManager2, a0);
return CreateClass(NotificationTokenManager2, [{key: '_initialize', value: value_99161}, {key: '_terminate',
value: value_99163}, {key: 'registerListener', value: value_99164}, {key: 'registerNotificationCategories',
value: value_99165}, {key: 'registerLegacyNotificationCategories', value: value_99166},
{key: 'trackDisabledAndroidNotifChannels', value: value_99167}, {key: 'getToken', value: function() {
return this.token;
}}, {key: 'canSync', get: get_99172}]);
function NotificationTokenManager(a0) { // fn#99151, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:468, offset: 0x021bc5f5, size: 270 bytes, params: 2, frame: 20
var r0;
var Reflect;
let value = copyRestArgs(0, undefined);
let binding = env1_3;
binding(this, NotificationTokenManager);
const items2 = [];
arraySpread(items2, value, 0, items2);
value = env1_6(NotificationTokenManager);
binding = env1_5;
if (_isNativeReflectConstruct_99147()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items2, env1_6(this).constructor);
r0 = value;
} else {
value = value.apply(this, items2);
r0 = value;
}
value = binding(this, r0);
value._experimentUnsubscribe = null;
value.token = null;
value.hasRegisterEventListener = false;
value.hasTrackedDisabledAndroidNotifChannels = false;
value.postConnectionOpenTimeoutID = null;
value._handleExperimentsUpdated = _handleExperimentsUpdated;
value.handleToken = handleToken;
value.registerToken = registerToken;
value.handleSyncNoMultiAccountOnLoginSuccess = handleSyncNoMultiAccountOnLoginSuccess;
value.handleSyncNoMultiAccountOnRegisterSuccess = handleSyncNoMultiAccountOnRegisterSuccess;
value.handleSyncNoMultiAccountOnPostConnectionOpen = handleSyncNoMultiAccountOnPostConnectionOpen;
value.handleSyncNoMultiAccount = handleSyncNoMultiAccount;
value.handleSyncWithMultiAccount = handleSyncWithMultiAccount;
return value;
function _handleExperimentsUpdated() { // fn#99152, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:906, owner: NotificationTokenManager._handleExperimentsUpdated, offset: 0x021bc703, size: 19 bytes, params: 1, frame: 9
return env0_0.registerNotificationCategories();
}
function handleToken(a0) { // fn#99153, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:959, owner: NotificationTokenManager.handleToken, offset: 0x021bc716, size: 43 bytes, params: 2, frame: 10
const binding = env0_0;
binding.token = a0;
if (binding.canSync) {
env0_0.registerToken();
}
}
function registerToken() { // fn#99154, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:1019, owner: NotificationTokenManager.registerToken, offset: 0x021bc741, size: 283 bytes, params: 1, frame: 24
var environment;
var value2;
var DCDNotificationCategoryUtils;
var registerNotificationReplyCategories;
const intl = (IndexNativeModule).intl;
var string;
const t = (IndexNativeModule).t;
var TBA5Xg;
var value3;
var value4;
var defaultImport;
if (env0_0.token != null) {
value2 = environment.__proto__.__proto__;
DCDNotificationCategoryUtils = NativeModules.DCDNotificationCategoryUtils;
registerNotificationReplyCategories = DCDNotificationCategoryUtils.registerNotificationReplyCategories;
string = intl.string;
TBA5Xg = t.TBA5Xg;
value3 = Reflect.apply(string, intl, [TBA5Xg]);
value4 = intl.string(t.TXNS7S);
string = intl.string;
TBA5Xg = t.TBA5Xg;
Reflect.apply(registerNotificationReplyCategories, DCDNotificationCategoryUtils, [value3, value4,
Reflect.apply(string, intl, [TBA5Xg]), function() {
}]);
if (NativeModules.PushNotificationAndroid) {
NativeModules.PushNotificationAndroid.onRegisterNotificationToken();
}
defaultImport = importDefault(11875) /* metro dependency 11875: PushNotificationActionCreators */;
defaultImport.registerDevice(env0_0.token);
}
}
function handleSyncNoMultiAccountOnLoginSuccess() { // fn#99156, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:1396, owner: NotificationTokenManager.handleSyncNoMultiAccountOnLoginSuccess, offset: 0x021bc85c, size: 21 bytes, params: 1, frame: 9
env0_0.handleSyncNoMultiAccount();
}
function handleSyncNoMultiAccountOnRegisterSuccess() { // fn#99157, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:1475, owner: NotificationTokenManager.handleSyncNoMultiAccountOnRegisterSuccess, offset: 0x021bc871, size: 43 bytes, params: 1, frame: 14
const binding = env0_0;
binding.postConnectionOpenTimeoutID = global.setTimeout(binding.handleSyncNoMultiAccountOnPostConnectionOpen, 5000);
}
function handleSyncNoMultiAccountOnPostConnectionOpen() { // fn#99158, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:1621, owner: NotificationTokenManager.handleSyncNoMultiAccountOnPostConnectionOpen, offset: 0x021bc89c, size: 64 bytes, params: 1, frame: 13
var clearTimeout;
var binding;
if (env0_0.postConnectionOpenTimeoutID != null) {
clearTimeout = global.clearTimeout;
binding = env0_0;
clearTimeout(binding.postConnectionOpenTimeoutID);
binding.postConnectionOpenTimeoutID = null;
binding.handleSyncNoMultiAccount();
}
}
function handleSyncNoMultiAccount() { // fn#99159, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:1801, owner: NotificationTokenManager.handleSyncNoMultiAccount, offset: 0x021bc8dc, size: 53 bytes, params: 1, frame: 10
if (env0_0.canSync && !MultiAccountStore.canUseMultiAccountNotifications) {
env0_0.registerToken();
}
}
function handleSyncWithMultiAccount() { // fn#99160, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:1901, owner: NotificationTokenManager.handleSyncWithMultiAccount, offset: 0x021bc911, size: 50 bytes, params: 1, frame: 10
if (env0_0.canSync && MultiAccountStore.canUseMultiAccountNotifications) {
env0_0.registerToken();
}
}
}
function value_99161() { // fn#99161, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:2063, offset: 0x021bc943, size: 241 bytes, params: 1, frame: 18
var environment;
if (this.token != null) {
this.handleToken(this.token);
}
let value = environment.__proto__;
const apexExperimentStoreBinding = ApexExperimentStore;
apexExperimentStoreBinding.addChangeListener(this._handleExperimentsUpdated);
this._experimentUnsubscribe = _experimentUnsubscribe_99162;
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.subscribe('LOGIN_SUCCESS', this.handleSyncNoMultiAccountOnLoginSuccess);
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.subscribe('REGISTER_SUCCESS', this.handleSyncNoMultiAccountOnRegisterSuccess);
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.subscribe('POST_CONNECTION_OPEN', this.handleSyncNoMultiAccountOnPostConnectionOpen);
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.subscribe('POST_CONNECTION_OPEN', this.handleSyncWithMultiAccount);
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.subscribe('MULTI_ACCOUNT_REMOVE_ACCOUNT', this.handleSyncWithMultiAccount);
function value_99161_experimentUnsubscribe() { // fn#99162, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:2201, owner: value_99161._experimentUnsubscribe, offset: 0x021bca34, size: 35 bytes, params: 1, frame: 11
const apexExperimentStoreBinding = ApexExperimentStore;
apexExperimentStoreBinding.removeChangeListener(env0_0._handleExperimentsUpdated);
}
}
function value_99163() { // fn#99163, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:2705, offset: 0x021bca57, size: 200 bytes, params: 1, frame: 18
let value = environment.__proto__;
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.unsubscribe('LOGIN_SUCCESS', this.handleSyncNoMultiAccountOnLoginSuccess);
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.unsubscribe('REGISTER_SUCCESS', this.handleSyncNoMultiAccountOnRegisterSuccess);
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.unsubscribe('POST_CONNECTION_OPEN', this.handleSyncNoMultiAccountOnPostConnectionOpen);
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.unsubscribe('POST_CONNECTION_OPEN', this.handleSyncWithMultiAccount);
value = importDefault(694) /* metro dependency 694: Dispatcher */;
value.unsubscribe('MULTI_ACCOUNT_REMOVE_ACCOUNT', this.handleSyncWithMultiAccount);
if (this._experimentUnsubscribe != null) {
this._experimentUnsubscribe();
this._experimentUnsubscribe = null;
}
}
function value_99164() { // fn#99164, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:3275, offset: 0x021bcb1f, size: 100 bytes, params: 1, frame: 12
if (this.hasRegisterEventListener) {
throw new global.Error('Device token listener already registered.');
}
this.hasRegisterEventListener = true;
let value = environment.__proto__;
value = importDefault(10741) /* metro dependency 10741: PushNotification */;
value.addRegisterEventListener(this.handleToken);
}
function value_99165() { // fn#99165, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:3511, offset: 0x021bcb83, size: 275 bytes, params: 1, frame: 17
var r4;
var enabled;
var property;
var defaultImport;
var value4;
var error;
var defaultImport2;
var clearDeclarative;
var defaultImport3;
var defaultImport4;
let value = environment.__proto__;
const config = require(dependencyMap[15]).declarativeNotifSettingsExperiment.getConfig({location: 'registerNotificationCategories'});
const value3 = false;
try {
enabled = config.enabled;
if (enabled) {
property = dependencyMap[16];
defaultImport = importDefault(property);
value4 = defaultImport.registerDeclarativeNotificationCategories();
r4 = value4;
} else {
r4 = value3;
}
} catch (error) {
defaultImport2 = importDefault(dependencyMap[17]);
defaultImport2.captureException(error);
r4 = value3;
}
if (!r4) {
try {
clearDeclarative = config.clearDeclarative;
if (clearDeclarative) {
property = dependencyMap[17];
defaultImport3 = importDefault(property);
defaultImport3.addBreadcrumb({message: 'Clearing declarative notification categories'});
property = dependencyMap[16];
defaultImport4 = importDefault(property);
defaultImport4.clear();
}
} catch (error) {
value = importDefault(dependencyMap[17]);
value.captureException(error);
}
this.registerLegacyNotificationCategories();
}
this.trackDisabledAndroidNotifChannels();
}
function value_99166() { // fn#99166, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:4048, offset: 0x021bcc96, size: 1563 bytes, params: 1, frame: 21
var object;
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
var object2;
let DCDNotificationCategoryUtils = NativeModules.DCDNotificationCategoryUtils;
const registerNotificationCategories = DCDNotificationCategoryUtils.registerNotificationCategories;
DCDNotificationCategoryUtils = NativeModules.DCDNotificationCategoryUtils;
const registerNotificationCategoriesAndGroups = DCDNotificationCategoryUtils.registerNotificationCategoriesAndGroups;
if (registerNotificationCategoriesAndGroups != null) {
object = {};
object.calls = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */)['IUH/Oe']);
object.mediaConnections = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).VeBD1N);
object.messages = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */)['4qWUAO']);
object.directMessages = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).NGdNZb);
object.friendRequests = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).NxgGZA);
object.polls = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).MOjygY);
object.social = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */)['UzRF+8']);
object.stageLive = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */)['4n388K']);
object.guildEventLive = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */)['40TIqW']);
object.guildHighlights = intl.string(t.p5jg9S);
object.forumThreadCreated = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).HibKoy);
object.systemMessages = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).zJlwvV);
object.other = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).kIrLfg);
object.default = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */)['T+79Eo']);
object.reactions = intl.string(t.gHp0C4);
object2 = {};
object2.realtime = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).S5cB9e);
object2.social = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */)['UzRF+8']);
object2.server = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).zRKbpz);
object2.other = intl.string((importDefault(2518) /* metro dependency 2518: NotificationSettingsMessages */).q5M7HV);
registerNotificationCategoriesAndGroups(object, object2);
} else if (registerNotificationCategories != null) {
object = {};
object.calls = intl.string(t.JJogjm);
object.mediaConnections = intl.string(t.K3lovD);
object.messages = intl.string(t.OIgYlQ);
object.directMessages = intl.string(t.YUU0RF);
object.social = intl.string(t.TdEu5X);
object.gameDetection = intl.string(t['A/4saf']);
object.stageLive = intl.string(t.qGRagm);
object.guildEventLive = intl.string(t.MfGr0a);
object.guildHighlights = intl.string(t.p5jg9S);
object.forumThreadCreated = intl.string(t.dl57ho);
object.other = intl.string(t.BcZTKu);
object.otherHighPriority = intl.string(t.bcv3rp);
registerNotificationCategories(object);
}
}
function value_99167() { // fn#99167, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:5863, offset: 0x021bd2b1, size: 272 bytes, params: 1, frame: 17
var environment;
var getAndroidNotifChannelStates;
var value;
var value2;
var moduleValue;
var androidNotifChannelStates;
var Set;
var value4;
var set;
var value7;
var defaultImport2;
var track;
var ANDROID_NOTIFICATION_CHANNELS_SYNCED;
var object;
if (!this.hasTrackedDisabledAndroidNotifChannels) {
this.hasTrackedDisabledAndroidNotifChannels = true;
value = environment.__proto__;
value2 = undefined;
moduleValue = require(477) /* metro dependency 477: PlatformUtils */;
if (moduleValue.isAndroid()) {
getAndroidNotifChannelStates = (importDefault(13004) /* metro dependency 13004: NativeNotifSettingsModule */) == null ? value2 : (importDefault(13004) /* metro dependency 13004: NativeNotifSettingsModule */).getAndroidNotifChannelStates;
if (getAndroidNotifChannelStates != null) {
androidNotifChannelStates = getAndroidNotifChannelStates();
Set = global.Set;
value4 = NOTIF_SETTINGS.map(function(a0) {
return a0.string_id;
});
set = new Set();
value7 = androidNotifChannelStates.filter(_fun99169);
defaultImport2 = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
track = defaultImport2.track;
ANDROID_NOTIFICATION_CHANNELS_SYNCED = AnalyticEvents.ANDROID_NOTIFICATION_CHANNELS_SYNCED;
object = {};
object.disabled_channels = value7.map(_fun99170);
Reflect.apply(track, defaultImport2, [ANDROID_NOTIFICATION_CHANNELS_SYNCED, object]);
}
}
}
function _fun99169(a0) { // fn#99169, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:6129, offset: 0x021bd3cc, size: 42 bytes, params: 2, frame: 12
return a0.importance === 0 && env0_0.has(a0.channelId);
}
}
function get_99172() { // fn#99172, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:6350, offset: 0x021bd401, size: 50 bytes, params: 1, frame: 10
var r0;
var value;
const isInitialized = this.isInitialized;
if (isInitialized) {
value = environment.__proto__;
value = AuthenticationStore.isAuthenticated();
r0 = value;
} else {
r0 = isInitialized;
}
if (r0) {
value = environment.__proto__;
value = !MultiAccountStore.isSwitchingAccount;
r0 = value;
}
return r0;
}
}
}
function _fun99170(a0) { // fn#99170, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13188:6251, offset: 0x0119ee7e, size: 10 bytes, params: 2, frame: 1
return a0.channelId;
}
global.__d(_fun99146, 12998, [6, 7, 15, 17, 18, 27, 1220, 11876, 1226, 12999, 661, 1244, 11875, 694, 10741, 13002,
13003, 1216, 2518, 477, 13004, 683, 4561,
2]) /* metro module 12998, dependencies: [6, 7, 15, 17, 18, 27, 1220, 11876, 1226, 12999, 661, 1244, 11875, 694, 10741, 13002, 13003, 1216, 2518, 477, 13004, 683, 4561, 2] */;