diff --git a/app/controllers/home.js b/app/controllers/home.js index 905788f..43cfbc5 100644 --- a/app/controllers/home.js +++ b/app/controllers/home.js @@ -150,7 +150,7 @@ class HomeController extends SiteController { res.locals.pageTitle = `${res.locals.userProfile.displayName || res.locals.userProfile.username} | ${this.dtp.config.site.name}`; res.locals.pageDescription = res.locals.userProfile.bio || this.dtp.config.site.description; - res.locals.pagination = this.getPaginationParameters(req, 20); + res.locals.pagination = this.getPaginationParameters(req, 100); res.locals.links = await linkService.getForUser(res.locals.userProfile, res.locals.pagination); await userService.recordProfileView(res.locals.userProfile, req); @@ -165,7 +165,7 @@ class HomeController extends SiteController { async getHome (req, res, next) { const { link: linkService } = this.dtp.services; try { - res.locals.pagination = this.getPaginationParameters(req, 20); + res.locals.pagination = this.getPaginationParameters(req, 100); if (req.user) { res.locals.links = await linkService.getForUser(req.user, res.locals.pagination); res.render('index-logged-in'); diff --git a/app/services/user.js b/app/services/user.js index 9c29dbb..4003281 100644 --- a/app/services/user.js +++ b/app/services/user.js @@ -561,6 +561,34 @@ class UserService { } await User.updateOne({ _id: user._id }, { $unset: { 'header': '' } }); } + + async remove (user) { + const { + link: linkService, + otpAuth: otpAuthService, + resource: resourceService, + } = this.dtp.services; + + const ChatMessage = mongoose.model('ChatMessage'); + await ChatMessage.deleteMany({ author: user._id }); + + const Link = mongoose.model('Link'); + await Link + .find({ user: user._id }) + .cursor() + .eachAsync(async (link) => { + await linkService.remove(link); + }); + + const LinkCategory = mongoose.model('LinkCategory'); + await LinkCategory.deleteMany({ user: user._id }); + + await this.removeHeaderImage(user); + await this.removePhoto(user); + + await otpAuthService.removeForUser(user); + await resourceService.remove('User', user); + } } module.exports = { diff --git a/dtp-libertylinks-cli.js b/dtp-libertylinks-cli.js index 96e76d9..119d6d2 100644 --- a/dtp-libertylinks-cli.js +++ b/dtp-libertylinks-cli.js @@ -4,6 +4,8 @@ 'use strict'; +const DTP_COMPONENT_NAME = 'sites-cli'; + require('dotenv').config(); const path = require('path'); @@ -18,7 +20,7 @@ const { module.pkg = require(path.join(__dirname, 'package.json')); module.config = { - componentName: 'sites-cli', + componentName: DTP_COMPONENT_NAME, root: __dirname, site: { name: process.env.DTP_SITE_NAME, @@ -177,4 +179,4 @@ module.resetIndexes = async ( ) => { module.log.error('failed to process target', { app: module.app, error }); } -})(); \ No newline at end of file +})(); diff --git a/lib/site-platform.js b/lib/site-platform.js index 270aed9..0403acf 100644 --- a/lib/site-platform.js +++ b/lib/site-platform.js @@ -47,7 +47,6 @@ module.connectDatabase = async (/*dtp*/) => { } }; - module.loadModels = async (dtp) => { dtp.models = module.models = [ ]; const modelScripts = glob.sync(path.join(dtp.config.root, 'app', 'models', '*.js')); @@ -169,7 +168,7 @@ module.loadControllers = async (dtp) => { */ module.log.info('registering ExpressJS error handler'); dtp.app.use((error, req, res, next) => { // jshint ignore:line - res.locals.errorCode = error.statusCode || error.status || error.code || 500; + res.locals.errorCode = error.statusCode || error.status || 500; module.log.error('ExpressJS error', { url: req.url, error }); res.status(res.locals.errorCode).render('error', { message: error.message,