tag / place / event filtering, refactoring, cleaning

This commit is contained in:
lesion
2022-06-18 01:14:26 +02:00
parent 4d39fc41c5
commit e03b9c4499
7 changed files with 164 additions and 84 deletions

View File

@@ -116,6 +116,14 @@ module.exports = {
next()
},
col (field) {
if (config.db.dialect === 'postgres') {
return '"' + field.split('.').join('"."') + '"'
} else {
return field
}
},
async getImageFromURL (url) {
log.debug(`getImageFromURL ${url}`)
if(!/^https?:\/\//.test(url)) {
@@ -233,5 +241,13 @@ module.exports = {
}
}
next()
},
async feedRedirect (req, res, next) {
const accepted = req.accepts('html', 'application/rss+xml', 'text/calendar')
if (['application/rss+xml', 'text/calendar'].includes(accepted) && /^\/(tag|place|collection)\/.*/.test(req.path)) {
return res.redirect((accepted === 'application/rss+xml' ? '/feed/rss' : '/feed/ics') + req.path)
}
next()
}
}