From 6bd4558b2600b881515c431135fd47313d81e376 Mon Sep 17 00:00:00 2001 From: Solomon Cammack Date: Sun, 13 Aug 2023 21:38:38 +0100 Subject: [PATCH] Fix redirect load logic in a place I forgot about --- server/src/meta.js | 2 +- server/src/routes.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/meta.js b/server/src/meta.js index 69631de2..c21f17a9 100644 --- a/server/src/meta.js +++ b/server/src/meta.js @@ -353,7 +353,7 @@ module.exports = ({ app, Cache }) => { } async function getAllRedirects() { - return Promise.all((await Cache.get("Redirects"))?.ids?.map(id => Cache.get(id))); + return Promise.all(((await Cache.get("Redirects"))?.ids || []).map(id => Cache.get(id))); } async function getRedirect(path = "", subdomain) { diff --git a/server/src/routes.js b/server/src/routes.js index 561f3302..383ef0be 100644 --- a/server/src/routes.js +++ b/server/src/routes.js @@ -24,7 +24,7 @@ function niceJoin(array) { module.exports = ({ app, cors, Cache, io }) => { app.get("/redirect", async (req, res) => { try { - let redirects = (await Cache.get("Redirects"))?.items; + let redirects = await Promise.all(((await Cache.get("Redirects"))?.ids || []).map(id => Cache.get(id))); let subdomain = req.query.subdomain || null; let path = req.query.path; @@ -32,7 +32,7 @@ module.exports = ({ app, cors, Cache, io }) => { path = path.trim().toLowerCase(); - if (!redirects) return res.send({ redirect: null, warn: "no redirects loaded" }); + if (!redirects?.length) return res.send({ redirect: null, warn: "no redirects loaded" }); let redirect = redirects.find(r => { if (!r.active) return false;