Browse Source

quick updates

master
Rob Colbert 2 years ago
parent
commit
0ebdb951a3
  1. 4
      app/controllers/home.js
  2. 28
      app/services/user.js
  3. 6
      dtp-libertylinks-cli.js
  4. 3
      lib/site-platform.js

4
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');

28
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 = {

6
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 });
}
})();
})();

3
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,

Loading…
Cancel
Save