From 2423e6ee4eba3668f6de31d969f862f20e2e3d51 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sun, 8 Jan 2023 02:53:00 +0100 Subject: [PATCH] Added a filter for dead links in the link controller --- server/controller/link.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/controller/link.js b/server/controller/link.js index 40fc652..a64ab44 100644 --- a/server/controller/link.js +++ b/server/controller/link.js @@ -1,6 +1,7 @@ const Link = require('../models/Link'); const {getUserByName, getUserById} = require("./user"); const {Op} = require("sequelize"); +const {getModule} = require("./module"); module.exports.mapLink = async (link) => { const user = await getUserById(link.creatorId); @@ -27,8 +28,8 @@ module.exports.listLinks = async (domainName, configuration) => { return (await Link.findAll({ where: {...configuration, domainName}, limit: configuration.limit || 5000, - order: [['createdAt', 'DESC']] - })); + order: [['createdAt', 'DESC']], + })).filter(obj => getModule(obj.type)); } module.exports.getLinkById = async (id) => { @@ -53,4 +54,4 @@ module.exports.createLink = async (configuration) => { module.exports.editLink = async (id, configuration) => { return await Link.update(configuration, {where: {id}}); -} \ No newline at end of file +}