From dda70a66c9615a7edfd1e220e000eab30996244e Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sun, 15 Jan 2023 16:21:46 +1100 Subject: Add an error log if embed handler fails, in addition to the existing sentry log --- src/api/util/handlers/Message.ts | 1 + 1 file changed, 1 insertion(+) 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 }); -- cgit 1.4.1 From e0aae75757285433168348e55d22c4b25522bc8d Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sun, 15 Jan 2023 17:35:54 +1100 Subject: Window name patch + fix overlapping text in client patcher --- scripts/client.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/scripts/client.js b/scripts/client.js index 3cdd3719..606430be 100644 --- a/scripts/client.js +++ b/scripts/client.js @@ -65,6 +65,12 @@ const doPatch = (content) => { //content = content.replaceAll(/DiscordTag/g, "FosscordTag"); content = content.replaceAll(/\*Discord\*/g, `*${INSTANCE_NAME}*`); + // Replace window title + content = content.replaceAll( + ":c.base;", + `:(c.base == 'Discord' ? '${INSTANCE_NAME}' : c.base);`, + ); + //server -> guild const serverVariations = [ ['"Server"', '"Guild"'], @@ -186,6 +192,12 @@ const processFile = async (name) => { ); }; +const print = (x) => { + process.stdout.write( + `${x}${" ".repeat(process.stdout.columns - x.length)}\r`, + ); +}; + (async () => { const start = Date.now(); @@ -198,9 +210,7 @@ const processFile = async (name) => { while (INDEX_SCRIPTS.length > 0) { const asset = INDEX_SCRIPTS.shift(); - process.stdout.write( - `Scraping asset ${asset}. Remaining: ${INDEX_SCRIPTS.length} \r`, - ); + print(`Scraping asset ${asset}. Remaining: ${INDEX_SCRIPTS.length}`); const newAssets = await processFile(asset); assets.push(...newAssets); @@ -218,8 +228,8 @@ const processFile = async (name) => { while (CACHE_MISSES.length > 0) { const asset = CACHE_MISSES.shift(); - process.stdout.write( - `Scraping cache misses ${asset}. Remaining: ${CACHE_MISSES.length} \r`, + print( + `Scraping cache misses ${asset}. Remaining: ${CACHE_MISSES.length}`, ); if (existsSync(path.join(CACHE_PATH, `${asset}`))) { @@ -236,9 +246,7 @@ const processFile = async (name) => { while (existing.length > 0) { var file = existing.shift(); - process.stdout.write( - `Patching existing ${file}. Remaining: ${existing.length}. \r`, - ); + print(`Patching existing ${file}. Remaining: ${existing.length}.`); var text = await fs.readFile(path.join(CACHE_PATH, file)); if (file.includes(".js") || file.includes(".css")) { @@ -273,7 +281,7 @@ const processFile = async (name) => { : 1; const finishTime = averageRate * (assets.length - i); - process.stdout.write( + print( `Caching asset ${asset}. ` + `${i}/${assets.length - 1} = ${Math.floor( (i / (assets.length - 1)) * 100, @@ -282,8 +290,6 @@ const processFile = async (name) => { // Date.now() + finishTime, // ).toLocaleTimeString()}`, ); - //not adding to the previous mess, incase the finish time is added back or something - process.stdout.write(" \r"); promises.push(processFile(asset)); // await processFile(asset); -- cgit 1.4.1 From de3909f646b3ad19e00d6671a471678efbf4e5e5 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Mon, 16 Jan 2023 00:03:51 +1100 Subject: Update dead lines --- README.md | 6 ++---- src/api/util/utility/EmbedHandlers.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8ec423ed..2133865d 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,6 @@ This repository contains: - [HTTP CDN Server](/src/cdn) - [Utility and Database Models](/src/util) -## [Resources](https://docs.fosscord.com/resources/) +## [Contributing](https://docs.fosscord.com/contributing/) -- [Contributing](https://docs.fosscord.com/contributing/server/) - -## [Setup](https://docs.fosscord.com/server/setup/) +## [Setup](https://docs.fosscord.com/setup/server/) diff --git a/src/api/util/utility/EmbedHandlers.ts b/src/api/util/utility/EmbedHandlers.ts index 2549937e..0e4146d1 100644 --- a/src/api/util/utility/EmbedHandlers.ts +++ b/src/api/util/utility/EmbedHandlers.ts @@ -43,7 +43,7 @@ export const getProxyUrl = ( // TODO: Imagor documentation console.log( - "Imagor has not been set up correctly. docs.fosscord.com/set/up/a/page/about/this", + "Imagor has not been set up correctly. https://docs.fosscord.com/setup/server/configuration/imagor/", ); return ""; }; -- cgit 1.4.1 From 577124764583f85a6ca10bdf4b6d63c7c65d964c Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:20:17 +1100 Subject: Return embed proxy url even if imagor not set up. Also make warning nicer --- src/api/util/utility/EmbedHandlers.ts | 19 ++++++++++++++----- 1 file 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 => { -- cgit 1.4.1