1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-20 01:31:34 +02:00

Return embed proxy url even if imagor not set up. Also make warning nicer

This commit is contained in:
Madeline 2023-01-16 14:20:17 +11:00
parent b8e5f7343c
commit 49a311f5d0
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47

View File

@ -3,6 +3,7 @@ import fetch, { Response } from "node-fetch";
import * as cheerio from "cheerio";
import probe from "probe-image-size";
import crypto from "crypto";
import { yellow } from "picocolors";
export const DEFAULT_FETCH_OPTIONS: any = {
redirect: "follow",
@ -16,6 +17,8 @@ export const DEFAULT_FETCH_OPTIONS: any = {
method: "GET",
};
let hasWarnedAboutImagor = false;
export const getProxyUrl = (
url: URL,
width: number,
@ -41,11 +44,17 @@ export const getProxyUrl = (
return `${imagorServerUrl}/${hash}/${path}`;
}
// TODO: Imagor documentation
console.log(
"Imagor has not been set up correctly. https://docs.fosscord.com/setup/server/configuration/imagor/",
);
return "";
if (!hasWarnedAboutImagor) {
hasWarnedAboutImagor = true;
console.log(
"[Embeds]",
yellow(
"Imagor has not been set up correctly. https://docs.fosscord.com/setup/server/configuration/imagor/",
),
);
}
return url.toString();
};
const getMeta = ($: cheerio.CheerioAPI, name: string): string | undefined => {