Added a filter for dead links in the link controller

This commit is contained in:
2023-01-08 02:53:00 +01:00
parent 6baae04f4f
commit 2423e6ee4e

View File

@ -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}});
}
}