92 lines
4.4 KiB
TypeScript
92 lines
4.4 KiB
TypeScript
/* Metro module 13024; source: modules/rpc/server/commands/images.tsx; dependencies: [1878, 4135, 661, 8079, 1423, 8076, 1475, 2] */
|
|
function _fun99420(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#99420, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13214:6, offset: 0x021c7d9e, size: 201 bytes, params: 8, frame: 19
|
|
var object2;
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
|
|
const RPC_LOCAL_SCOPE = (require(4135) /* metro dependency 4135: Constants */).RPC_LOCAL_SCOPE;
|
|
const constantsModule = require(661) /* metro dependency 661: Constants */;
|
|
const RPCCommands = constantsModule.RPCCommands;
|
|
const env0_4 = constantsModule.RPCErrors;
|
|
object2 = {};
|
|
const GET_IMAGE = RPCCommands.GET_IMAGE;
|
|
object2[GET_IMAGE] = {scope: RPC_LOCAL_SCOPE, validation: validation_99421, handler: handler_99422};
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/rpc/server/commands/images.tsx');
|
|
exports.default = object2;
|
|
}
|
|
|
|
function validation_99421(a0) { // fn#99421, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13214:212, offset: 0x021c7e67, size: 213 bytes, params: 2, frame: 15
|
|
let value = (importDefault(8079) /* metro dependency 8079: createRpcJoiSchemaObject */)(a0);
|
|
value = value.required();
|
|
const keys = value.keys;
|
|
const object2 = {};
|
|
object2.type = a0.string().required().valid(['user']);
|
|
object2.id = a0.string().required();
|
|
object2.format = a0.string().required().valid(['png', 'webp', 'jpg']);
|
|
object2.size = a0.number().required().valid([16, 32, 64, 128, 256, 512, 1024]);
|
|
return Reflect.apply(keys, value, [object2]);
|
|
}
|
|
|
|
function handler_99422({args}) { // fn#99422, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13214:432, offset: 0x021c7f3c, size: 425 bytes, params: 2, frame: 23
|
|
var r5;
|
|
var value13;
|
|
const type = args.type;
|
|
const id = args.id;
|
|
let format = args.format;
|
|
let value = undefined;
|
|
format = format === value ? 'png' : format;
|
|
let size = args.size;
|
|
size = size === value ? 128 : size;
|
|
if (type !== 'user') {
|
|
r5 = value;
|
|
if (r5 == null) {
|
|
value = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
value = new value({errorCode: RPCErrors.INVALID_COMMAND}, 'No valid type.');
|
|
throw value;
|
|
}
|
|
value = global.fetch(r5);
|
|
value = value.then(function(a0) {
|
|
return a0.blob();
|
|
});
|
|
value = value.then(_fun99424);
|
|
return value.then(_fun99425);
|
|
}
|
|
const user = UserStore.getUser(id);
|
|
if (user == null) {
|
|
value = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
({}).errorCode = RPCErrors.INVALID_USER;
|
|
value13 = 'Invalid user id: ' + id;
|
|
value = new value();
|
|
throw value;
|
|
}
|
|
const userAvatarURL = (importDefault(1423) /* metro dependency 1423: AvatarUtils */).getUserAvatarURL(user, false,
|
|
size, format);
|
|
const GLOBAL_ENV = global.window.GLOBAL_ENV;
|
|
const CDN_HOST = GLOBAL_ENV.CDN_HOST;
|
|
r5 = CDN_HOST != null && userAvatarURL.indexOf(CDN_HOST) !== -1 ? userAvatarURL + '&_=' : userAvatarURL;
|
|
if (r5 == null) {
|
|
value = importDefault(8076) /* metro dependency 8076: RPCError */;
|
|
value = new value({errorCode: RPCErrors.INVALID_COMMAND}, 'No valid type.');
|
|
throw value;
|
|
}
|
|
value = global.fetch(r5);
|
|
value = value.then(function(a0) {
|
|
return a0.blob();
|
|
});
|
|
value = value.then(_fun99424);
|
|
return value.then(function(a0) {
|
|
return {data_url: a0};
|
|
});
|
|
}
|
|
|
|
function _fun99424(a0) { // fn#99424, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13214:839, offset: 0x021c80f4, size: 41 bytes, params: 2, frame: 11
|
|
const value = environment.__proto__;
|
|
return (require(1475) /* metro dependency 1475: ImageUtils */).readFileAsBase64(a0);
|
|
}
|
|
|
|
function _fun99425(a0) { // fn#99425, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13214:879, offset: 0x021c811d, size: 14 bytes, params: 2, frame: 2
|
|
return {data_url: a0};
|
|
}
|
|
|