307 lines
18 KiB
TypeScript
307 lines
18 KiB
TypeScript
/* Metro module 11997; source: modules/contact_sync/native/ContactSyncUtils.tsx; dependencies: [5, 27, 5040, 11996, 11995, 661, 478, 5046, 480, 694, 11998, 3829, 1216, 566, 1391, 1948, 3853, 5080, 2] */
|
|
import Module00005 from '../../../by-id/module-00005.js'; /* Metro dependency 5 */
|
|
import ConnectedAccountsStore from '../../../stores/ConnectedAccountsStore.tsx'; /* Metro dependency 5040 */
|
|
import TrackedHTTPUtils from '../../../utils/TrackedHTTPUtils.tsx'; /* Metro dependency 5046 */
|
|
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 PlatformUtilsModule from '../../../external/discord_common/js/shared/utils/PlatformUtils.tsx'; /* Metro dependency 478 */
|
|
import * as AnalyticsUtilsModule from '../../../external/discord_common/js/packages/analytics-utils/AnalyticsUtils.tsx'; /* Metro dependency 480 */
|
|
import * as FluxModule from '../../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
|
|
import * as FlagUtilsModule from '../../../external/discord_common/js/shared/utils/FlagUtils.tsx'; /* Metro dependency 1391 */
|
|
import * as UserSettingsModule from '../../user_settings/UserSettings.tsx'; /* Metro dependency 3829 */
|
|
import * as ContactSyncPersistedStoreModule from './ContactSyncPersistedStore.tsx'; /* Metro dependency 11996 */
|
|
import * as ContactSyncManagerModule from './ContactSyncManager.tsx'; /* Metro dependency 11998 */
|
|
|
|
function _fun92150(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#92150, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:6, offset: 0x0207e29e, size: 624 bytes, params: 8, frame: 23
|
|
const env0_0 = require;
|
|
const isContactSyncEnabled2 = isContactSyncEnabled;
|
|
const closure2 = function() {
|
|
return importDefault(dependencyMap[15]).getArticleURL(HelpdeskArticles.CONTACT_SYNC);
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let value = ContactSyncPersistedStoreModule;
|
|
const env0_6 = value.useContactSyncStore;
|
|
const env0_7 = value.clearDismissState;
|
|
const env0_8 = value.deleteStoredContacts;
|
|
value = require(11995) /* metro dependency 11995: ContactSyncConstants */;
|
|
const env0_9 = value.CONTACT_SYNC_MODAL_KEY;
|
|
const env0_10 = value.ContactPermissions;
|
|
const env0_11 = value.ContactSyncSuggestionsSetting;
|
|
value = require(661) /* metro dependency 661: Constants */;
|
|
const env0_12 = value.Endpoints;
|
|
const env0_13 = value.PlatformTypes;
|
|
const env0_14 = value.FriendDiscoveryFlags;
|
|
const env0_15 = value.HelpdeskArticles;
|
|
let Error = global.Error;
|
|
let error = new Error('No contact permissions');
|
|
Error = global.Error;
|
|
error = new Error('No phone number');
|
|
Error = global.Error;
|
|
error = new Error('Failed to fetch contact image');
|
|
const isContactSyncAvailable2 = isContactSyncAvailable;
|
|
const value6 = _fun92154();
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/contact_sync/native/ContactSyncUtils.tsx');
|
|
exports.ContactSyncPermissionDenied = error;
|
|
exports.ContactSyncFailedUserHasNoPhone = error;
|
|
exports.ContactImageFetchFailed = error;
|
|
exports.isContactSyncAvailable = isContactSyncAvailable2;
|
|
exports.checkContactPermissions = checkContactPermissions;
|
|
exports.uploadContacts = value6;
|
|
exports.bulkAddFriends = bulkAddFriends;
|
|
exports.adminDeleteContactSync = adminDeleteContactSync;
|
|
exports.getImageForContactId = getImageForContactId;
|
|
exports.getContacts = getContacts;
|
|
exports.getStoredContacts = getStoredContacts;
|
|
exports.useContactSyncAccount = function() {
|
|
return require(dependencyMap[13]).useStateFromStores([ConnectedAccountsStore], _fun92172);
|
|
};
|
|
exports.useContactSyncEnabled = function() {
|
|
return require(dependencyMap[13]).useStateFromStores([ConnectedAccountsStore], _fun92174);
|
|
};
|
|
exports.useContactSyncUserIsDiscoverable = useContactSyncUserIsDiscoverable;
|
|
exports.isContactSyncEnabled = isContactSyncEnabled2;
|
|
exports.getOpenLearnMoreUrl = closure2;
|
|
exports.handleOpenLearnMoreLink = function() {
|
|
importDefault(dependencyMap[16]).openURL(getOpenLearnMoreUrl());
|
|
};
|
|
exports.transitionToAddFriendsLandingPage = function() {
|
|
importDefault(dependencyMap[17]).popWithKey(CONTACT_SYNC_MODAL_KEY);
|
|
};
|
|
function isContactSyncEnabled(a0) { // fn#92151, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:1173, offset: 0x0207e50e, size: 45 bytes, params: 2, frame: 3
|
|
return a0 != null && a0.friendSync && a0.type === PlatformTypes.CONTACTS;
|
|
}
|
|
|
|
function isContactSyncAvailable() { // fn#92153, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:542, offset: 0x0207e56b, size: 88 bytes, params: 1, frame: 13
|
|
const value2 = undefined;
|
|
const isIOS2 = (PlatformUtilsModule).isIOS();
|
|
return isIOS2 ? !!isIOS2 : (NativeModules.DCDContactSyncManager == null ? value2 : NativeModules.DCDContactSyncManager.isContactSyncSupported) ?? (NativeModules.DCDContactSyncManager == null ? value2 : NativeModules.DCDContactSyncManager.isContactSyncSupported) != null;
|
|
}
|
|
|
|
function _fun92154() { // fn#92154, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:662, offset: 0x0207e5c3, size: 36 bytes, params: 1, frame: 12
|
|
const env0_0 = Module00005(_fun92156);
|
|
return _fun92158;
|
|
async function _fun92156(a0) { // fn#92156, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:682, offset: 0x0207e5fb, size: 269 bytes, params: 2, frame: 21
|
|
let value = a1;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
const r8 = value !== undefined ? value : false;
|
|
await undefined;
|
|
if (false) {
|
|
return undefined;
|
|
}
|
|
const JSON = global.JSON;
|
|
value = JSON.parse(a0);
|
|
const binding = env2_1;
|
|
const binding2 = env2_2;
|
|
const value6 = binding(binding2[7]);
|
|
const put = value6.put;
|
|
const object = {};
|
|
const CONNECTION_SYNC_CONTACTS = env2_12.CONNECTION_SYNC_CONTACTS;
|
|
object.url = CONNECTION_SYNC_CONTACTS;
|
|
const ANYONE_WITH_CONTACT_INFO = env2_11.ANYONE_WITH_CONTACT_INFO;
|
|
object.body = {friend_list_entries: value, background: r8, allowed_in_suggestions: ANYONE_WITH_CONTACT_INFO,
|
|
include_mutual_friends_count: false};
|
|
const NetworkActionNames = env2_0(binding2[8]).NetworkActionNames;
|
|
const USER_CONTACTS_SYNC = NetworkActionNames.USER_CONTACTS_SYNC;
|
|
object.trackedActionData = {event: USER_CONTACTS_SYNC};
|
|
object.rejectWithError = false;
|
|
await Reflect.apply(put, value6, [object]);
|
|
value = undefined;
|
|
if (false) {
|
|
return value;
|
|
}
|
|
const body = value.body;
|
|
env2_1(env2_2[9]).wait(_fun92157);
|
|
return body;
|
|
function _fun92157() { // fn#92157, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:1017, offset: 0x0207e708, size: 65 bytes, params: 1, frame: 12
|
|
const value = environment.__proto__.__proto__.__proto__;
|
|
return env3_1(env3_2[9]).dispatch({type: 'LOAD_FRIEND_SUGGESTIONS_SUCCESS', suggestions: body.friend_suggestions});
|
|
}
|
|
|
|
}
|
|
|
|
function _fun92158() { // fn#92158, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:1127, offset: 0x00c3945f, size: 30 bytes, params: 1, frame: 13
|
|
return env0_0.apply(this, arguments);
|
|
}
|
|
|
|
}
|
|
|
|
function checkContactPermissions() { // fn#92159, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:1591, offset: 0x0207e749, size: 70 bytes, params: 1, frame: 12
|
|
return isContactSyncAvailable() ? NativeModules.DCDContactSyncManager.hasContactsPermissions() : global.Promise.resolve(ContactPermissions.UNAUTHORIZED);
|
|
}
|
|
|
|
function bulkAddFriends(a0, a1) { // fn#92160, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:1739, offset: 0x0207e78f, size: 141 bytes, params: 3, frame: 16
|
|
const defaultImport = TrackedHTTPUtils;
|
|
const post = defaultImport.post;
|
|
const object = {};
|
|
const USER_BULK_RELATIONSHIPS = Endpoints.USER_BULK_RELATIONSHIPS;
|
|
object.url = USER_BULK_RELATIONSHIPS;
|
|
object.body = {user_ids: a0, token: a1};
|
|
const NetworkActionNames = (AnalyticsUtilsModule).NetworkActionNames;
|
|
const USER_BULK_RELATIONSHIPS_UPDATE = NetworkActionNames.USER_BULK_RELATIONSHIPS_UPDATE;
|
|
object.trackedActionData = {event: USER_BULK_RELATIONSHIPS_UPDATE};
|
|
object.rejectWithError = false;
|
|
return Reflect.apply(post, defaultImport, [object]).then(function(a0) {
|
|
return a0.body;
|
|
});
|
|
}
|
|
|
|
function adminDeleteContactSync() { // fn#92162, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:1965, offset: 0x0207e81c, size: 195 bytes, params: 1, frame: 20
|
|
clearDismissState();
|
|
deleteStoredContacts();
|
|
(ContactSyncManagerModule).removeLastUserContactsUpload();
|
|
const ContactSyncEnabled = (UserSettingsModule).ContactSyncEnabled;
|
|
ContactSyncEnabled.updateSetting(false);
|
|
const defaultImport = TrackedHTTPUtils;
|
|
const object = {};
|
|
const CONNECTION = Endpoints.CONNECTION;
|
|
const CONTACTS = PlatformTypes.CONTACTS;
|
|
object.url = Reflect.apply(CONNECTION, Endpoints, [CONTACTS, '@me']);
|
|
object.oldFormErrors = true;
|
|
const NetworkActionNames = (AnalyticsUtilsModule).NetworkActionNames;
|
|
const USER_CONNECTIONS_UPDATE = NetworkActionNames.USER_CONNECTIONS_UPDATE;
|
|
object.trackedActionData = {event: USER_CONNECTIONS_UPDATE};
|
|
object.rejectWithError = false;
|
|
return defaultImport.delete(object);
|
|
}
|
|
|
|
function getImageForContactId(a0) { // fn#92163, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2255, offset: 0x0207e8df, size: 63 bytes, params: 2, frame: 11
|
|
const env0_0 = a0;
|
|
const env0_1 = NativeModules.DCDContactSyncManager;
|
|
const Promise = global.Promise;
|
|
const value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
const promise = new Promise(_fun92164);
|
|
return promise instanceof Object ? promise : value;
|
|
function _fun92164(a0, a1) { // fn#92164, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2309, offset: 0x0207e91e, size: 50 bytes, params: 3, frame: 13
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
DCDContactSyncManager.getImageForContactId(env0_0, _fun92165);
|
|
function _fun92165(a0, a1) { // fn#92165, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2343, offset: 0x0207e950, size: 82 bytes, params: 3, frame: 14
|
|
var value;
|
|
if (a0 == null) {
|
|
env0_0(a1.replace(RegExp('(\\r\\n|\\n|\\r)', 'gm'), ''));
|
|
} else {
|
|
value = environment.__proto__.__proto__;
|
|
require(env2_17);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getContacts(a0) { // fn#92166, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2420, offset: 0x0207e9a2, size: 84 bytes, params: 2, frame: 12
|
|
let value = a1;
|
|
const env0_0 = a0;
|
|
const env0_1 = value !== undefined ? value : '';
|
|
const env0_2 = NativeModules.DCDContactSyncManager;
|
|
const Promise = global.Promise;
|
|
value = Object.create(Promise.prototype, {constructor: {value: Promise}});
|
|
const promise = new Promise(function(a0, a1) {
|
|
DCDContactSyncManager.syncContacts(a1, a0, _fun92168);
|
|
});
|
|
return promise instanceof Object ? promise : value;
|
|
function _fun92167(a0, a1) { // fn#92167, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2481, offset: 0x0207e9f6, size: 55 bytes, params: 3, frame: 15
|
|
DCDContactSyncManager.syncContacts(a1, a0, _fun92168);
|
|
function _fun92168(a0, a1, a2) { // fn#92168, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2509, offset: 0x0207ea2d, size: 178 bytes, params: 4, frame: 18
|
|
var environment;
|
|
var r2;
|
|
var unencryptedName;
|
|
var value4;
|
|
var JSON;
|
|
var value5;
|
|
var error;
|
|
var value7;
|
|
const value = undefined;
|
|
const value2 = null;
|
|
if (value2 == a0) {
|
|
try {
|
|
JSON = global.JSON;
|
|
value5 = JSON.parse(a1);
|
|
r2 = value5;
|
|
} catch (error) {
|
|
r2 = {};
|
|
}
|
|
value7 = global.Object.values(r2).find(_fun92169);
|
|
unencryptedName = value2 == value7 ? value : value7.unencryptedName;
|
|
env0_0({names: a1, ownName: value2 != unencryptedName ? unencryptedName : value2, payload: a2});
|
|
} else {
|
|
value4 = environment.__proto__.__proto__;
|
|
require(env2_16);
|
|
}
|
|
return value;
|
|
function _fun92169({phone}) { // fn#92169, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2615, offset: 0x0207eadf, size: 22 bytes, params: 2, frame: 2
|
|
return phone === env2_0;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getStoredContacts() { // fn#92170, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2742, offset: 0x0207eaf5, size: 87 bytes, params: 1, frame: 14
|
|
var r0;
|
|
var JSON;
|
|
var value2;
|
|
var error;
|
|
let value = environment;
|
|
const getState = useContactSyncStore.getState;
|
|
try {
|
|
JSON = global.JSON;
|
|
value2 = JSON.parse(Reflect.apply(getState, useContactSyncStore, []).storedContacts);
|
|
r0 = value2;
|
|
} catch (error) {
|
|
value = importDefault(1216) /* metro dependency 1216: SentryUtilsNative */;
|
|
value.captureException(error);
|
|
r0 = {};
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function useContactSyncAccount() { // fn#92171, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2903, offset: 0x0207eb4c, size: 59 bytes, params: 1, frame: 13
|
|
return (require(566) /* metro dependency 566: flux */).useStateFromStores([ConnectedAccountsStore], function() {
|
|
return ConnectedAccountsStore.getLocalAccount(PlatformTypes.CONTACTS);
|
|
});
|
|
function _fun92172() { // fn#92172, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:2976, offset: 0x0207eb87, size: 30 bytes, params: 1, frame: 11
|
|
const connectedAccountsStoreBinding = ConnectedAccountsStore;
|
|
const getLocalAccount = connectedAccountsStoreBinding.getLocalAccount;
|
|
const CONTACTS = PlatformTypes.CONTACTS;
|
|
return Reflect.apply(getLocalAccount, connectedAccountsStoreBinding, [CONTACTS]);
|
|
}
|
|
|
|
}
|
|
|
|
function useContactSyncEnabled() { // fn#92173, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:3038, offset: 0x0207eba5, size: 59 bytes, params: 1, frame: 13
|
|
return (FluxModule).useStateFromStores([ConnectedAccountsStore], _fun92174);
|
|
function _fun92174() { // fn#92174, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:3111, offset: 0x0207ebe0, size: 41 bytes, params: 1, frame: 12
|
|
const value = environment.__proto__;
|
|
const isContactSyncEnabledBinding = isContactSyncEnabled;
|
|
const connectedAccountsStoreBinding = ConnectedAccountsStore;
|
|
const getLocalAccount = connectedAccountsStoreBinding.getLocalAccount;
|
|
const CONTACTS = PlatformTypes.CONTACTS;
|
|
return isContactSyncEnabledBinding(Reflect.apply(getLocalAccount, connectedAccountsStoreBinding, [CONTACTS]));
|
|
}
|
|
|
|
}
|
|
|
|
function useContactSyncUserIsDiscoverable() { // fn#92175, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12183:3206, offset: 0x0207ec09, size: 127 bytes, params: 1, frame: 18
|
|
const FriendDiscoverySettings = (UserSettingsModule).FriendDiscoverySettings;
|
|
const value2 = FriendDiscoverySettings.useSetting();
|
|
let hasFlag = FlagUtilsModule.hasFlag;
|
|
const FIND_BY_PHONE = FriendDiscoveryFlags.FIND_BY_PHONE;
|
|
const value = Reflect.apply(hasFlag, FlagUtilsModule, [value2, FIND_BY_PHONE]);
|
|
hasFlag = FlagUtilsModule.hasFlag;
|
|
const FIND_BY_EMAIL = FriendDiscoveryFlags.FIND_BY_EMAIL;
|
|
const hasFlag2 = Reflect.apply(hasFlag, FlagUtilsModule, [value2, FIND_BY_EMAIL]);
|
|
return {phone: value, email: hasFlag2, any: value || hasFlag2};
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun92150, 11997, [5, 27, 5040, 11996, 11995, 661, 478, 5046, 480, 694, 11998, 3829, 1216, 566, 1391,
|
|
1948, 3853, 5080,
|
|
2]) /* metro module 11997, dependencies: [5, 27, 5040, 11996, 11995, 661, 478, 5046, 480, 694, 11998, 3829, 1216, 566, 1391, 1948, 3853, 5080, 2] */;
|