360 lines
14 KiB
TypeScript
360 lines
14 KiB
TypeScript
/* Metro module 11875; source: actions/native/PushNotificationActionCreators.tsx; dependencies: [5, 11876, 1226, 661, 5079, 3, 692, 507, 1216, 11880, 587, 5046, 477, 480, 1360, 694, 2] */
|
|
function _fun91078(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#91078, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:6, offset: 0x020523dc, size: 400 bytes, params: 8, frame: 19
|
|
var object2;
|
|
const env0_0 = require;
|
|
const getOrRefreshPushSyncToken = function() {
|
|
return _getOrRefreshPushSyncToken.apply(this, arguments);
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_4 = importDefault(5) /* metro dependency 5 */;
|
|
const multiAccountStore = importDefault(11876) /* metro dependency 11876: MultiAccountStore */;
|
|
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
|
|
let value = require(661) /* metro dependency 661: Constants */;
|
|
const env0_7 = value.DEVICE_TOKEN;
|
|
const env0_8 = value.DEVICE_VOIP_TOKEN;
|
|
const env0_9 = value.Endpoints;
|
|
value = require(5079) /* metro dependency 5079: PushNotificationConstants */;
|
|
const env0_10 = value.BUNDLE_ID;
|
|
const env0_11 = value.DEVICE_PUSH_VOIP_PROVIDER;
|
|
const env0_12 = value.getDevicePushProvider;
|
|
const env0_13 = value.IS_QUEST_RELEASE;
|
|
value = importDefault(3) /* metro dependency 3: Logger */;
|
|
value = new value('PushNotificationActionCreators');
|
|
object2 = {registerDevice: registerDevice, syncDevice: syncDevice, unregisterDevice: unregisterDevice};
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('actions/native/PushNotificationActionCreators.tsx');
|
|
exports.default = object2;
|
|
exports.setPushPermissionState = setPushPermissionState;
|
|
exports.setPushPermissionReactivationSeen = setPushPermissionReactivationSeen;
|
|
exports.setPushNotificationPermissionEligibleForPrompt = setPushNotificationPermissionEligibleForPrompt;
|
|
exports.updateNotificationAuthorizationStatus = updateNotificationAuthorizationStatus;
|
|
}
|
|
|
|
function _getOrRefreshPushSyncToken() { // fn#91080, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:433, offset: 0x0205256c, size: 50 bytes, params: 1, frame: 14
|
|
return env0_4(_fun91082).apply(this, arguments);
|
|
}
|
|
|
|
function registerDevice(a0) { // fn#91083, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:868, offset: 0x020526ba, size: 355 bytes, params: 2, frame: 24
|
|
var r8;
|
|
var r0;
|
|
var defaultImport;
|
|
var post;
|
|
var object4;
|
|
var object5;
|
|
var object6;
|
|
const value = a1;
|
|
const r1 = value !== undefined ? value : false;
|
|
const canUseMultiAccountNotifications = MultiAccountStore.canUseMultiAccountNotifications;
|
|
env0_14.log('Registering push notification token: ' + a0 + ', is voip:' + r1 + ', multi-account:' + canUseMultiAccountNotifications);
|
|
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
|
|
Storage.set(r1 ? DEVICE_VOIP_TOKEN : DEVICE_TOKEN, a0);
|
|
if (canUseMultiAccountNotifications) {
|
|
r0 = this.syncDevice(a0, r1);
|
|
} else {
|
|
defaultImport = importDefault(5046) /* metro dependency 5046: TrackedHTTPUtils */;
|
|
post = defaultImport.post;
|
|
object4 = {};
|
|
object4.url = Endpoints.DEVICES;
|
|
object5 = {};
|
|
r8 = r1 ? DEVICE_PUSH_VOIP_PROVIDER : getDevicePushProvider();
|
|
object5.provider = r8;
|
|
object5.token = a0;
|
|
r8 = (require(477) /* metro dependency 477: PlatformUtils */).isAndroid() && !IS_QUEST_RELEASE;
|
|
object5.bypass_server_throttling_supported = r8;
|
|
object5.bundle_id = BUNDLE_ID;
|
|
object4.body = object5;
|
|
object4.oldFormErrors = true;
|
|
object6 = {};
|
|
object6.event = (require(480) /* metro dependency 480: AnalyticsUtils */).NetworkActionNames.USER_REGISTER_DEVICE_TOKEN;
|
|
object4.trackedActionData = object6;
|
|
object4.rejectWithError = false;
|
|
r0 = Reflect.apply(post, defaultImport, [object4]);
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function syncDevice(a0) { // fn#91084, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:1340, offset: 0x0205281d, size: 49 bytes, params: 2, frame: 12
|
|
const value = a1;
|
|
const env0_0 = a0;
|
|
const env0_1 = value !== undefined ? value : false;
|
|
return env0_4(_fun91086)();
|
|
}
|
|
|
|
function unregisterDevice(a0) { // fn#91088, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:1891, offset: 0x02052a34, size: 165 bytes, params: 2, frame: 17
|
|
env0_14.log('Unregistering push notification token: ' + a0);
|
|
const defaultImport = importDefault(5046) /* metro dependency 5046: TrackedHTTPUtils */;
|
|
const object3 = {};
|
|
const DEVICES = Endpoints.DEVICES;
|
|
object3.url = DEVICES;
|
|
const object4 = {};
|
|
object4.provider = getDevicePushProvider();
|
|
object4.token = a0;
|
|
object3.body = object4;
|
|
const NetworkActionNames = (require(480) /* metro dependency 480: AnalyticsUtils */).NetworkActionNames;
|
|
const USER_UNREGISTER_DEVICE_TOKEN = NetworkActionNames.USER_UNREGISTER_DEVICE_TOKEN;
|
|
object3.trackedActionData = {event: USER_UNREGISTER_DEVICE_TOKEN};
|
|
object3.rejectWithError = false;
|
|
return defaultImport.delete(object3);
|
|
}
|
|
|
|
function setPushPermissionState(a0) { // fn#91089, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:2234, offset: 0x02052ad9, size: 54 bytes, params: 2, frame: 12
|
|
const env0_0 = a0;
|
|
(importDefault(694) /* metro dependency 694: Dispatcher */).wait(_fun91090);
|
|
}
|
|
|
|
function setPushPermissionReactivationSeen(a0) { // fn#91091, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:2414, offset: 0x02052b4c, size: 57 bytes, params: 2, frame: 13
|
|
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'PUSH_NOTIFICATION_PERMISSION_REACTIVATION_SEEN',
|
|
promptType: a0});
|
|
}
|
|
|
|
function setPushNotificationPermissionEligibleForPrompt(a0) { // fn#91092, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:2598, offset: 0x02052b85, size: 57 bytes, params: 2, frame: 13
|
|
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'PUSH_NOTIFICATION_PERMISSION_SET_ELIGIBLE',
|
|
promptType: a0});
|
|
}
|
|
|
|
function updateNotificationAuthorizationStatus(a0) { // fn#91093, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:2781, offset: 0x02052bbe, size: 57 bytes, params: 2, frame: 13
|
|
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'PUSH_NOTIFICATION_AUTHORIZATION_STATUS_UPDATE',
|
|
authorizationStatus: a0});
|
|
}
|
|
|
|
function* _fun91082(a0) { // fn#91082, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:508, offset: 0x020525a9, size: 273 bytes, params: 2, frame: 20
|
|
var binding2;
|
|
var property;
|
|
var value5;
|
|
var HTTP;
|
|
var get;
|
|
var object3;
|
|
var DEVICES_SYNC_TOKEN;
|
|
var object4;
|
|
var value6;
|
|
var value7;
|
|
var value8;
|
|
var body;
|
|
var token;
|
|
var error;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
if (a0.pushSyncToken != null) {
|
|
return a0.pushSyncToken;
|
|
}
|
|
value = environment.__proto__.__proto__;
|
|
let binding = env2_2;
|
|
const token2 = binding(env2_3[6]).getToken(a0.id);
|
|
if (token2 == null) {
|
|
return null;
|
|
}
|
|
try {
|
|
binding = env2_0;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
binding2 = env2_3;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
property = binding2[7];
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
value5 = binding(property);
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
HTTP = value5.HTTP;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
get = HTTP.get;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
object3 = {};
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
binding = env2_9;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
DEVICES_SYNC_TOKEN = binding.DEVICES_SYNC_TOKEN;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
object3.url = DEVICES_SYNC_TOKEN;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
object4 = {};
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
object4.authorization = token2;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
object3.headers = object4;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
object3.rejectWithError = false;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
value6 = Reflect.apply(get, HTTP, [object3]);
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
yield value6;
|
|
try {
|
|
value7 = undefined;
|
|
value8 = false;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
if (value8) {
|
|
return value7;
|
|
}
|
|
try {
|
|
body = value7.body;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
try {
|
|
token = body.token;
|
|
} catch (error) {
|
|
binding = env2_1;
|
|
value = binding(env2_3[8]);
|
|
value.captureException(error);
|
|
return null;
|
|
}
|
|
value = env2_2(env2_3[9]);
|
|
value.updatePushSyncToken(a0.id, token);
|
|
return token;
|
|
}
|
|
|
|
function* _fun91086() { // fn#91086, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:1353, offset: 0x02052859, size: 424 bytes, params: 1, frame: 21
|
|
var environment;
|
|
if (true) {
|
|
var env0_0;
|
|
value = environment.__proto__.__proto__;
|
|
var binding = env2_6;
|
|
env0_0 = binding.getId();
|
|
var Promise = global.Promise;
|
|
var all = Promise.all;
|
|
var value4 = env2_5.getValidUsers().sort(_fun91087);
|
|
yield Reflect.apply(all, Promise, [value4.map(env2_15)]);
|
|
var value5 = undefined;
|
|
if (false) {
|
|
return value5;
|
|
}
|
|
if (!(value5.length < 1)) {
|
|
if (value5[0] == null) {
|
|
return undefined;
|
|
}
|
|
binding = env2_0;
|
|
var HTTP = binding(env2_3[7]).HTTP;
|
|
var put = HTTP.put;
|
|
var object3 = {};
|
|
var DEVICES_SYNC = env2_9.DEVICES_SYNC;
|
|
object3.url = DEVICES_SYNC;
|
|
var object4 = {};
|
|
object4.provider = importDefault ? env2_11 : env2_12();
|
|
object4.token = require;
|
|
var filter = value5.filter;
|
|
binding = env2_0;
|
|
var binding2 = env2_3;
|
|
object4.push_sync_tokens = Reflect.apply(filter, value5, [binding(binding2[14]).isNotNullish]);
|
|
object4.bypass_server_throttling_supported = binding(binding2[12]).isAndroid() && !env2_13;
|
|
object4.bundle_id = env2_10;
|
|
object3.body = object4;
|
|
object3.rejectWithError = false;
|
|
yield Reflect.apply(put, HTTP, [object3]);
|
|
var value11 = undefined;
|
|
if (false) {
|
|
return value11;
|
|
}
|
|
if (value11.body.invalid_push_sync_tokens.length > 0) {
|
|
value = env2_2(env2_3[9]);
|
|
value.invalidatePushSyncTokens(value11.body.invalid_push_sync_tokens);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function _fun91090() { // fn#91090, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:2284, offset: 0x02052b0f, size: 61 bytes, params: 1, frame: 13
|
|
const value = environment.__proto__;
|
|
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'PUSH_NOTIFICATION_PERMISSION_SET_STATE',
|
|
permissionState: env0_0});
|
|
}
|
|
|
|
function _fun91087({id}, a1) { // fn#91087, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12061:1425, offset: 0x02052a01, size: 51 bytes, params: 3, frame: 4
|
|
return id === env0_0 ? -1 : a1.id !== env0_0 ? 0 : 1;
|
|
}
|
|
|