diff --git a/alerts.js b/alerts.js index 6732038..7e2b9cb 100644 --- a/alerts.js +++ b/alerts.js @@ -27,7 +27,7 @@ router.get('/', (req, res) => { function loadAlerts(noCache) { if (noCache) { - console.log('load alerts (no cache)'); + console.log('Load alerts (no cache)'); return loadAlertsDirect(); } @@ -36,7 +36,7 @@ function loadAlerts(noCache) { } if (!pendingLoad) { - console.log('load alerts (cache)'); + console.log('Load alerts (cache)'); pendingLoad = loadAlertsDirect() .then(response => { pendingLoad = null; diff --git a/config.js b/config.js index 418e357..019e7a7 100644 --- a/config.js +++ b/config.js @@ -78,11 +78,6 @@ config.sso = { jwksUri: 'https://sso.sota.org.uk/auth/realms/SOTA/protocol/openid-connect/certs' }; -config.mail = { - host: process.env.MAIL_HOST, - port: process.env.MAIL_PORT -}; - config.solardata = { apiKey: process.env.SOLARDATA_API_KEY }; diff --git a/package-lock.json b/package-lock.json index 65f057f..016e6b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,6 @@ "moment": "^2.24.0", "mongodb": "^4.8.1", "multer": "^1.4.2", - "nodemailer": "^6.4.6", "reconnect-net": "^1.1.1", "sharp": "^0.26.3", "togeojson": "^0.16.0", @@ -2896,15 +2895,6 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz", "integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==" }, - "node_modules/nodemailer": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.6.tgz", - "integrity": "sha512-/kJ+FYVEm2HuUlw87hjSqTss+GU35D4giOpdSfGp7DO+5h6RlJj7R94YaYHOkoxu1CSaM0d3WRBtCzwXrY6MKA==", - "hasInstallScript": true, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/noop-logger": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", @@ -6614,11 +6604,6 @@ "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-3.1.0.tgz", "integrity": "sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw==" }, - "nodemailer": { - "version": "6.4.6", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.6.tgz", - "integrity": "sha512-/kJ+FYVEm2HuUlw87hjSqTss+GU35D4giOpdSfGp7DO+5h6RlJj7R94YaYHOkoxu1CSaM0d3WRBtCzwXrY6MKA==" - }, "noop-logger": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz", diff --git a/package.json b/package.json index 5fc9c0d..5917c0a 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "moment": "^2.24.0", "mongodb": "^4.8.1", "multer": "^1.4.2", - "nodemailer": "^6.4.6", "reconnect-net": "^1.1.1", "sharp": "^0.26.3", "togeojson": "^0.16.0", diff --git a/photos.js b/photos.js index 82da02e..2140c91 100644 --- a/photos.js +++ b/photos.js @@ -6,7 +6,6 @@ const exif = require('exif-reader') const path = require('path') const hasha = require('hasha') const minio = require('minio') -const nodemailer = require('nodemailer') const config = require('./config') const db = require('./db') @@ -114,15 +113,7 @@ function uploadToCloud(storageConfig, targetPath, buffer) { } return minioClient.putObject(storageConfig.bucketName, targetPath, buffer, metadata) .catch(err => { - console.error(err) - - let transporter = nodemailer.createTransport(config.mail) - transporter.sendMail({ - from: 'api@sotl.as', - to: 'mk@neon1.net', - subject: 'Cloud photo upload failed', - text: `The file ${filename} could not be uploaded to ${storageConfig.endpoint} at path ${targetPath}:\n${err}` - }) + console.error('Cloud photo upload failed: ' + err) }) } diff --git a/photos_router.js b/photos_router.js index f75098d..d7d927e 100644 --- a/photos_router.js +++ b/photos_router.js @@ -4,7 +4,6 @@ const config = require('./config') const photos = require('./photos') const jwt = require('express-jwt') const jwksRsa = require('jwks-rsa') -const nodemailer = require('nodemailer') const db = require('./db') let upload = multer({dest: config.photos.uploadPath}) diff --git a/rbn.js b/rbn.js index 458eec7..b5427cc 100644 --- a/rbn.js +++ b/rbn.js @@ -13,7 +13,7 @@ class RbnReceiver { wsManager.on('message', (ws, message) => { if (message.rbnFilter !== undefined) { - console.log("Set RBN filter to " + JSON.stringify(message.rbnFilter)); + //console.log("Set RBN filter to " + JSON.stringify(message.rbnFilter)); ws.rbnFilter = message.rbnFilter; this.sendSpotHistory(ws) diff --git a/sotaspots.js b/sotaspots.js index 876ca95..e35e822 100644 --- a/sotaspots.js +++ b/sotaspots.js @@ -30,7 +30,7 @@ class SotaSpotReceiver { if (this.latestSpots.getLength() == 0) { numSpotsToLoad = config.sotaspots.initialLoadSpots; } - console.log(`load ${numSpotsToLoad} spots`); + console.log(`Load ${numSpotsToLoad} spots`); axios.get(config.sotaspots.url + '/' + numSpotsToLoad + '/all') .then(response => { let minSpotId = undefined; diff --git a/spots.js b/spots.js deleted file mode 100644 index a4bcf84..0000000 --- a/spots.js +++ /dev/null @@ -1,74 +0,0 @@ -const axios = require('axios'); -const wsManager = require('./ws-manager'); -const config = require('./config'); -const db = require('./db'); -const TreeMap = require("treemap-js"); - -const latestSpots = new TreeMap(); -const maxSpots = 100; -const updateInterval = 30000; -let lastUpdate = null; - -wsManager.on('connect', (ws) => { - let spots = [] - latestSpots.each(spot => { - spots.push(spot) - }); - wsManager.unicast({spots}, ws); -}) - -loadSpots(); -setInterval(loadSpots, updateInterval); - -function loadSpots() { - console.log('load spots'); - axios.get('https://sota-api2.azurewebsites.net/api/spots/' + maxSpots + '/all') - .then(response => { - response.data.forEach(spot => { - spot.summit = {code: spot.associationCode + '/' + spot.summitCode}; - delete spot.associationCode; - delete spot.summitCode; - delete spot.summitDetails; - delete spot.highlightColor; - if (spot.comments === '(null)') { - spot.comments = ''; - } - updateSpot(spot); - }); - }); -} - -function updateSpot(spot) { - // Check if we already have this spot in the list, and if it has changed - if (spotsAreEqual(latestSpots.get(spot.id), spot)) { - return; - } - - // Spot is new or modified - console.log("New/modified spot id " + spot.id); - lookupSummit(spot.summit.code) - .then(summit => { - if (summit) { - spot.summit = summit; - } - - latestSpots.set(spot.id, spot); - while (latestSpots.getLength() > maxSpots) { - latestSpots.remove(latestSpots.getMinKey()); - } - wsManager.broadcast({spot}); - }) -} - -function lookupSummit(summitCode, callback) { - return db.getDb().collection('summits').findOne({code: summitCode}, {projection: {'_id': false, code: true, name: true, altitude: true, points: true, activationCount: true}}); -} - -function spotsAreEqual(spot1, spot2) { - if (spot1 === undefined || spot2 === undefined) { - return false; - } - return (spot1.id === spot2.id && spot1.comments === spot2.comments && spot1.callsign === spot2.callsign && - spot1.summit.code === spot2.summit.code && spot1.activatorCallsign === spot2.activatorCallsign && - spot1.frequency === spot2.frequency && spot1.mode === spot2.mode); -} diff --git a/ws-manager.js b/ws-manager.js index c75dfa4..8d95c1b 100644 --- a/ws-manager.js +++ b/ws-manager.js @@ -11,7 +11,7 @@ class WebSocketManager extends EventEmitter { this.router = express.Router(); this.router.ws('/', (ws, req) => { - console.log('WebSocket client connected'); + //console.log('WebSocket client connected'); ws.isAlive = true; this.webSocketClients.add(ws); console.log("Number of clients: " + this.webSocketClients.size); @@ -28,7 +28,7 @@ class WebSocketManager extends EventEmitter { ws.isAlive = true; }); ws.on('close', () => { - console.log("WebSocket closed"); + //console.log("WebSocket closed"); clearInterval(ws.pingInterval); this.webSocketClients.delete(ws); console.log("Number of clients: " + this.webSocketClients.size); @@ -42,7 +42,7 @@ class WebSocketManager extends EventEmitter { ws.pingInterval = setInterval(() => { if (!ws.isAlive) { - console.log("WebSocket ping timeout"); + //console.log("WebSocket ping timeout"); ws.terminate(); return; }