98 lines
5.1 KiB
TypeScript
98 lines
5.1 KiB
TypeScript
/* Metro module 13024; source: modules/rpc/server/commands/images.tsx; dependencies: [1878, 4135, 661, 8079, 1423, 8076, 1475, 2] */
|
|
import AvatarUtils from '../../../../utils/AvatarUtils.tsx'; /* Metro dependency 1423 */
|
|
import UserStore from '../../../../stores/UserStore.tsx'; /* Metro dependency 1878 */
|
|
import CreateRpcJoiSchemaObject from '../../helpers/createRpcJoiSchemaObject.tsx'; /* Metro dependency 8079 */
|
|
import * as FileImportTrackerModule from '../../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ConstantsModule from '../../../../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as ImageUtilsModule from '../../../../utils/ImageUtils.tsx'; /* Metro dependency 1475 */
|
|
import * as ConstantsModule2 from '../../Constants.tsx'; /* Metro dependency 4135 */
|
|
|
|
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
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const RPC_LOCAL_SCOPE = (ConstantsModule2).RPC_LOCAL_SCOPE;
|
|
const RPCCommands = ConstantsModule.RPCCommands;
|
|
object = {};
|
|
const GET_IMAGE = RPCCommands.GET_IMAGE;
|
|
object[GET_IMAGE] = {scope: RPC_LOCAL_SCOPE, validation: validation_99421, handler: handler_99422};
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/rpc/server/commands/images.tsx');
|
|
exports.default = object;
|
|
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 = (CreateRpcJoiSchemaObject)(a0);
|
|
value = value.required();
|
|
const keys = value.keys;
|
|
const object = {};
|
|
object.type = a0.string().required().valid(['user']);
|
|
object.id = a0.string().required();
|
|
object.format = a0.string().required().valid(['png', 'webp', 'jpg']);
|
|
object.size = a0.number().required().valid([16, 32, 64, 128, 256, 512, 1024]);
|
|
return Reflect.apply(keys, value, [object]);
|
|
}
|
|
|
|
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 = (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 (ImageUtilsModule).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};
|
|
}
|
|
|
|
global.__d(_fun99420, 13024, [1878, 4135, 661, 8079, 1423, 8076, 1475,
|
|
2]) /* metro module 13024, dependencies: [1878, 4135, 661, 8079, 1423, 8076, 1475, 2] */;
|