217 lines
10 KiB
TypeScript
217 lines
10 KiB
TypeScript
/* Metro module 13057; source: modules/rpc/server/commands/quests.tsx; dependencies: [7093, 661, 4122, 8081, 7116, 8076, 683, 694, 9524, 2] */
|
|
function _fun99692(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#99692, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13247:6, offset: 0x021d19fa, size: 307 bytes, params: 8, frame: 21
|
|
var object2;
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const questStore = importDefault(7093) /* metro dependency 7093: QuestStore */;
|
|
const constantsModule = require(661) /* metro dependency 661: Constants */;
|
|
const RPCCommands = constantsModule.RPCCommands;
|
|
const env0_4 = constantsModule.RPCErrors;
|
|
const env0_5 = constantsModule.AnalyticEvents;
|
|
object2 = {};
|
|
const GET_QUEST_ENROLLMENT_STATUS = RPCCommands.GET_QUEST_ENROLLMENT_STATUS;
|
|
const OAuth2Scopes = (require(4122) /* metro dependency 4122: OAuth2Scopes */).OAuth2Scopes;
|
|
let IDENTIFY = OAuth2Scopes.IDENTIFY;
|
|
object2[GET_QUEST_ENROLLMENT_STATUS] = {scope: IDENTIFY, handler: handler_99693};
|
|
const QUEST_START_TIMER = RPCCommands.QUEST_START_TIMER;
|
|
IDENTIFY = OAuth2Scopes.IDENTIFY;
|
|
object2[QUEST_START_TIMER] = {scope: IDENTIFY, handler: handler_99694};
|
|
const GET_QUEST = RPCCommands.GET_QUEST;
|
|
IDENTIFY = OAuth2Scopes.IDENTIFY;
|
|
object2[GET_QUEST] = {scope: IDENTIFY, handler: handler_99695};
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/rpc/server/commands/quests.tsx');
|
|
exports.default = object2;
|
|
}
|
|
|
|
function handler_99693({socket, args}) { // fn#99693, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13247:238, offset: 0x021d1b2d, size: 303 bytes, params: 2, frame: 19
|
|
var defaultImport;
|
|
const quest_id = args.quest_id;
|
|
var value;
|
|
const rpcHelpersModule = require(8081) /* metro dependency 8081: RPCHelpers */;
|
|
rpcHelpersModule.validatePostMessageTransport(socket.transport);
|
|
const moduleValue2 = rpcHelpersModule;
|
|
const value3 = moduleValue2.validateApplication(socket.application);
|
|
const quest = QuestStore.getQuest(quest_id);
|
|
const activityApplicationId = (require(7116) /* metro dependency 7116: QuestTaskUtils */).getActivityApplicationId(quest);
|
|
if (quest == null) {
|
|
defaultImport = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
({}).errorCode = RPCErrors.INVALID_COMMAND;
|
|
value = 'Quest not found: ' + quest_id;
|
|
value = new defaultImport();
|
|
throw value;
|
|
}
|
|
if (activityApplicationId == null) {
|
|
defaultImport = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
({}).errorCode = RPCErrors.INVALID_COMMAND;
|
|
value = 'Quest not found: ' + quest_id;
|
|
value = new defaultImport();
|
|
throw value;
|
|
}
|
|
if (activityApplicationId !== value3) {
|
|
defaultImport = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
({}).errorCode = RPCErrors.INVALID_COMMAND;
|
|
value = 'Quest not found: ' + quest_id;
|
|
value = new defaultImport();
|
|
throw value;
|
|
}
|
|
const object2 = {quest_id: quest_id};
|
|
let userStatus = quest.userStatus;
|
|
object2.is_enrolled = userStatus?.enrolledAt != null;
|
|
userStatus = quest.userStatus;
|
|
object2.enrolled_at = userStatus?.enrolledAt ?? null;
|
|
return object2;
|
|
}
|
|
|
|
function handler_99694({socket, args}) { // fn#99694, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13247:755, offset: 0x021d1c5c, size: 435 bytes, params: 2, frame: 20
|
|
var defaultImport3;
|
|
const quest_id = args.quest_id;
|
|
var value;
|
|
const rpcHelpersModule = require(8081) /* metro dependency 8081: RPCHelpers */;
|
|
rpcHelpersModule.validatePostMessageTransport(socket.transport);
|
|
const moduleValue2 = rpcHelpersModule;
|
|
const value3 = moduleValue2.validateApplication(socket.application);
|
|
const quest = QuestStore.getQuest(quest_id);
|
|
const playActivityApplicationId = (require(7116) /* metro dependency 7116: QuestTaskUtils */).getPlayActivityApplicationId(quest);
|
|
if (quest == null) {
|
|
defaultImport3 = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
({}).errorCode = RPCErrors.INVALID_COMMAND;
|
|
value = 'Quest not found: ' + quest_id;
|
|
value = new defaultImport3();
|
|
throw value;
|
|
}
|
|
if (playActivityApplicationId == null) {
|
|
defaultImport3 = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
({}).errorCode = RPCErrors.INVALID_COMMAND;
|
|
value = 'Quest not found: ' + quest_id;
|
|
value = new defaultImport3();
|
|
throw value;
|
|
}
|
|
if (playActivityApplicationId !== value3) {
|
|
defaultImport3 = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
({}).errorCode = RPCErrors.INVALID_COMMAND;
|
|
value = 'Quest not found: ' + quest_id;
|
|
value = new defaultImport3();
|
|
throw value;
|
|
}
|
|
const userStatus = quest.userStatus;
|
|
if (userStatus?.enrolledAt == null) {
|
|
throw new (importDefault(8076) /* metro dependency 8076: RPCError */)({errorCode: RPCErrors.INVALID_COMMAND},
|
|
'User is not enrolled in quest');
|
|
}
|
|
const defaultImport = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
const track = defaultImport.track;
|
|
const RPC_QUEST_START_TIMER_CALLED = AnalyticEvents.RPC_QUEST_START_TIMER_CALLED;
|
|
Reflect.apply(track, defaultImport, [RPC_QUEST_START_TIMER_CALLED, {application_id: value3, quest_id: quest_id}]);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.dispatch({type: 'QUEST_APPLICATION_START_TIMER', questId: quest_id, applicationId: value3});
|
|
return {success: true};
|
|
}
|
|
|
|
function handler_99695({socket}) { // fn#99695, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13247:1425, offset: 0x021d1e0f, size: 235 bytes, params: 2, frame: 20
|
|
const rpcHelpersModule = require(8081) /* metro dependency 8081: RPCHelpers */;
|
|
rpcHelpersModule.validatePostMessageTransport(socket.transport);
|
|
const moduleValue2 = rpcHelpersModule;
|
|
const eligibleQuestsForApplicationId = (require(9524) /* metro dependency 9524: QuestMatchingUtils */).getEligibleQuestsForApplicationId(QuestStore.quests,
|
|
moduleValue2.validateApplication(socket.application), true);
|
|
if (eligibleQuestsForApplicationId.length === 0) {
|
|
throw new (importDefault(8076) /* metro dependency 8076: RPCError */)({errorCode: RPCErrors.INVALID_COMMAND},
|
|
'No eligible quests found');
|
|
}
|
|
let value = eligibleQuestsForApplicationId.map(function(a0) {
|
|
var r5;
|
|
var r3;
|
|
var property = a0.userStatus;
|
|
var value = null;
|
|
var value2 = undefined;
|
|
r5 = value == property ? value2 : property.enrolledAt;
|
|
property = a0.userStatus;
|
|
r3 = value == property ? value2 : property.completedAt;
|
|
return {quest_id: a0.id, enrolled_at: value != r5 ? r5 : value, completed_at: value != r3 ? r3 : value,
|
|
external_cta_url: a0.config.ctaConfig.link};
|
|
});
|
|
return value.sort(_fun99697)[0];
|
|
}
|
|
|
|
function _fun99697(a0, a1) { // fn#99697, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13247:1944, offset: 0x021d1f70, size: 169 bytes, params: 3, frame: 16
|
|
var r2;
|
|
var r1;
|
|
var r0;
|
|
var value;
|
|
var Date;
|
|
var prototype;
|
|
var date;
|
|
var value2;
|
|
var value3;
|
|
let enrolled_at = a0.enrolled_at;
|
|
if (enrolled_at != null) {
|
|
enrolled_at = a0.enrolled_at;
|
|
value = 1;
|
|
if (enrolled_at == null) {
|
|
r1 = value;
|
|
} else {
|
|
enrolled_at = a1.enrolled_at;
|
|
value = -1;
|
|
if (enrolled_at == null) {
|
|
r2 = value;
|
|
} else {
|
|
Date = global.Date;
|
|
enrolled_at = a0.enrolled_at;
|
|
prototype = Date.prototype;
|
|
value = Object.create(prototype, {constructor: {value: Date}});
|
|
date = new Date(enrolled_at);
|
|
value = date instanceof Object ? date : value;
|
|
value = value.getTime();
|
|
Date = global.Date;
|
|
enrolled_at = a1.enrolled_at;
|
|
prototype = Date.prototype;
|
|
value2 = Object.create(prototype, {constructor: {value: Date}});
|
|
date = new Date(enrolled_at);
|
|
value3 = date instanceof Object ? date : value2;
|
|
value -= value3.getTime();
|
|
r2 = value;
|
|
}
|
|
r1 = r2;
|
|
}
|
|
r0 = r1;
|
|
} else {
|
|
enrolled_at = a1.enrolled_at;
|
|
value = 0;
|
|
if (enrolled_at == null) {
|
|
r0 = value;
|
|
} else {
|
|
enrolled_at = a0.enrolled_at;
|
|
value = 1;
|
|
if (enrolled_at == null) {
|
|
r1 = value;
|
|
} else {
|
|
enrolled_at = a1.enrolled_at;
|
|
value = -1;
|
|
if (enrolled_at == null) {
|
|
r2 = value;
|
|
} else {
|
|
Date = global.Date;
|
|
enrolled_at = a0.enrolled_at;
|
|
prototype = Date.prototype;
|
|
value = Object.create(prototype, {constructor: {value: Date}});
|
|
date = new Date(enrolled_at);
|
|
value = date instanceof Object ? date : value;
|
|
value = value.getTime();
|
|
Date = global.Date;
|
|
enrolled_at = a1.enrolled_at;
|
|
prototype = Date.prototype;
|
|
value2 = Object.create(prototype, {constructor: {value: Date}});
|
|
date = new Date(enrolled_at);
|
|
value3 = date instanceof Object ? date : value2;
|
|
value -= value3.getTime();
|
|
r2 = value;
|
|
}
|
|
r1 = r2;
|
|
}
|
|
r0 = r1;
|
|
}
|
|
}
|
|
return r0;
|
|
}
|
|
|