isGeocodingEnabled

This commit is contained in:
lesion 2023-01-10 18:15:33 +01:00
parent 2a59e45a3c
commit ded3c2fd98
No known key found for this signature in database
GPG key ID: 352918250B012177
4 changed files with 33 additions and 7 deletions

View file

@ -170,10 +170,12 @@ module.exports = () => {
api.get('/places', isAdmin, placeController.getAll)
api.get('/place/:placeName', cors, placeController.getEvents)
api.get('/place', cors, placeController.search)
api.get('/placeOSM/Nominatim/:place_details', cors, placeController._nominatim)
api.get('/placeOSM/Photon/:place_details', cors, placeController._photon)
api.put('/place', isAdmin, placeController.updatePlace)
// - GEOCODING
api.get('/placeOSM/Nominatim/:place_details', helpers.isGeocodingEnabled, placeController._nominatim)
api.get('/placeOSM/Photon/:place_details', helpers.isGeocodingEnabled, placeController._photon)
// - TAGS
api.get('/tags', isAdmin, tagController.getAll)
api.get('/tag', cors, tagController.search)

View file

@ -1,2 +1,20 @@
// export default models
// Announcement: require('./announcement'),
// APUser: require('./ap_user'),
// Collection: require('./collection'),
// Event: require('./event'),
// EventNotification: require('./eventnotification'),
// Filter: require('./filter'),
// Instance: require('./instance'),
// Notification: require('./notification'),
// OAuthClient: require('./oauth_client'),
// OAuthCode: require('./oauth_code'),
// OAuthToken: require('./oauth_token'),
// Place: require('./place'),
// Resource: require('./resource'),
// Setting: require('./setting'),
// Tag: require('./tag'),
// User: require('./user'),
module.exports = {}

View file

@ -1,6 +1,5 @@
const ical = require('ical.js')
const settingsController = require('./api/controller/settings')
const acceptLanguage = require('accept-language')
const express = require('express')
const dayjs = require('dayjs')
const timezone = require('dayjs/plugin/timezone')
@ -15,7 +14,6 @@ const axios = require('axios')
const crypto = require('crypto')
const Microformats = require('microformat-node')
const get = require('lodash/get')
const cloneDeep = require('lodash/cloneDeep')
const DOMPurify = require('dompurify')
const { JSDOM } = require('jsdom')
@ -119,9 +117,9 @@ module.exports = {
log.warn(err)
} else {
res.status(404).send('Not found (but nice try 😊)')
// }
}
}})
}
})
})
router.use('/fallbackimage.png', (req, res, next) => {
@ -287,5 +285,13 @@ module.exports = {
return res.redirect((accepted === 'application/rss+xml' ? '/feed/rss' : '/feed/ics') + req.path)
}
next()
},
async isGeocodingEnabled(req, res, next) {
if (res.locals.settings.allow_geolocation) {
next()
} else {
res.sendStatus(403)
}
}
}

View file

@ -1,5 +1,4 @@
const log = require('./log')
const eventController = require('./api/controller/event')
const placeHelpers = require('./helpers/place')
const tagHelpers = require('./helpers/tag')
// const notifier = require('./notifier')
@ -54,6 +53,7 @@ class TaskManager {
}
start (interval = loopInterval) {
const eventController = require('./api/controller/event')
// create and clean recurrent events
this.add(new Task({