Return embed proxy url even if imagor not set up. Also make warning nicer
This commit is contained in:
parent
de3909f646
commit
5771247645
@ -3,6 +3,7 @@ import fetch, { Response } from "node-fetch";
|
|||||||
import * as cheerio from "cheerio";
|
import * as cheerio from "cheerio";
|
||||||
import probe from "probe-image-size";
|
import probe from "probe-image-size";
|
||||||
import crypto from "crypto";
|
import crypto from "crypto";
|
||||||
|
import { yellow } from "picocolors";
|
||||||
|
|
||||||
export const DEFAULT_FETCH_OPTIONS: any = {
|
export const DEFAULT_FETCH_OPTIONS: any = {
|
||||||
redirect: "follow",
|
redirect: "follow",
|
||||||
@ -16,6 +17,8 @@ export const DEFAULT_FETCH_OPTIONS: any = {
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let hasWarnedAboutImagor = false;
|
||||||
|
|
||||||
export const getProxyUrl = (
|
export const getProxyUrl = (
|
||||||
url: URL,
|
url: URL,
|
||||||
width: number,
|
width: number,
|
||||||
@ -41,11 +44,17 @@ export const getProxyUrl = (
|
|||||||
return `${imagorServerUrl}/${hash}/${path}`;
|
return `${imagorServerUrl}/${hash}/${path}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Imagor documentation
|
if (!hasWarnedAboutImagor) {
|
||||||
|
hasWarnedAboutImagor = true;
|
||||||
console.log(
|
console.log(
|
||||||
|
"[Embeds]",
|
||||||
|
yellow(
|
||||||
"Imagor has not been set up correctly. https://docs.fosscord.com/setup/server/configuration/imagor/",
|
"Imagor has not been set up correctly. https://docs.fosscord.com/setup/server/configuration/imagor/",
|
||||||
|
),
|
||||||
);
|
);
|
||||||
return "";
|
}
|
||||||
|
|
||||||
|
return url.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMeta = ($: cheerio.CheerioAPI, name: string): string | undefined => {
|
const getMeta = ($: cheerio.CheerioAPI, name: string): string | undefined => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user