fix event content-type
This commit is contained in:
parent
9b22892466
commit
0764617e5d
3 changed files with 13 additions and 5 deletions
|
@ -154,6 +154,7 @@ if (config.status !== 'READY') {
|
||||||
|
|
||||||
|
|
||||||
api.get('/place/:placeName/events', cors, placeController.getEvents)
|
api.get('/place/:placeName/events', cors, placeController.getEvents)
|
||||||
|
api.get('/place/all', isAdmin, placeController.getAll)
|
||||||
api.get('/place', cors, placeController.get)
|
api.get('/place', cors, placeController.get)
|
||||||
api.put('/place', isAdmin, placeController.updatePlace)
|
api.put('/place', isAdmin, placeController.updatePlace)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ const log = require('../log')
|
||||||
router.use(cors())
|
router.use(cors())
|
||||||
|
|
||||||
// is federation enabled? middleware
|
// is federation enabled? middleware
|
||||||
router.use((req, res, next) => {
|
router.use((_req, res, next) => {
|
||||||
if (settingsController.settings.enable_federation) { return next() }
|
if (settingsController.settings.enable_federation) { return next() }
|
||||||
log.debug('Federation disabled!')
|
log.debug('Federation disabled!')
|
||||||
return res.status(401).send('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.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) => {
|
router.get('/m/:event_id', async (req, res) => {
|
||||||
const settingsController = require('../api/controller/settings')
|
|
||||||
log.debug('[AP] Get event details ')
|
log.debug('[AP] Get event details ')
|
||||||
const event_id = req.params.event_id
|
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] })
|
const event = await Event.findByPk(req.params.event_id, { include: [User, Tag, Place] })
|
||||||
if (!event) { return res.status(404).send('Not found') }
|
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
|
// get any message coming from federation
|
||||||
|
|
|
@ -224,7 +224,8 @@ module.exports = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async APRedirect (req, res, next) {
|
async APRedirect (req, res, next) {
|
||||||
if (!req.accepts('html')) {
|
const acceptJson = req.accepts('html', 'application/activity+json') === 'application/activity+json'
|
||||||
|
if (acceptJson) {
|
||||||
const eventController = require('../server/api/controller/event')
|
const eventController = require('../server/api/controller/event')
|
||||||
const event = await eventController._get(req.params.slug)
|
const event = await eventController._get(req.params.slug)
|
||||||
if (event) {
|
if (event) {
|
||||||
|
|
Loading…
Reference in a new issue