diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-01-16 17:00:32 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-16 17:00:32 +1100 |
commit | 0b89db8031447385fe8edbda954a0ce8f613dbfa (patch) | |
tree | 2038284e99f4e0a338b2f29d5bc5466ecba329cc /src | |
parent | Move endpoints from ping -> policies/instance/domains (#933) (diff) | |
parent | Return embed proxy url even if imagor not set up. Also make warning nicer (diff) | |
download | server-0b89db8031447385fe8edbda954a0ce8f613dbfa.tar.xz |
Merge pull request #934 from fosscord/master
Merge master into dev/endpoints-in-ping
Diffstat (limited to 'src')
-rw-r--r-- | src/api/util/handlers/Message.ts | 1 | ||||
-rw-r--r-- | src/api/util/utility/EmbedHandlers.ts | 19 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/api/util/handlers/Message.ts b/src/api/util/handlers/Message.ts index 93dc3bf4..d6fe48bd 100644 --- a/src/api/util/handlers/Message.ts +++ b/src/api/util/handlers/Message.ts @@ -223,6 +223,7 @@ export async function postHandleMessage(message: Message) { data.embeds.push(embed); } } catch (e) { + console.error(`[Embeds] Error while generating embed`, e); Sentry.captureException(e, (scope) => { scope.clear(); scope.setContext("request", { url }); diff --git a/src/api/util/utility/EmbedHandlers.ts b/src/api/util/utility/EmbedHandlers.ts index 2549937e..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. docs.fosscord.com/set/up/a/page/about/this", - ); - 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 => { |