549 lines
22 KiB
TypeScript
549 lines
22 KiB
TypeScript
/* Metro module 13040; source: modules/rpc/server/commands/setActivity.tsx; dependencies: [4234, 4135, 661, 4122, 8079, 8844, 8076, 694, 6884, 8045, 22, 672, 6873, 683, 2] */
|
|
function _fun99543(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#99543, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13230:6, offset: 0x021ccb42, size: 345 bytes, params: 8, frame: 24
|
|
var object2;
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const applicationStore = importDefault(4234) /* metro dependency 4234: ApplicationStore */;
|
|
let value = require(4135) /* metro dependency 4135: Constants */;
|
|
const RPC_SCOPE_CONFIG = value.RPC_SCOPE_CONFIG;
|
|
const RPC_LOCAL_SCOPE = value.RPC_LOCAL_SCOPE;
|
|
const env0_4 = value.TransportTypes;
|
|
value = require(661) /* metro dependency 661: Constants */;
|
|
const env0_5 = value.ActivityGamePlatforms;
|
|
const env0_6 = value.ActivityPartyPrivacy;
|
|
const env0_7 = value.ActivityTypes;
|
|
const env0_8 = value.AnalyticEvents;
|
|
const RPCCommands = value.RPCCommands;
|
|
const env0_9 = value.RPCErrors;
|
|
const env0_10 = ['1402418171662569542'];
|
|
object2 = {};
|
|
const SET_ACTIVITY = RPCCommands.SET_ACTIVITY;
|
|
const ANY = RPC_SCOPE_CONFIG.ANY;
|
|
const {RPC, RPC_ACTIVITIES_WRITE} = (require(4122) /* metro dependency 4122: OAuth2Scopes */).OAuth2Scopes;
|
|
object2[SET_ACTIVITY] = {scope: {[ANY]: [RPC, RPC_ACTIVITIES_WRITE, RPC_LOCAL_SCOPE]}, validation: validation_99544,
|
|
handler: handler_99545};
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/rpc/server/commands/setActivity.tsx');
|
|
exports.default = object2;
|
|
}
|
|
|
|
function validation_99544(a0) { // fn#99544, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13230:449, offset: 0x021ccc9b, size: 1470 bytes, params: 2, frame: 34
|
|
const value3 = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0).required();
|
|
const keys = value3.keys;
|
|
const object8 = {};
|
|
const value4 = a0.number();
|
|
object8.pid = value4.min(0);
|
|
const value5 = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
const keys2 = value5.keys;
|
|
const object9 = {};
|
|
const value7 = a0.string().min(1);
|
|
object9.name = value7.max(128);
|
|
object9.state = a0.string().min(2).max(128);
|
|
object9.state_url = a0.string().uri().min(1).max(256);
|
|
object9.details = a0.string().min(2).max(128);
|
|
object9.details_url = a0.string().uri().min(1).max(256);
|
|
const value18 = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
const keys3 = value18.keys;
|
|
const object10 = {};
|
|
object10.start = a0.number().min(1);
|
|
object10.end = a0.number().min(1);
|
|
object9.timestamps = Reflect.apply(keys3, value18, [object10]);
|
|
const value21 = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
const keys4 = value21.keys;
|
|
const object11 = {};
|
|
object11.large_image = a0.string().min(1).max(300);
|
|
object11.large_text = a0.string().min(2).max(128);
|
|
object11.large_url = a0.string().uri().min(1).max(256);
|
|
object11.small_image = a0.string().min(1).max(300);
|
|
object11.small_text = a0.string().min(2).max(128);
|
|
object11.small_url = a0.string().uri().min(1).max(256);
|
|
object11.invite_cover_image = a0.string().min(1).max(300);
|
|
object9.assets = Reflect.apply(keys4, value21, [object11]);
|
|
const value38 = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
const keys5 = value38.keys;
|
|
const object12 = {};
|
|
object12.id = a0.string().min(2).max(128);
|
|
const value41 = a0.array();
|
|
let items2 = value41.items;
|
|
const value42 = a0.number();
|
|
object12.size = Reflect.apply(items2, value41, [value42.min(0)]).length(2);
|
|
const value44 = a0.number();
|
|
let PRIVATE = ActivityPartyPrivacy.PRIVATE;
|
|
const value45 = value44.default(PRIVATE);
|
|
let valid = value45.valid;
|
|
PRIVATE = ActivityPartyPrivacy.PRIVATE;
|
|
const PUBLIC = ActivityPartyPrivacy.PUBLIC;
|
|
object12.privacy = Reflect.apply(valid, value45, [[PRIVATE, PUBLIC]]);
|
|
object9.party = Reflect.apply(keys5, value38, [object12]);
|
|
const value46 = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
const keys6 = value46.keys;
|
|
const object13 = {};
|
|
object13.match = a0.string().min(2).max(128);
|
|
object13.join = a0.string().min(2).max(128);
|
|
object13.spectate = a0.string().min(2).max(128);
|
|
object9.secrets = Reflect.apply(keys6, value46, [object13]);
|
|
const value53 = a0.array();
|
|
items2 = value53.items;
|
|
const value54 = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
const keys7 = value54.keys;
|
|
const object14 = {};
|
|
object14.label = a0.string().min(1).max(32).required();
|
|
object14.url = a0.string().uri().min(1).max(512).required();
|
|
object9.buttons = Reflect.apply(items2, value53, [Reflect.apply(keys7, value54, [object14])]).min(1).max(2);
|
|
object9.instance = a0.boolean();
|
|
const value64 = a0.array();
|
|
items2 = value64.items;
|
|
const value66 = a0.string().min(1);
|
|
object9.supported_platforms = Reflect.apply(items2, value64, [value66.max(32)]).min(1).max(10);
|
|
const value69 = a0.number();
|
|
let PLAYING = ActivityTypes.PLAYING;
|
|
const value70 = value69.default(PLAYING);
|
|
valid = value70.valid;
|
|
PLAYING = ActivityTypes.PLAYING;
|
|
const LISTENING = ActivityTypes.LISTENING;
|
|
const WATCHING = ActivityTypes.WATCHING;
|
|
const COMPETING = ActivityTypes.COMPETING;
|
|
object9.type = Reflect.apply(valid, value70, [PLAYING, LISTENING, WATCHING, COMPETING]);
|
|
const value72 = a0.number().optional();
|
|
valid = value72.valid;
|
|
const {NAME, STATE, DETAILS} = (require(8844) /* metro dependency 8844: StatusDisplayTypes */).StatusDisplayTypes;
|
|
object9.status_display_type = Reflect.apply(valid, value72, [NAME, STATE, DETAILS]);
|
|
object8.activity = Reflect.apply(keys2, value5, [object9]).allow(null);
|
|
return Reflect.apply(keys, value3, [object8]);
|
|
}
|
|
|
|
function handler_99545({socket, args, isSocketConnected}) { // fn#99545, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13230:1903, offset: 0x021cd259, size: 1551 bytes, params: 2, frame: 32
|
|
var r8;
|
|
var r12;
|
|
var privacy;
|
|
var r14;
|
|
var r5;
|
|
var prototype;
|
|
var name;
|
|
var application;
|
|
var id;
|
|
var value5;
|
|
var getApplication;
|
|
var value6;
|
|
var instance;
|
|
var party;
|
|
var moduleValue;
|
|
var computeActivityFlags;
|
|
var value8;
|
|
var moduleValue2;
|
|
var canLaunchFrame;
|
|
var canLaunchFrame2;
|
|
var activityFlags;
|
|
var value9;
|
|
var assets;
|
|
var secrets;
|
|
var timestamps;
|
|
var buttons;
|
|
var PLAYING;
|
|
var value11;
|
|
var defaultImport2;
|
|
var intersection;
|
|
var length;
|
|
var binding;
|
|
var defaultImport3;
|
|
var uniq;
|
|
var length2;
|
|
var map;
|
|
var Object;
|
|
var keys;
|
|
var value13;
|
|
var property;
|
|
var Date;
|
|
var now;
|
|
var value14;
|
|
var toString;
|
|
var property2;
|
|
var length3;
|
|
var Math;
|
|
var floor;
|
|
var property3;
|
|
var Millis;
|
|
var SECOND;
|
|
var value15;
|
|
var fetchAssetIds;
|
|
var large_image;
|
|
var small_image;
|
|
var invite_cover_image;
|
|
var Error;
|
|
var error;
|
|
const pid = args.pid;
|
|
const activity = args.activity;
|
|
let value = undefined;
|
|
const IPC = TransportTypes.IPC;
|
|
let object = [IPC];
|
|
const WEBSOCKET = TransportTypes.WEBSOCKET;
|
|
object[1] = WEBSOCKET;
|
|
const POST_MESSAGE = TransportTypes.POST_MESSAGE;
|
|
object[2] = POST_MESSAGE;
|
|
let includes = object.includes;
|
|
if (Reflect.apply(includes, object, [socket.transport])) {
|
|
if (pid == null) {
|
|
reducibleJoin4: while (true) {
|
|
if (TransportTypes.IPC === socket.transport) {
|
|
value = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
value = new value({errorCode: RPCErrors.INVALID_COMMAND}, 'nonzero pid required');
|
|
throw value;
|
|
}
|
|
break reducibleJoin4;
|
|
}
|
|
}
|
|
if (activity == null) {
|
|
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'LOCAL_ACTIVITY_UPDATE',
|
|
socketId: socket.id, pid: pid, activity: activity});
|
|
return global.Promise.resolve(activity);
|
|
}
|
|
object = {};
|
|
name = activity.name;
|
|
reducibleJoin7: while (true) {
|
|
if (name) {
|
|
break reducibleJoin7;
|
|
}
|
|
application = socket.application;
|
|
name = application.name;
|
|
activity.name = name;
|
|
break reducibleJoin7;
|
|
}
|
|
application = socket.application;
|
|
id = application.id;
|
|
activity.application_id = id;
|
|
value5 = socket.transport === TransportTypes.POST_MESSAGE;
|
|
r8 = value5 ? ActivityGamePlatforms.EMBEDDED : ActivityGamePlatforms.DESKTOP;
|
|
activity.platform = r8;
|
|
getApplication = ApplicationStore.getApplication;
|
|
r8 = id ?? value;
|
|
value6 = Reflect.apply(getApplication, ApplicationStore, [r8]);
|
|
instance = activity.instance;
|
|
r12 = instance != null && instance;
|
|
party = activity.party;
|
|
reducibleJoin14: while (true) {
|
|
if (party == null) {
|
|
privacy = value;
|
|
break reducibleJoin14;
|
|
}
|
|
privacy = party.privacy;
|
|
break reducibleJoin14;
|
|
}
|
|
delete activity.instance;
|
|
party = activity.party;
|
|
reducibleJoin16: while (true) {
|
|
if (party == null) {
|
|
break reducibleJoin16;
|
|
}
|
|
delete party.privacy;
|
|
break reducibleJoin16;
|
|
}
|
|
moduleValue = require(6884) /* metro dependency 6884: ActivityFlagUtils */;
|
|
computeActivityFlags = moduleValue.computeActivityFlags;
|
|
value8 = value6 != null;
|
|
reducibleJoin18: while (true) {
|
|
if (value8) {
|
|
moduleValue2 = require(8045) /* metro dependency 8045: canLaunchFrame */;
|
|
canLaunchFrame = moduleValue2.canLaunchFrame;
|
|
canLaunchFrame2 = Reflect.apply(canLaunchFrame, moduleValue2, [value6]);
|
|
r8 = canLaunchFrame2;
|
|
break reducibleJoin18;
|
|
}
|
|
r8 = value8;
|
|
break reducibleJoin18;
|
|
}
|
|
r8 = r8 && value5;
|
|
activityFlags = Reflect.apply(computeActivityFlags, moduleValue, [activity, r12, value5, r8, privacy]);
|
|
value9 = 0;
|
|
reducibleJoin21: while (true) {
|
|
if (activityFlags > value9) {
|
|
activity.flags = activityFlags;
|
|
break reducibleJoin21;
|
|
}
|
|
break reducibleJoin21;
|
|
}
|
|
assets = activity.assets;
|
|
party = activity.party;
|
|
secrets = activity.secrets;
|
|
timestamps = activity.timestamps;
|
|
buttons = activity.buttons;
|
|
reducibleJoin23: while (true) {
|
|
if (activity.type != null) {
|
|
break reducibleJoin23;
|
|
}
|
|
PLAYING = ActivityTypes.PLAYING;
|
|
activity.type = PLAYING;
|
|
break reducibleJoin23;
|
|
}
|
|
if (secrets != null) {
|
|
value11 = (importDefault(22) /* metro dependency 22 */).values(secrets).filter(function(a0) {
|
|
return !!a0;
|
|
});
|
|
reducibleJoin30: while (true) {
|
|
reducibleJoin28: while (true) {
|
|
if (party == null) {
|
|
break reducibleJoin28;
|
|
}
|
|
defaultImport2 = importDefault(22) /* metro dependency 22 */;
|
|
intersection = defaultImport2.intersection;
|
|
id = party.id;
|
|
length = Reflect.apply(intersection, defaultImport2, [value11, [id]]).length;
|
|
if (length > value9) {
|
|
binding = env0_10;
|
|
includes = binding.includes;
|
|
application = socket.application;
|
|
id = application.id;
|
|
if (!Reflect.apply(includes, binding, [id])) {
|
|
value = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
value = new value({errorCode: RPCErrors.INVALID_ACTIVITY_SECRET},
|
|
'secrets cannot match the party id');
|
|
throw value;
|
|
}
|
|
break reducibleJoin28;
|
|
}
|
|
break reducibleJoin28;
|
|
}
|
|
defaultImport3 = importDefault(22) /* metro dependency 22 */;
|
|
uniq = defaultImport3.uniq;
|
|
length = Reflect.apply(uniq, defaultImport3, [value11]).length;
|
|
length2 = value11.length;
|
|
if (length < length2) {
|
|
value = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
value = new value({errorCode: RPCErrors.INVALID_ACTIVITY_SECRET}, 'secrets must be unique');
|
|
throw value;
|
|
}
|
|
if (buttons != null) {
|
|
value = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
value = new value({errorCode: RPCErrors.INVALID_ACTIVITY_SECRET},
|
|
'secrets cannot currently be sent with buttons');
|
|
throw value;
|
|
}
|
|
break reducibleJoin30;
|
|
}
|
|
}
|
|
reducibleJoin32: while (true) {
|
|
if (buttons == null) {
|
|
break reducibleJoin32;
|
|
}
|
|
map = buttons.map;
|
|
object.button_urls = Reflect.apply(map, buttons, [_fun99547]);
|
|
map = buttons.map;
|
|
activity.buttons = Reflect.apply(map, buttons, [_fun99548]);
|
|
break reducibleJoin32;
|
|
}
|
|
activity.metadata = object;
|
|
reducibleJoin37: while (true) {
|
|
if (timestamps == null) {
|
|
break reducibleJoin37;
|
|
}
|
|
Object = global.Object;
|
|
keys = Object.keys;
|
|
value13 = Reflect.apply(keys, Object, [timestamps]);
|
|
length = value13.length;
|
|
if (!(value9 < length)) {
|
|
break reducibleJoin37;
|
|
}
|
|
r14 = value9;
|
|
reducibleLoop34: while (true) {
|
|
property = value13[r14];
|
|
Date = global.Date;
|
|
now = Date.now;
|
|
value14 = Reflect.apply(now, Date, []);
|
|
toString = value14.toString;
|
|
length = Reflect.apply(toString, value14, []).length;
|
|
property2 = timestamps[property];
|
|
toString = property2.toString;
|
|
length3 = Reflect.apply(toString, property2, []).length;
|
|
reducibleJoin36: while (true) {
|
|
if (length - length3 > 2) {
|
|
Math = global.Math;
|
|
floor = Math.floor;
|
|
property3 = timestamps[property];
|
|
Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
|
|
SECOND = Millis.SECOND;
|
|
timestamps[property] = Reflect.apply(floor, Math, [property3 * SECOND]);
|
|
break reducibleJoin36;
|
|
}
|
|
break reducibleJoin36;
|
|
}
|
|
value15 = typeof r14 === 'bigint' ? r14 + 1n : +r14 + 1;
|
|
length = value13.length;
|
|
if (value15 < length) {
|
|
r14 = value15;
|
|
continue reducibleLoop34;
|
|
}
|
|
break reducibleJoin37;
|
|
}
|
|
}
|
|
if (assets == null) {
|
|
r5 = global.Promise.resolve([]);
|
|
} else {
|
|
application = socket.application;
|
|
reducibleJoin43: while (true) {
|
|
reducibleJoin41: while (true) {
|
|
if (application == null) {
|
|
break reducibleJoin41;
|
|
}
|
|
application = socket.application;
|
|
id = application.id;
|
|
if (id == null) {
|
|
break reducibleJoin41;
|
|
}
|
|
value = require(6873) /* metro dependency 6873: ApplicationAssetUtils */;
|
|
fetchAssetIds = value.fetchAssetIds;
|
|
application = socket.application;
|
|
id = application.id;
|
|
large_image = assets.large_image;
|
|
small_image = assets.small_image;
|
|
invite_cover_image = assets.invite_cover_image;
|
|
value = Reflect.apply(fetchAssetIds, value, [id, [large_image, small_image, invite_cover_image]]);
|
|
r5 = value;
|
|
break reducibleJoin43;
|
|
}
|
|
Error = global.Error;
|
|
prototype = Error.prototype;
|
|
value = Object.create(prototype, {constructor: {value: Error}});
|
|
error = new Error();
|
|
value = error instanceof Object ? error : value;
|
|
throw value;
|
|
}
|
|
}
|
|
return r5.then(_fun99549);
|
|
}
|
|
value = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
const INVALID_COMMAND = RPCErrors.INVALID_COMMAND;
|
|
value = new value({errorCode: INVALID_COMMAND}, 'command not available from "' + socket.transport + '" transport');
|
|
throw value;
|
|
}
|
|
|
|
function _fun99549(a0) { // fn#99549, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13230:3811, offset: 0x021cd868, size: 704 bytes, params: 2, frame: 20
|
|
var r0;
|
|
var r1;
|
|
var r3;
|
|
var r2;
|
|
var r7;
|
|
var item3;
|
|
var value3;
|
|
var item4;
|
|
var value4;
|
|
var value6;
|
|
var defaultImport;
|
|
var dispatch;
|
|
var object2;
|
|
var socketBinding;
|
|
var id;
|
|
var activityBinding;
|
|
var secrets;
|
|
var party;
|
|
var details;
|
|
var value7;
|
|
const iterator = a0[Symbol.iterator]();
|
|
const iterator2 = iterator.next;
|
|
let item2 = Reflect.apply(iterator2, iterator, []);
|
|
let item = item2.value;
|
|
item2 = item2.done ? undefined : iterator;
|
|
let value = undefined;
|
|
const value2 = item2 === value;
|
|
const r4 = value2 ? value : item;
|
|
if (value2) {
|
|
r0 = item2;
|
|
r1 = value2;
|
|
r3 = value;
|
|
} else {
|
|
item3 = Reflect.apply(iterator2, item2, []);
|
|
item = item3.value;
|
|
item3 = item3.done ? undefined : item2;
|
|
value3 = item3 === value;
|
|
if (value3) {
|
|
r0 = item3;
|
|
r1 = value3;
|
|
r3 = value;
|
|
} else {
|
|
r0 = item3;
|
|
r1 = value3;
|
|
r3 = item;
|
|
}
|
|
}
|
|
if (r1) {
|
|
r2 = value;
|
|
} else {
|
|
item4 = Reflect.apply(iterator2, r0, []);
|
|
item = item4.value;
|
|
item4 = item4.done ? undefined : r0;
|
|
value4 = item4 === value;
|
|
if (value4) {
|
|
r0 = item4;
|
|
r1 = value4;
|
|
r2 = value;
|
|
} else {
|
|
r0 = item4;
|
|
r1 = value4;
|
|
r2 = item;
|
|
}
|
|
}
|
|
if (!r1) {
|
|
r0.return();
|
|
}
|
|
if (assets != null) {
|
|
if (r4 != null) {
|
|
assets.large_image = r4;
|
|
} else {
|
|
delete assets.large_image;
|
|
}
|
|
if (r3 != null) {
|
|
assets.small_image = r3;
|
|
} else {
|
|
delete assets.small_image;
|
|
}
|
|
if (r2 != null) {
|
|
assets.invite_cover_image = r2;
|
|
} else {
|
|
delete assets.invite_cover_image;
|
|
}
|
|
}
|
|
if (isSocketConnected()) {
|
|
value6 = environment.__proto__;
|
|
defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
dispatch = defaultImport.dispatch;
|
|
socketBinding = socket;
|
|
id = socketBinding.id;
|
|
activityBinding = activity;
|
|
Reflect.apply(dispatch, defaultImport, [{type: 'LOCAL_ACTIVITY_UPDATE', socketId: id, pid: pid,
|
|
activity: activityBinding, partyPrivacy: privacy}]);
|
|
secrets = activityBinding.secrets;
|
|
party = activityBinding.party;
|
|
object2 = {};
|
|
id = socketBinding.application.id;
|
|
object2.application_id = id;
|
|
object2.type = activityBinding.type;
|
|
object2.name = activityBinding.name;
|
|
object2.status_display_type = activityBinding.status_display_type;
|
|
details = activityBinding.details;
|
|
value7 = '';
|
|
object2.details = details ?? value7;
|
|
r7 = activity.state ?? value7;
|
|
object2.state = r7;
|
|
r7 = activity.state_url != null || activity.details_url != null;
|
|
r7 = !r7 ? (activity.assets == null ? value : activity.assets.large_url) != null : r7;
|
|
r7 = !r7 ? (activity.assets == null ? value : activity.assets.small_url) != null : r7;
|
|
object2.has_urls = r7;
|
|
if (secrets != null) {
|
|
object2.has_match_secret = !!secrets.match;
|
|
object2.has_join_secret = !!secrets.join;
|
|
}
|
|
if (assets != null) {
|
|
r3 = assets.large_image || assets.small_image;
|
|
r3 = !r3 ? assets.invite_cover_image : r3;
|
|
object2.has_images = !!r3;
|
|
}
|
|
if (party != null) {
|
|
object2.party_max = party.size != null && party.size[1] > 0 ? party.size[1] : value;
|
|
object2.party_id = party.id;
|
|
}
|
|
value = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
value.track(AnalyticEvents.ACTIVITY_UPDATED, object2);
|
|
return activity;
|
|
}
|
|
return value;
|
|
}
|
|
|