Files
discord-decomp/modules/build_overrides/ApplyBuildOverrideUtils.tsx
T
2026-11-01 12:12:55 +02:00

148 lines
3.3 KiB
TypeScript

// Metro module 10981 (f10982).
import AuthenticationStore from "../../stores/AuthenticationStore";
import * as _BundleUpdater from "../../lib/native/BundleUpdater";
import { HTTP } from "../../_bundle/sendRequest";
import { getAPIEndpoint, APP_VERSION } from "./BuildOverrideUtils";
let c7395_2;
let env7395 = {};
const c7395_5 = "/__development/build_overrides";
let c7396_0 = async (c26894_0) => {
await _BundleUpdater.default.setBuildOverrideCookieHeader(c26894_0.headers["set-cookie"]);
};
c7395_2 = function() {
const apply = c7396_0.apply;
return c7396_0.apply(this, arguments);
};
export async function applyStaffBuildOverride(overrides) {
let r90;
let token, value;
let c26891_5 = 0;
let c30322_0;
try {
c30322_0 = void 0;
c26891_5 = 1;
const r39 = {
url: getAPIEndpoint(c7395_5),
body: {
overrides,
version: APP_VERSION
},
headers: null,
oldFormErrors: true,
rejectWithError: false
};
const token2 = AuthenticationStore.getToken();
token = token2;
if (token2 == null) {
token = "";
}
r39.headers = {
Authorization: token
};
c30322_0 = await HTTP.put(r39);
await (0, c7395_2)(c30322_0);
r90 = c30322_0;
c26891_5 = 0;
} catch ($e) {
const r32 = $e;
let r8 = r32;
value = r32;
if (c26891_5 !== 0) {
while (true) {
try {
c26891_5 = 0;
} catch (r95) {
r8 = r95;
value = r95;
if (c26891_5 === 0) {
break;
}
continue;
}
return value;
}
}
throw r8;
}
return r90;
}
export async function applyPublicBuildOverride(payload) {
let r84;
let value2;
let c26892_4 = 0;
let c30323_0;
try {
c30323_0 = void 0;
c26892_4 = 1;
c30323_0 = await HTTP.put({
url: getAPIEndpoint("/__development/link"),
body: {
payload,
token: AuthenticationStore.getToken(),
version: APP_VERSION
},
oldFormErrors: true,
rejectWithError: false
});
await (0, c7395_2)(c30323_0);
r84 = c30323_0;
c26892_4 = 0;
} catch ($e) {
const r30 = $e;
let r8 = r30;
value2 = r30;
if (c26892_4 !== 0) {
while (true) {
try {
c26892_4 = 0;
} catch (r89) {
r8 = r89;
value2 = r89;
if (c26892_4 === 0) {
break;
}
continue;
}
return value2;
}
}
throw r8;
}
return r84;
}
export async function clearBuildOverride() {
let c30324_0 = await HTTP.del({
url: getAPIEndpoint(c7395_5),
oldFormErrors: true,
rejectWithError: false
});
await (0, c7395_2)(c30324_0);
return c30324_0;
}
export function getPublicBuildOverrideLink(a0) {
const r14 = {
url: getAPIEndpoint("/__development/create_build_override_link"),
body: a0,
headers: null,
oldFormErrors: true,
rejectWithError: false
};
let Authorization = AuthenticationStore.getToken();
if (Authorization == null) {
Authorization = "";
}
r14.headers = {
Authorization
};
return HTTP.post(r14).then((result) => ({
url: result.body.url,
error: false
}), (a0) => a0.status === 400 ? {
url: false,
error: a0.body
} : {
url: false,
error: `Error making API request (${a0.status})`
});
}