mirror of
https://github.com/MathMan05/Fermi.git
synced 2026-07-02 19:51:36 +00:00
shorter invite links
This commit is contained in:
@@ -371,7 +371,7 @@ class Channel extends SnowFlake {
|
||||
.then((_) => _.json())
|
||||
.then((json) => {
|
||||
const params = new URLSearchParams("");
|
||||
params.set("instance", this.info.wellknown);
|
||||
params.set("instance", this.localuser.instanceString());
|
||||
const encoded = params.toString();
|
||||
text.textContent = `${location.origin}/invite/${json.code}?${encoded}`;
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ export async function makeInviteMenu(inviteMenu: Options, guild: Guild, url: str
|
||||
"/invite/" +
|
||||
invite.code +
|
||||
"?" +
|
||||
new URLSearchParams([["instance", guild.info.wellknown]]),
|
||||
new URLSearchParams([["instance", guild.localuser.instanceString()]]),
|
||||
undefined,
|
||||
),
|
||||
);
|
||||
@@ -1282,7 +1282,7 @@ class Guild extends SnowFlake {
|
||||
headers: this.headers,
|
||||
},
|
||||
);
|
||||
const search = new URLSearchParams([["instance", this.info.wellknown]]);
|
||||
const search = new URLSearchParams([["instance", this.localuser.instanceString()]]);
|
||||
form.addMDText(
|
||||
new MarkDown(
|
||||
I18n.guild.templateURL(
|
||||
@@ -1431,7 +1431,7 @@ class Guild extends SnowFlake {
|
||||
.then((_) => _.json())
|
||||
.then((json) => {
|
||||
const params = new URLSearchParams("");
|
||||
params.set("instance", this.info.wellknown);
|
||||
params.set("instance", this.localuser.instanceString());
|
||||
const encoded = params.toString();
|
||||
text.textContent = `${location.origin}/invite/${json.code}?${encoded}`;
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import {Guild} from "./guild.js";
|
||||
import {Channel} from "./channel.js";
|
||||
import {Direct, Group} from "./direct.js";
|
||||
import {User} from "./user.js";
|
||||
import {createImg, getapiurls, getBulkUsers, installPGet, SW} from "./utils/utils.js";
|
||||
import {createImg, getapiurls, getBulkUsers, getInstances, installPGet, SW} from "./utils/utils.js";
|
||||
import {getBulkInfo, setTheme, Specialuser} from "./utils/utils.js";
|
||||
import {
|
||||
channeljson,
|
||||
@@ -49,6 +49,7 @@ import {getLocalSettings, ServiceWorkerModeValues} from "./utils/storage/localSe
|
||||
import {PromiseLock} from "./utils/promiseLock.js";
|
||||
import {CDNParams} from "./utils/cdnParams.js";
|
||||
import {SnowFlake} from "./snowflake.js";
|
||||
import {trimTrailingSlashes} from "./utils/netUtils.js";
|
||||
type traceObj = {
|
||||
micros: number;
|
||||
calls?: (string | traceObj)[];
|
||||
@@ -1451,6 +1452,18 @@ class Localuser {
|
||||
elms.set("online", online);
|
||||
this.generateListHTML(elms, channel);
|
||||
}
|
||||
instanceString(): string {
|
||||
const insts = getInstances();
|
||||
if (insts) {
|
||||
for (const inst of insts) {
|
||||
if (trimTrailingSlashes(inst.url ?? "") === trimTrailingSlashes(this.info.wellknown)) {
|
||||
return inst.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log("failed with", insts, this.info.wellknown);
|
||||
return this.info.wellknown;
|
||||
}
|
||||
roleListMap = new WeakMap<
|
||||
HTMLDivElement,
|
||||
{
|
||||
@@ -3485,7 +3498,7 @@ class Localuser {
|
||||
} else if (format.index === 2) {
|
||||
if (urlOptionsJSON.type === "Fermi") {
|
||||
const options = new URLSearchParams();
|
||||
options.set("instance", this.info.wellknown);
|
||||
options.set("instance", this.instanceString());
|
||||
pre.textContent = json.tokens
|
||||
.map((token) => {
|
||||
options.set("token", token);
|
||||
|
||||
Reference in New Issue
Block a user