show event author in event page if admin is browsing and feature is enabled from config file

This commit is contained in:
encrypt
2023-06-16 13:57:34 +02:00
parent 8eb43ac7b5
commit 50fbecb15a
4 changed files with 13 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ const helpers = require('../../helpers')
const Col = helpers.col
const notifier = require('../../notifier')
const { Event, Resource, Tag, Place, Notification, APUser } = require('../models/models')
const { Event, Resource, Tag, Place, Notification, User, APUser } = require('../models/models')
const exportController = require('./export')
@@ -100,6 +100,7 @@ const eventController = {
async get(req, res) {
const format = req.params.format || 'json'
const settings = res.locals.settings
const is_admin = req.user && req.user.is_admin
const slug = req.params.event_slug
@@ -128,7 +129,8 @@ const eventController = {
required: false,
attributes: ['id', 'activitypub_id', 'data', 'hidden']
},
{ model: Event, required: false, as: 'parent', attributes: ['id', 'recurrent', 'is_visible', 'start_datetime'] }
{ model: Event, required: false, as: 'parent', attributes: ['id', 'recurrent', 'is_visible', 'start_datetime'] },
...((is_admin && settings.show_event_author_to_admin) ? [{model: User, attributes: ['email']}] : [])
],
order: [[Resource, 'id', 'DESC']]
})

View File

@@ -29,6 +29,7 @@ const defaultSettings = {
allow_recurrent_event: false,
allow_online_event: true,
recurrent_event_visible: false,
show_event_author_to_admin: config.show_event_author_to_admin || false,
allow_geolocation: false,
geocoding_provider_type: 'Nominatim',
geocoding_provider: 'https://nominatim.openstreetmap.org/search',