fix event content-type
This commit is contained in:
@@ -20,7 +20,7 @@ const log = require('../log')
|
||||
router.use(cors())
|
||||
|
||||
// is federation enabled? middleware
|
||||
router.use((req, res, next) => {
|
||||
router.use((_req, res, next) => {
|
||||
if (settingsController.settings.enable_federation) { return next() }
|
||||
log.debug('Federation disabled!')
|
||||
return res.status(401).send('Federation disabled')
|
||||
@@ -29,14 +29,20 @@ router.use((req, res, next) => {
|
||||
router.use(express.json({ type: ['application/json', 'application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'] }))
|
||||
|
||||
router.get('/m/:event_id', async (req, res) => {
|
||||
const settingsController = require('../api/controller/settings')
|
||||
log.debug('[AP] Get event details ')
|
||||
const event_id = req.params.event_id
|
||||
if (req.accepts('html')) { return res.redirect(301, `/event/${event_id}`) }
|
||||
const acceptHtml = req.accepts('html', 'application/activity+json') === 'html'
|
||||
if (acceptHtml) { return res.redirect(301, `/event/${event_id}`) }
|
||||
|
||||
const event = await Event.findByPk(req.params.event_id, { include: [User, Tag, Place] })
|
||||
if (!event) { return res.status(404).send('Not found') }
|
||||
return res.json(event.toAP(settingsController.settings.instance_name, settingsController.settings.instance_locale))
|
||||
const eventAp = event.toAP(settingsController.settings.instance_name, settingsController.settings.instance_locale)
|
||||
eventAp['@context'] = [
|
||||
"https://www.w3.org/ns/activitystreams"
|
||||
]
|
||||
|
||||
res.type('application/activity+json; charset=utf-8')
|
||||
return res.json(eventAp)
|
||||
})
|
||||
|
||||
// get any message coming from federation
|
||||
|
||||
Reference in New Issue
Block a user