Files
discord-decomp/lib/uploader_inline/InlineUploader.tsx
T
2026-11-01 12:12:55 +02:00

72 lines
1.9 KiB
TypeScript

// Metro module 7949 (f7950).
import DiscordMd5 from "../../modules/discord_md5/DiscordMd5";
import { ORIGINAL_MD5_HEADER } from "./originalMd5Header";
let c5020_4 = /^[a-f0-9]{32}$/;
class InlineUploader {
constructor(a0, a1) {
this.surface = a0;
this.originalMd5Promise = a1;
}
static fromBlob(a0, a1) {
const originalMd5Promise = DiscordMd5.fromBlob(a1).catch(() => null);
const r18 = {
__proto__: InlineUploader.prototype
};
r18.surface = a0;
r18.originalMd5Promise = originalMd5Promise;
return r18;
}
getOriginalMd5() {
return this.originalMd5Promise;
}
static buildHeadersForMd5(a0, a1) {
const r5 = (function serializeOriginalMd5Header(a0) {
if (a0 == null) {
return null;
}
if (typeof a0 === "string") {
return c5020_4.test(a0) ? a0 : null;
}
const r6 = [];
for (const item of Object.keys(a0)) {
const r31 = a0[item];
if (r31 != null && c5020_4.test(r31)) {
r6.push([item, r31]);
}
}
const length = r6.length;
let r43 = null;
if (length !== 0) {
r6.sort((a, b) => {
const [r14] = a;
const [r20] = b;
return r14 < r20 ? -1 : r14 > r20 ? 1 : 0;
});
r43 = r6.map((item) => {
const [r26, r8] = item;
return `${r26.toLowerCase()}="${r8}"`;
}).join(", ");
}
return r43;
})(a0);
let r9 = a1;
if (r5 != null) {
const r10 = {
...a1
};
r10[ORIGINAL_MD5_HEADER] = r5;
r9 = r10;
}
return r9;
}
async buildHeaders(c16123_0) {
const _this = this;
let c26066_2;
c26066_2 = void 0;
let c26066_1 = InlineUploader;
const buildHeadersForMd52 = InlineUploader.buildHeadersForMd5;
return buildHeadersForMd52.call(c26066_1, await _this.originalMd5Promise, c16123_0);
}
}
export default InlineUploader;