refactor res.locals and settings

This commit is contained in:
lesion
2022-02-26 21:27:40 +01:00
parent 9e2ed063b6
commit cf3e1c69fa
20 changed files with 133 additions and 102 deletions

View File

@@ -1,6 +1,7 @@
const Event = require('../api/models/event')
const Resource = require('../api/models/resource')
const APUser = require('../api/models/ap_user')
const settingsController = require('../api/controller/settings')
const log = require('../log')
const helpers = require('../helpers')
@@ -10,7 +11,7 @@ module.exports = {
// create a resource from AP Note
async create (req, res) {
if (!req.settings.enable_resources) {
if (!settingsController.settings.enable_resources) {
log.info('Ignore resource as it is disabled in settings')
return
}
@@ -67,7 +68,7 @@ module.exports = {
}
// check if fedi_user that requested resource removal
// is the same that created the resource at first place
if (req.fedi_user.ap_id === resource.ap_user.ap_id) {
if (res.locals.fedi_user.ap_id === resource.ap_user.ap_id) {
await resource.destroy()
log.info(`Comment ${req.body.object.id} removed`)
res.sendStatus(201)