The mapLink function now returns the creator
This commit is contained in:
@ -1,11 +1,15 @@
|
|||||||
const Link = require('../models/Link');
|
const Link = require('../models/Link');
|
||||||
const {getUserByName} = require("./user");
|
const {getUserByName, getUserById} = require("./user");
|
||||||
const {Op} = require("sequelize");
|
const {Op} = require("sequelize");
|
||||||
|
|
||||||
module.exports.mapLink = (link) => ({
|
module.exports.mapLink = async (link) => {
|
||||||
id: link.id, accessId: link.accessId, domainName: link.domainName, tags: link.tags?.split(","),
|
const user = await getUserById(link.creatorId);
|
||||||
title: link.title, type: link.type, clicks: link.clicks, meta: JSON.parse(link.meta)
|
|
||||||
});
|
return {
|
||||||
|
...link, tags: link.tags?.split(","), meta: JSON.parse(link.meta), createdAt: undefined, updatedAt: undefined,
|
||||||
|
creator: {id: user.id, username: user.username, email: user.email}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.listLinks = async (domainName, configuration) => {
|
module.exports.listLinks = async (domainName, configuration) => {
|
||||||
if (configuration.creator) {
|
if (configuration.creator) {
|
||||||
|
Reference in New Issue
Block a user