217 lines
11 KiB
TypeScript
217 lines
11 KiB
TypeScript
/* Metro module 13057; source: modules/rpc/server/commands/quests.tsx; dependencies: [7093, 661, 4122, 8081, 7116, 8076, 683, 694, 9524, 2] */
|
|
import AnalyticsUtils from '../../../../utils/AnalyticsUtils.tsx'; /* Metro dependency 683 */
|
|
import QuestStore from '../../../quests/QuestStore.tsx'; /* Metro dependency 7093 */
|
|
import * as FileImportTrackerModule from '../../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ConstantsModule from '../../../../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as OAuth2ScopesModule from '../../../../external/discord_common/js/shared/shared-constants/OAuth2Scopes.tsx'; /* Metro dependency 4122 */
|
|
import * as QuestTaskUtilsModule from '../../../quests/utils/QuestTaskUtils.tsx'; /* Metro dependency 7116 */
|
|
import * as RPCHelpersModule from '../../RPCHelpers.tsx'; /* Metro dependency 8081 */
|
|
import * as QuestMatchingUtilsModule from '../../../quests/utils/QuestMatchingUtils.tsx'; /* Metro dependency 9524 */
|
|
|
|
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
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const RPCCommands = ConstantsModule.RPCCommands;
|
|
object = {};
|
|
const GET_QUEST_ENROLLMENT_STATUS = RPCCommands.GET_QUEST_ENROLLMENT_STATUS;
|
|
const OAuth2Scopes = (OAuth2ScopesModule).OAuth2Scopes;
|
|
let IDENTIFY = OAuth2Scopes.IDENTIFY;
|
|
object[GET_QUEST_ENROLLMENT_STATUS] = {scope: IDENTIFY, handler: handler_99693};
|
|
const QUEST_START_TIMER = RPCCommands.QUEST_START_TIMER;
|
|
IDENTIFY = OAuth2Scopes.IDENTIFY;
|
|
object[QUEST_START_TIMER] = {scope: IDENTIFY, handler: handler_99694};
|
|
const GET_QUEST = RPCCommands.GET_QUEST;
|
|
IDENTIFY = OAuth2Scopes.IDENTIFY;
|
|
object[GET_QUEST] = {scope: IDENTIFY, handler: handler_99695};
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/rpc/server/commands/quests.tsx');
|
|
exports.default = object;
|
|
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;
|
|
RPCHelpersModule.validatePostMessageTransport(socket.transport);
|
|
const value3 = RPCHelpersModule.validateApplication(socket.application);
|
|
const quest = QuestStore.getQuest(quest_id);
|
|
const activityApplicationId = (QuestTaskUtilsModule).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 object = {quest_id: quest_id};
|
|
let userStatus = quest.userStatus;
|
|
object.is_enrolled = userStatus?.enrolledAt != null;
|
|
userStatus = quest.userStatus;
|
|
object.enrolled_at = userStatus?.enrolledAt ?? null;
|
|
return object;
|
|
}
|
|
|
|
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;
|
|
RPCHelpersModule.validatePostMessageTransport(socket.transport);
|
|
const value3 = RPCHelpersModule.validateApplication(socket.application);
|
|
const quest = QuestStore.getQuest(quest_id);
|
|
const playActivityApplicationId = (QuestTaskUtilsModule).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 = 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
|
|
RPCHelpersModule.validatePostMessageTransport(socket.transport);
|
|
const eligibleQuestsForApplicationId = (QuestMatchingUtilsModule).getEligibleQuestsForApplicationId(QuestStore.quests,
|
|
RPCHelpersModule.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;
|
|
}
|
|
|
|
global.__d(_fun99692, 13057, [7093, 661, 4122, 8081, 7116, 8076, 683, 694, 9524,
|
|
2]) /* metro module 13057, dependencies: [7093, 661, 4122, 8081, 7116, 8076, 683, 694, 9524, 2] */;
|