diff --git a/server/api/index.js b/server/api/index.js index a9a53ce9..49d0e61d 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -170,9 +170,11 @@ 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) diff --git a/server/api/models/models.js b/server/api/models/models.js index 0b46a05d..791c124b 100644 --- a/server/api/models/models.js +++ b/server/api/models/models.js @@ -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 = {} \ No newline at end of file diff --git a/server/helpers.js b/server/helpers.js index 17f6a289..fbd41bf5 100644 --- a/server/helpers.js +++ b/server/helpers.js @@ -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) + } } } diff --git a/server/taskManager.js b/server/taskManager.js index 20e010db..c0385c70 100644 --- a/server/taskManager.js +++ b/server/taskManager.js @@ -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({