diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-16 14:20:17 +1100 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-16 14:20:17 +1100 |
commit | 49a311f5d07025d3bdca2603ac2e8cf427d81f77 (patch) | |
tree | 9272ead97ff8aa16fe2906253ccd427310db8205 | |
parent | Update dead lines (diff) | |
download | server-49a311f5d07025d3bdca2603ac2e8cf427d81f77.tar.xz |
Return embed proxy url even if imagor not set up. Also make warning nicer
-rw-r--r-- | src/api/util/utility/EmbedHandlers.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/api/util/utility/EmbedHandlers.ts b/src/api/util/utility/EmbedHandlers.ts index 0e4146d1..6ec4cac0 100644 --- a/src/api/util/utility/EmbedHandlers.ts +++ b/src/api/util/utility/EmbedHandlers.ts @@ -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 => { |