refactor res.locals and settings
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user