/* Metro module 11880; source: modules/multi_account/MultiAccountActionCreators.tsx; dependencies: [5, 1226, 11876, 661, 3, 692, 694, 507, 683, 5076, 2] */ function _fun91139(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#91139, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:6, offset: 0x020539fa, size: 296 bytes, params: 8, frame: 19 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_4 = importDefault(5) /* metro dependency 5 */; const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */; const multiAccountStore = importDefault(11876) /* metro dependency 11876: MultiAccountStore */; let value = require(661) /* metro dependency 661: Constants */; const env0_7 = value.AnalyticEvents; const env0_8 = value.Endpoints; value = importDefault(3) /* metro dependency 3: Logger */; value = new value('MultiAccountActionCreators'); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/multi_account/MultiAccountActionCreators.tsx'); exports.validateMultiAccountTokens = validateMultiAccountTokens; exports.switchAccount = switchAccount; exports.moveAccount = moveAccount; exports.removeAccount = removeAccount_91147; exports.updatePushSyncToken = updatePushSyncToken; exports.invalidatePushSyncTokens = invalidatePushSyncTokens; } function validateMultiAccountTokens() { // fn#91140, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:333, offset: 0x02053b22, size: 62 bytes, params: 1, frame: 12 const env0_0 = AuthenticationStore.getId(); MultiAccountStore.getUsers().forEach(_fun91141()); } function switchAccount(a0, a1, a2) { // fn#91145, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:1479, offset: 0x02053e62, size: 281 bytes, params: 4, frame: 21 var r0; let value = a2; env0_9.log('Switching account to ' + a0, {switchSynchronously: a1}); const token = (importAll(692) /* metro dependency 692: TokenManager */).getToken(a0); const value5 = null; if (value5 == token) { env0_9.log('Switching accounts failed because there was no token'); value = importDefault(694) /* metro dependency 694: Dispatcher */; value.dispatch({type: 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE', userId: a0}); value = global.Promise.resolve(); r0 = value; } else { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'MULTI_ACCOUNT_SWITCH_START', targetUserId: a0, location: value5 != value ? value : value5}); value = importDefault(5076) /* metro dependency 5076: AuthenticationActionCreators */; value = value.switchAccountToken(token, a1); r0 = value; } return r0; } function moveAccount(a0, a1) { // fn#91146, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:1907, offset: 0x02053f7b, size: 63 bytes, params: 3, frame: 13 (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'MULTI_ACCOUNT_MOVE_ACCOUNT', from: a0, to: a1}); } function removeAccount_91147(a0) { // fn#91147, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:2017, offset: 0x02053fba, size: 54 bytes, params: 2, frame: 13 (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'MULTI_ACCOUNT_REMOVE_ACCOUNT', userId: a0}); } function updatePushSyncToken(a0, a1) { // fn#91148, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:2132, offset: 0x02053ff0, size: 64 bytes, params: 3, frame: 13 (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'MULTI_ACCOUNT_UPDATE_PUSH_SYNC_TOKEN', userId: a0, pushSyncToken: a1}); } function invalidatePushSyncTokens(a0) { // fn#91149, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:2284, offset: 0x02054030, size: 57 bytes, params: 2, frame: 13 (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'MULTI_ACCOUNT_INVALIDATE_PUSH_SYNC_TOKENS', invalidPushSyncTokens: a0}); } function _fun91141() { // fn#91141, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:408, offset: 0x02053b60, size: 36 bytes, params: 1, frame: 12 const env0_0 = env1_4(_fun91143); return _fun91144; } async function _fun91143(a0) { // fn#91143, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12066:428, offset: 0x02053b98, size: 714 bytes, params: 2, frame: 26 var id; var r10; var status; var r3; var r6; var value; var value2; var id2; var value3; var value4; var value5; var binding; var value6; var getToken; var value7; var value8; var value9; var dispatch; var object3; var value10; var binding2; var property; var value11; var HTTP; var get; var ME; var object4; var value12; var value13; var value14; var body; var value15; var value16; var value17; var binding3; var value18; var value19; var error; var value20; var value21; var value22; var value23; exceptionSkip41: while (true) { exceptionLanding41: while (true) { value = undefined; value2 = false; if (value2) { return value; } id2 = a0.id; value = undefined; await value; value3 = undefined; value4 = false; if (value4) { return value3; } value5 = environment.__proto__.__proto__.__proto__; binding = env3_2; value6 = binding(env3_3[5]); getToken = value6.getToken; value7 = Reflect.apply(getToken, value6, [id2]); value8 = null; if (value8 == value7) { value9 = env3_1(env3_3[6]); value9.dispatch({type: 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE', userId: id2}); return value; } if (value7 !== '') { binding = env3_1; value10 = binding(env3_3[6]); dispatch = value10.dispatch; Reflect.apply(dispatch, value10, [{type: 'MULTI_ACCOUNT_VALIDATE_TOKEN_REQUEST', userId: id2}]); try { binding = env3_0; } catch (error) { break exceptionLanding41; } try { binding2 = env3_3; } catch (error) { break exceptionLanding41; } try { property = binding2[7]; } catch (error) { break exceptionLanding41; } try { value11 = binding(property); } catch (error) { break exceptionLanding41; } try { HTTP = value11.HTTP; } catch (error) { break exceptionLanding41; } try { get = HTTP.get; } catch (error) { break exceptionLanding41; } try { object3 = {}; } catch (error) { break exceptionLanding41; } try { binding = env3_8; } catch (error) { break exceptionLanding41; } try { ME = binding.ME; } catch (error) { break exceptionLanding41; } try { object3.url = ME; } catch (error) { break exceptionLanding41; } try { object4 = {}; } catch (error) { break exceptionLanding41; } try { object4.authorization = value7; } catch (error) { break exceptionLanding41; } try { object3.headers = object4; } catch (error) { break exceptionLanding41; } try { object3.retries = 3; } catch (error) { break exceptionLanding41; } try { object3.rejectWithError = false; } catch (error) { break exceptionLanding41; } try { value12 = Reflect.apply(get, HTTP, [object3]); } catch (error) { break exceptionLanding41; } await value12; try { value13 = undefined; value14 = false; } catch (error) { break exceptionLanding41; } if (value14) { return value13; } body = value13.body; id = value8 == body ? value : body.id; r10 = value8 != id ? id : value8; if (value8 == r10) { value15 = environment.__proto__.__proto__; if (require !== id2) { value16 = env3_1(env3_3[6]); value16.dispatch({type: 'USER_UPDATE', user: value13.body}); } value17 = env3_1(env3_3[6]); value17.dispatch({type: 'MULTI_ACCOUNT_VALIDATE_TOKEN_SUCCESS', userId: id2}); return value; } if (r10 !== id2) { object3 = {expected_user_id: id2, actual_user_id: r10}; binding = env3_9; binding.log('Found per-user token authentication mismatch', object3); binding = env3_1; binding3 = env3_3; value18 = binding(binding3[8]); value18.track(env3_7.MULTI_ACCOUNT_VALIDATE_TOKEN_USER_MISMATCH, object3); value19 = binding(binding3[6]); value19.dispatch({type: 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE', userId: id2}); return value; } value15 = environment.__proto__.__proto__; if (require !== id2) { value16 = env3_1(env3_3[6]); dispatch = value16.dispatch; body = value13.body; Reflect.apply(dispatch, value16, [{type: 'USER_UPDATE', user: body}]); } binding = env3_1; value17 = binding(env3_3[6]); dispatch = value17.dispatch; Reflect.apply(dispatch, value17, [{type: 'MULTI_ACCOUNT_VALIDATE_TOKEN_SUCCESS', userId: id2}]); return value; } binding = env3_1; value9 = binding(env3_3[6]); dispatch = value9.dispatch; Reflect.apply(dispatch, value9, [{type: 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE', userId: id2}]); return value; break exceptionSkip41; } if (value8 == error) { status = value; value20 = status === 401; if (value20) { r3 = value20; value22 = env3_1(env3_3[6]); dispatch = value22.dispatch; object3 = {}; value23 = 'MULTI_ACCOUNT_VALIDATE_TOKEN_SUCCESS'; if (r3) { object3.type = 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE'; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } object3.type = value23; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } if (value8 == error) { r3 = value === 403; value22 = env3_1(env3_3[6]); dispatch = value22.dispatch; object3 = {}; value23 = 'MULTI_ACCOUNT_VALIDATE_TOKEN_SUCCESS'; if (r3) { object3.type = 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE'; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } object3.type = value23; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } status = error.status; r3 = status === 403; value22 = env3_1(env3_3[6]); dispatch = value22.dispatch; object3 = {}; value23 = 'MULTI_ACCOUNT_VALIDATE_TOKEN_SUCCESS'; if (r3) { object3.type = 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE'; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } object3.type = value23; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } status = error.status; value20 = status === 401; if (value20) { r3 = value20; value22 = env3_1(env3_3[6]); dispatch = value22.dispatch; object3 = {}; value23 = 'MULTI_ACCOUNT_VALIDATE_TOKEN_SUCCESS'; if (r3) { object3.type = 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE'; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } object3.type = value23; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } if (value8 == error) { r3 = value === 403; value22 = env3_1(env3_3[6]); dispatch = value22.dispatch; object3 = {}; value23 = 'MULTI_ACCOUNT_VALIDATE_TOKEN_SUCCESS'; if (r3) { object3.type = 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE'; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } object3.type = value23; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } status = error.status; value21 = status === 403; r3 = value21; binding = env3_1; value22 = binding(env3_3[6]); dispatch = value22.dispatch; object3 = {}; value23 = 'MULTI_ACCOUNT_VALIDATE_TOKEN_SUCCESS'; if (r3) { object3.type = 'MULTI_ACCOUNT_VALIDATE_TOKEN_FAILURE'; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; } r6 = value23; object3.type = r6; object3.userId = id2; Reflect.apply(dispatch, value22, [object3]); return value; break exceptionSkip41; } }