/event redirect to AP repr when accept application/json

This commit is contained in:
lesion
2021-11-11 16:55:11 +01:00
parent 82c21b3255
commit 8fc0da7474
3 changed files with 35 additions and 6 deletions

View File

@@ -214,7 +214,20 @@ module.exports = {
cursor = cursor.hour(date.hour()).minute(date.minute()).second(0)
log.debug(cursor)
return cursor
},
async APRedirect (req, res, next) {
const accepted = req.accepts('html', 'application/json', 'application/activity+json', 'application/ld+json' )
if (accepted && accepted !== 'html') {
const eventController = require('../server/api/controller/event')
try {
const event = await eventController._get(req.params.slug)
if (event) {
return res.redirect(`/federation/m/${event.id}`)
}
} catch (e) {}
}
next()
}
}