From b566debd79d036d26c47a34b426e5401d441e25d Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Sun, 16 Jan 2022 12:02:47 -0500 Subject: [PATCH 01/14] Additional Version Error Checking - Checks if stdout does not return anything - Removes destructuring for latest json in case it fails --- docker-compose.example.yml | 2 +- server/src/services/checkForUpdates.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docker-compose.example.yml b/docker-compose.example.yml index 731605d66..feebd444a 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -1,7 +1,7 @@ version: '3.1' services: reactmap: - image: ghcr.io/watwowmap/reactmap:main #pr-10 + image: ghcr.io/watwowmap/reactmap:main container_name: reactmap command: sh -c "yarn migrate:latest && yarn start" restart: unless-stopped diff --git a/server/src/services/checkForUpdates.js b/server/src/services/checkForUpdates.js index dcea0c4f7..88a3c2fc6 100644 --- a/server/src/services/checkForUpdates.js +++ b/server/src/services/checkForUpdates.js @@ -6,17 +6,17 @@ const Fetch = require('./Fetch') exec('git branch --show-current', async (err, stdout) => { try { - if (err || typeof stdout !== 'string') { + if (err || typeof stdout !== 'string' || !stdout.trim()) { throw new Error('Unable to get current branch', err.message) } - const { version } = await Fetch.json(`https://raw.githubusercontent.com/WatWowMap/ReactMap/${stdout.trim()}/package.json`) + const latest = await Fetch.json(`https://raw.githubusercontent.com/WatWowMap/ReactMap/${stdout.trim()}/package.json`) - if (!version) { + if (!latest || !latest.version) { throw new Error('Unable to fetch latest version') } const [majorC, minorC, patchC] = currentVersion.split('.').map(x => parseInt(x)) - const [majorN, minorN, patchN] = version.split('.').map(x => parseInt(x)) + const [majorN, minorN, patchN] = latest.version.split('.').map(x => parseInt(x)) if (stdout.trim() === 'main') { console.info('You are on the main branch, there may be additional features available on the "develop" branch. Type "git checkout develop" in the console if you would like the latest features.') @@ -24,7 +24,7 @@ exec('git branch --show-current', async (err, stdout) => { if (majorC < majorN || (majorC === majorN && minorC < minorN) || (majorC === majorN && minorC === minorN && patchC < patchN)) { - console.info(`[${stdout.trim().toUpperCase()}] New version available: ${version} (Current: ${currentVersion})`) + console.info(`[${stdout.trim().toUpperCase()}] New version available: ${latest.version} (Current: ${currentVersion})`) } } catch (e) { console.error(e.message) From 23367a4861ada18f2274ec42bbc9aac1cceebaf5 Mon Sep 17 00:00:00 2001 From: Fabio1988 <35898099+Fabio1988@users.noreply.github.com> Date: Sun, 16 Jan 2022 20:11:23 +0100 Subject: [PATCH 02/14] Update docker.yml --- .github/workflows/docker.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fa71c0aec..1a6a9d146 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,6 +11,13 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Set .gitsha + if: github.event_name == 'push' + run: "echo ${{github.sha}} > .gitsha" + - name: Set .gitref + if: github.event_name == 'push' + run: "echo ${{github.ref}} > .gitref" + - name: Log in to the Container registry uses: docker/login-action@v1 with: From 914665b635fe89055b6aa1873cd1f565b5169bfc Mon Sep 17 00:00:00 2001 From: Fabio1988 <35898099+Fabio1988@users.noreply.github.com> Date: Sun, 16 Jan 2022 20:12:54 +0100 Subject: [PATCH 03/14] Create .gitref --- .gitref | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitref diff --git a/.gitref b/.gitref new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/.gitref @@ -0,0 +1 @@ + From ab8d9e3fac584e02722af81c9bfc640071c80a8a Mon Sep 17 00:00:00 2001 From: Fabio1988 <35898099+Fabio1988@users.noreply.github.com> Date: Sun, 16 Jan 2022 20:13:08 +0100 Subject: [PATCH 04/14] Create .gitsha --- .gitsha | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitsha diff --git a/.gitsha b/.gitsha new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/.gitsha @@ -0,0 +1 @@ + From 177979061af1419051c46260b34b85c90b336090 Mon Sep 17 00:00:00 2001 From: Fabio1988 <35898099+Fabio1988@users.noreply.github.com> Date: Sun, 16 Jan 2022 20:14:02 +0100 Subject: [PATCH 05/14] Update .gitignore --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 02fb11d3a..ebe916c9b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,8 @@ server/src/data/masterfile.json # Docker file /docker-compose.yml +.gitref +.gitsha # Favicon public/favicon/* @@ -55,4 +57,4 @@ Desktop.ini *~ # VS Code -/.vscode/ \ No newline at end of file +/.vscode/ From 0637b74fcf136195e190c51c35741e8cf9ec2eb0 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Tue, 18 Jan 2022 23:27:00 -0500 Subject: [PATCH 06/14] Device Check --- src/components/popups/DevicePoly.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/popups/DevicePoly.jsx b/src/components/popups/DevicePoly.jsx index 9d0745954..caf0a8bb6 100644 --- a/src/components/popups/DevicePoly.jsx +++ b/src/components/popups/DevicePoly.jsx @@ -4,8 +4,7 @@ import { Polyline, Polygon } from 'react-leaflet' const DevicePoly = ({ device, color }) => { const arrayRoute = device.route[0].lat ? [device.route] : device.route - - return arrayRoute ? ( + return arrayRoute && Array.isArray(arrayRoute) ? ( <> {(device.type === 'circle_pokemon') ? arrayRoute.map((polygon, i) => ( @@ -28,6 +27,7 @@ const DevicePoly = ({ device, color }) => { const areEqual = (prev, next) => ( prev.device.type === next.device.type + && prev.color === next.color ) export default memo(DevicePoly, areEqual) From c48a2653f6f3ca7e14c8283d47096992b08af4e8 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Thu, 20 Jan 2022 09:32:42 -0500 Subject: [PATCH 07/14] Various Adjustments - Device route fix for mariadb users - Default stop/gym placement adjustment - Pokemon popup cleanup - Support other types of strategies --- server/src/index.js | 5 ++++- server/src/routes/authRouter.js | 2 +- src/components/markers/gym.jsx | 18 +++++++++--------- src/components/markers/pokestop.jsx | 10 +++++----- src/components/popups/DevicePoly.jsx | 3 +++ src/components/popups/Pokemon.jsx | 19 +++++++++---------- 6 files changed, 31 insertions(+), 26 deletions(-) diff --git a/server/src/index.js b/server/src/index.js index f1fa3f686..7c2a3502c 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -19,7 +19,10 @@ const { sessionStore } = require('./services/sessionStore') const rootRouter = require('./routes/rootRouter') const typeDefs = require('./graphql/typeDefs') const resolvers = require('./graphql/resolvers') -require('./services/checkForUpdates') + +if (!config.devOptions.skipUpdateCheck) { + require('./services/checkForUpdates') +} const app = express() diff --git a/server/src/routes/authRouter.js b/server/src/routes/authRouter.js index 61e3b27cd..e4e5c49f4 100644 --- a/server/src/routes/authRouter.js +++ b/server/src/routes/authRouter.js @@ -9,7 +9,7 @@ const { authentication: { strategies } } = require('../services/config') // Loads up the base auth routes and any custom ones strategies.forEach(strategy => { - const method = strategy.type === 'local' ? 'post' : 'get' + const method = strategy.type === 'discord' || strategy.type === 'telegram' ? 'get' : 'post' if (strategy.enabled) { router[method](`/${strategy.name}`, passport.authenticate(strategy.name, { failureRedirect: '/', diff --git a/src/components/markers/gym.jsx b/src/components/markers/gym.jsx index 24d45e777..9ad9cd4cb 100644 --- a/src/components/markers/gym.jsx +++ b/src/components/markers/gym.jsx @@ -63,8 +63,8 @@ export default function GymMarker(gym, hasHatched, hasRaid, filters, Icons, user style={{ width: gymSize, height: gymSize, - bottom: -1 + gymMod.offsetY, - left: `${gymMod.offsetX * 100}%`, + bottom: 2 + gymMod.offsetY, + left: `${gymMod.offsetX * 50}%`, transform: 'translateX(-50%)', }} /> @@ -74,8 +74,8 @@ export default function GymMarker(gym, hasHatched, hasRaid, filters, Icons, user style={{ width: gymSize / 1.5, height: 'auto', - bottom: -1 + gymMod.offsetY, - left: `${gymMod.offsetX * 15}%`, + bottom: 2 + gymMod.offsetY, + left: `${gymMod.offsetX * -33}%`, transform: 'translateX(-50%)', }} /> @@ -86,8 +86,8 @@ export default function GymMarker(gym, hasHatched, hasRaid, filters, Icons, user style={{ width: gymSize / 2, height: 'auto', - bottom: 20 + gymMod.offsetY, - left: `${gymMod.offsetX * 10}%`, + bottom: 23 + gymMod.offsetY, + left: `${gymMod.offsetX * -40}%`, transform: 'translateX(-50%)', }} /> @@ -98,8 +98,8 @@ export default function GymMarker(gym, hasHatched, hasRaid, filters, Icons, user style={{ width: gymSize, height: 'auto', - bottom: 10 + gymMod.offsetY, - left: `${gymMod.offsetX * 100}%`, + bottom: 13 + gymMod.offsetY, + left: `${gymMod.offsetX * 55}%`, transform: 'translateX(-50%)', }} /> @@ -111,7 +111,7 @@ export default function GymMarker(gym, hasHatched, hasRaid, filters, Icons, user width: raidSize, height: raidSize, bottom: gymSize * 0.4 + slotModifier * raidMod.offsetY, - left: `${raidMod.offsetX * 100}%`, + left: `${raidMod.offsetX * 55}%`, transform: 'translateX(-50%)', }} /> diff --git a/src/components/markers/pokestop.jsx b/src/components/markers/pokestop.jsx index db4cadf21..c9d50303a 100644 --- a/src/components/markers/pokestop.jsx +++ b/src/components/markers/pokestop.jsx @@ -112,8 +112,8 @@ export default function stopMarker(pokestop, hasQuest, hasLure, hasInvasion, fil style={{ width: baseSize, height: baseSize, - bottom: -1 + pokestopMod.offsetY, - left: `${pokestopMod.offsetX * 100}%`, + bottom: 2 + pokestopMod.offsetY, + left: `${pokestopMod.offsetX * 50}%`, transform: 'translateX(-50%)', }} /> @@ -123,7 +123,7 @@ export default function stopMarker(pokestop, hasQuest, hasLure, hasInvasion, fil style={{ width: baseSize / 2, height: 'auto', - bottom: 20 + pokestopMod.offsetY, + bottom: 23 + pokestopMod.offsetY, left: `${pokestopMod.offsetX * 10}%`, transform: 'translateX(-50%)', }} @@ -139,7 +139,7 @@ export default function stopMarker(pokestop, hasQuest, hasLure, hasInvasion, fil bottom: (baseSize * 0.6 + (invasionMod.removeQuest ? 10 : totalInvasionSize)) * rewardMod.offsetY + (questSizes[i] * i), - left: `${rewardMod.offsetX * 100}%`, + left: `${rewardMod.offsetX * 50}%`, transform: 'translateX(-50%)', }} /> @@ -156,7 +156,7 @@ export default function stopMarker(pokestop, hasQuest, hasLure, hasInvasion, fil height: invasionSizes[i], bottom: baseSize * 0.5 * invasionMod.offsetY + (invasionSizes[i] * i), - left: `${invasionMod.offsetX * 100}%`, + left: `${invasionMod.offsetX * 50}%`, transform: 'translateX(-50%)', }} /> diff --git a/src/components/popups/DevicePoly.jsx b/src/components/popups/DevicePoly.jsx index caf0a8bb6..dd0e226b6 100644 --- a/src/components/popups/DevicePoly.jsx +++ b/src/components/popups/DevicePoly.jsx @@ -3,6 +3,9 @@ import React, { memo } from 'react' import { Polyline, Polygon } from 'react-leaflet' const DevicePoly = ({ device, color }) => { + if (typeof device.route === 'string') { + device.route = JSON.parse(device.route) + } const arrayRoute = device.route[0].lat ? [device.route] : device.route return arrayRoute && Array.isArray(arrayRoute) ? ( <> diff --git a/src/components/popups/Pokemon.jsx b/src/components/popups/Pokemon.jsx index f28913678..f552d181c 100644 --- a/src/components/popups/Pokemon.jsx +++ b/src/components/popups/Pokemon.jsx @@ -56,7 +56,7 @@ export default function PokemonPopup({ classes={classes} isTutorial={isTutorial} /> - {pokemon.expire_timestamp && ( + {Boolean(pokemon.expire_timestamp) && ( {t('pokemon_cell')} )} - {hasStats && ( + {(hasStats && pokePerms.iv) && ( <> @@ -239,7 +238,7 @@ const Header = ({ ) } -const Stats = ({ pokemon, perms, t }) => { +const Stats = ({ pokemon, t }) => { const { cp, iv, atk_iv, def_iv, sta_iv, level, inactive_stats, } = pokemon @@ -258,27 +257,27 @@ const Stats = ({ pokemon, perms, t }) => { return ( - {(perms.iv && iv !== null) && ( + {iv !== null && ( {iv.toFixed(2)}{t('%')} )} - {(perms.iv && atk_iv !== null) && ( + {atk_iv !== null && ( - {atk_iv} | {def_iv} | {sta_iv} {inactive_stats ? '*' : ''} + {atk_iv || '?'} | {def_iv || '?'} | {sta_iv || '?'} {inactive_stats ? '*' : ''} )} - {(perms.iv && level !== null) && ( + {level !== null && ( {t('cp')} {cp} | {t('abbreviation_level')}{level} @@ -315,7 +314,7 @@ const Info = ({ }} /> )} - {gender && ( + {Boolean(gender) && ( {{ From 140c7ea31e985745a932c0dbe17415c2730bdf02 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Thu, 20 Jan 2022 19:49:27 -0500 Subject: [PATCH 08/14] Remove 0 :lappy: --- src/components/popups/Pokemon.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/popups/Pokemon.jsx b/src/components/popups/Pokemon.jsx index f552d181c..2d4f331cd 100644 --- a/src/components/popups/Pokemon.jsx +++ b/src/components/popups/Pokemon.jsx @@ -398,7 +398,7 @@ const Footer = ({ return ( <> - {hasPvp && ( + {Boolean(hasPvp) && ( Date: Thu, 20 Jan 2022 23:06:42 -0500 Subject: [PATCH 09/14] Docker Friendly Update Checking Co-Authored-By: Fabio1988 <35898099+Fabio1988@users.noreply.github.com> --- .gitref | 1 - .gitsha | 1 - server/src/services/checkForUpdates.js | 54 +++++++++++++++++--------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/.gitref b/.gitref index 8b1378917..e69de29bb 100644 --- a/.gitref +++ b/.gitref @@ -1 +0,0 @@ - diff --git a/.gitsha b/.gitsha index 8b1378917..e69de29bb 100644 --- a/.gitsha +++ b/.gitsha @@ -1 +0,0 @@ - diff --git a/server/src/services/checkForUpdates.js b/server/src/services/checkForUpdates.js index 88a3c2fc6..852c313d2 100644 --- a/server/src/services/checkForUpdates.js +++ b/server/src/services/checkForUpdates.js @@ -1,31 +1,47 @@ /* eslint-disable no-console */ const { exec } = require('child_process') - -const { version: currentVersion } = require('../../../package.json') -const Fetch = require('./Fetch') +const fs = require('fs') exec('git branch --show-current', async (err, stdout) => { try { - if (err || typeof stdout !== 'string' || !stdout.trim()) { - throw new Error('Unable to get current branch', err.message) - } - const latest = await Fetch.json(`https://raw.githubusercontent.com/WatWowMap/ReactMap/${stdout.trim()}/package.json`) + const gitRef = fs.readFileSync('.gitref', 'utf8') - if (!latest || !latest.version) { - throw new Error('Unable to fetch latest version') + if (err || typeof stdout !== 'string' || (!stdout.trim() && !gitRef)) { + throw new Error('Unable to get current branch', err) } + const branch = typeof gitRef === 'string' && gitRef.trim() + ? gitRef.trim() + : stdout.trim() - const [majorC, minorC, patchC] = currentVersion.split('.').map(x => parseInt(x)) - const [majorN, minorN, patchN] = latest.version.split('.').map(x => parseInt(x)) + exec('git rev-parse HEAD', async (err2, stdout2) => { + try { + const gitSha = fs.readFileSync('.gitsha', 'utf8') - if (stdout.trim() === 'main') { - console.info('You are on the main branch, there may be additional features available on the "develop" branch. Type "git checkout develop" in the console if you would like the latest features.') - } - if (majorC < majorN - || (majorC === majorN && minorC < minorN) - || (majorC === majorN && minorC === minorN && patchC < patchN)) { - console.info(`[${stdout.trim().toUpperCase()}] New version available: ${latest.version} (Current: ${currentVersion})`) - } + if (err2 || typeof stdout2 !== 'string' || (!stdout2.trim() && !gitSha)) { + throw new Error('Unable to get current sha', err) + } + const sha = typeof gitSha === 'string' && gitSha.trim() + ? gitSha.trim() + : stdout2.trim() + + exec(`git ls-remote https://github.com/WatWowMap/ReactMap/ refs/heads/${branch}`, (err3, stdout3) => { + try { + if (err3 || typeof stdout3 !== 'string' || !stdout3?.split('\t')?.[0]) { + throw new Error('Unable to get remote sha', err3) + } + const remoteSha = stdout3.split('\t')[0] + + if (remoteSha !== sha) { + console.log('There is a new version available:', remoteSha) + } + } catch (e) { + console.error(e.message) + } + }) + } catch (e) { + console.error(e.message) + } + }) } catch (e) { console.error(e.message) } From f4525278f53f4f68d276c62393b8c78465048ce7 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 21 Jan 2022 01:19:02 -0500 Subject: [PATCH 10/14] Simplify - Reduce try/catch statements in the check for updates - Clarify graphql validation error --- server/src/index.js | 13 +++++-- server/src/services/checkForUpdates.js | 54 +++++++++++--------------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/server/src/index.js b/server/src/index.js index 7c2a3502c..5cba78303 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -10,6 +10,7 @@ const passport = require('passport') const rateLimit = require('express-rate-limit') const i18next = require('i18next') const Backend = require('i18next-fs-backend') +const { ValidationError } = require('apollo-server-core') const { ApolloServer } = require('apollo-server-express') require('./db/initialization') @@ -33,9 +34,15 @@ const server = new ApolloServer({ introspection: config.devOptions.enabled, debug: config.devOptions.queryDebug, context: ({ req }) => ({ req }), - formatError: (e) => config.devOptions.enabled - ? console.error(e) - : console.error('GraphQL Error: ', e.message, e.path, e.location), + formatError: (e) => { + if (e instanceof ValidationError) { + console.warn('GraphQL Error:', e.message, '\nThis is very likely not a real issue and is caused by a user leaving an old browser session open, there is nothing you can do until they refresh.') + } else { + return config.devOptions.enabled + ? console.error(e) + : console.error('GraphQL Error: ', e.message, e.path, e.location) + } + }, }) server.start().then(() => server.applyMiddleware({ app, path: '/graphql' })) diff --git a/server/src/services/checkForUpdates.js b/server/src/services/checkForUpdates.js index 852c313d2..04edff31a 100644 --- a/server/src/services/checkForUpdates.js +++ b/server/src/services/checkForUpdates.js @@ -2,11 +2,11 @@ const { exec } = require('child_process') const fs = require('fs') -exec('git branch --show-current', async (err, stdout) => { - try { +try { + exec('git branch --show-current', async (err, stdout) => { const gitRef = fs.readFileSync('.gitref', 'utf8') - if (err || typeof stdout !== 'string' || (!stdout.trim() && !gitRef)) { + if (!gitRef && (err || typeof stdout !== 'string' || !stdout.trim())) { throw new Error('Unable to get current branch', err) } const branch = typeof gitRef === 'string' && gitRef.trim() @@ -14,35 +14,27 @@ exec('git branch --show-current', async (err, stdout) => { : stdout.trim() exec('git rev-parse HEAD', async (err2, stdout2) => { - try { - const gitSha = fs.readFileSync('.gitsha', 'utf8') + const gitSha = fs.readFileSync('.gitsha', 'utf8') - if (err2 || typeof stdout2 !== 'string' || (!stdout2.trim() && !gitSha)) { - throw new Error('Unable to get current sha', err) - } - const sha = typeof gitSha === 'string' && gitSha.trim() - ? gitSha.trim() - : stdout2.trim() + if (!gitSha && (err2 || typeof stdout2 !== 'string' || !stdout2.trim())) { + throw new Error('Unable to get current sha', err) + } + const sha = typeof gitSha === 'string' && gitSha.trim() + ? gitSha.trim() + : stdout2.trim() - exec(`git ls-remote https://github.com/WatWowMap/ReactMap/ refs/heads/${branch}`, (err3, stdout3) => { - try { - if (err3 || typeof stdout3 !== 'string' || !stdout3?.split('\t')?.[0]) { - throw new Error('Unable to get remote sha', err3) - } - const remoteSha = stdout3.split('\t')[0] + exec(`git ls-remote https://github.com/WatWowMap/ReactMap/ refs/heads/${branch}`, (err3, stdout3) => { + if (err3 || typeof stdout3 !== 'string' || !stdout3?.split('\t')?.[0]) { + throw new Error('Unable to get remote sha', err3) + } + const remoteSha = stdout3.split('\t')[0] - if (remoteSha !== sha) { - console.log('There is a new version available:', remoteSha) - } - } catch (e) { - console.error(e.message) - } - }) - } catch (e) { - console.error(e.message) - } + if (remoteSha !== sha) { + console.log('There is a new version available:', remoteSha) + } + }) }) - } catch (e) { - console.error(e.message) - } -}) + }) +} catch (e) { + console.log(e.message) +} From 0b34466778082338c567c0e3096c68feeba428af Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 21 Jan 2022 01:22:34 -0500 Subject: [PATCH 11/14] Add logging to ohbem init --- server/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/index.js b/server/src/index.js index 5cba78303..6fe7f1b77 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -150,7 +150,7 @@ app.use((err, req, res, next) => { }) if (config.api.pvp.reactMapHandlesPvp) { - (async () => Pokemon.initOhbem())() + Pokemon.initOhbem().then(() => console.log('Ohbem initialized')) } app.listen(config.port, config.interface, () => { From 514483595eff8e5da6f81d9bf9daa12bd4ff26a5 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 21 Jan 2022 01:31:40 -0500 Subject: [PATCH 12/14] Bug Fixes - Cleanup Session Init to reduce unnecessary error reporting - Poracle Profile Management Check --- server/src/routes/rootRouter.js | 2 +- src/components/layout/dialogs/webhooks/ProfileEditing.jsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/routes/rootRouter.js b/server/src/routes/rootRouter.js index 909e035c3..f463bd550 100644 --- a/server/src/routes/rootRouter.js +++ b/server/src/routes/rootRouter.js @@ -224,7 +224,7 @@ rootRouter.get('/settings', async (req, res) => { const filtered = config.webhooks.filter(webhook => serverSettings.user.perms.webhooks.includes(webhook.name)) try { await Promise.all(filtered.map(async webhook => { - if (config.webhookObj[webhook.name].client.valid) { + if (webhook.enabled && config.webhookObj?.[webhook.name]?.client?.valid) { const { strategy, webhookStrategy, discordId, telegramId } = serverSettings.user const webhookId = (() => { switch (strategy) { diff --git a/src/components/layout/dialogs/webhooks/ProfileEditing.jsx b/src/components/layout/dialogs/webhooks/ProfileEditing.jsx index bf33931f2..8fe1c53ba 100644 --- a/src/components/layout/dialogs/webhooks/ProfileEditing.jsx +++ b/src/components/layout/dialogs/webhooks/ProfileEditing.jsx @@ -13,7 +13,7 @@ import Query from '@services/Query' import Header from '@components/layout/general/Header' import Footer from '@components/layout/general/Footer' -const profilesObject = (data) => Object.fromEntries(data.map(profile => { +const profilesObject = (data) => data ? Object.fromEntries(data.map(profile => { const newProfile = { ...profile, active_hours: [] } const parsed = Array.isArray(profile.active_hours) ? profile.active_hours @@ -25,7 +25,7 @@ const profilesObject = (data) => Object.fromEntries(data.map(profile => { }) } return [profile.name, newProfile] -})) +})) : {} export default function ProfileEditing({ webhookData, setWebhookData, selectedWebhook, handleClose, isMobile, From f6fbc2cb0188526712efe26a6a4f29f503daaf9b Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 21 Jan 2022 17:48:38 -0500 Subject: [PATCH 13/14] Possible docker fix --- server/src/services/checkForUpdates.js | 58 ++++++++++++++++---------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/server/src/services/checkForUpdates.js b/server/src/services/checkForUpdates.js index 04edff31a..3cb701fb3 100644 --- a/server/src/services/checkForUpdates.js +++ b/server/src/services/checkForUpdates.js @@ -4,36 +4,48 @@ const fs = require('fs') try { exec('git branch --show-current', async (err, stdout) => { - const gitRef = fs.readFileSync('.gitref', 'utf8') + try { + const gitRef = fs.readFileSync('.gitref', 'utf8') - if (!gitRef && (err || typeof stdout !== 'string' || !stdout.trim())) { - throw new Error('Unable to get current branch', err) - } - const branch = typeof gitRef === 'string' && gitRef.trim() - ? gitRef.trim() - : stdout.trim() + if (!gitRef && (err || typeof stdout !== 'string' || !stdout.trim())) { + throw new Error('Unable to get current branch', err) + } + const branch = typeof gitRef === 'string' && gitRef.trim() + ? gitRef.split('/')[2].trim() + : stdout.trim() - exec('git rev-parse HEAD', async (err2, stdout2) => { - const gitSha = fs.readFileSync('.gitsha', 'utf8') + exec('git rev-parse HEAD', async (err2, stdout2) => { + try { + const gitSha = fs.readFileSync('.gitsha', 'utf8') - if (!gitSha && (err2 || typeof stdout2 !== 'string' || !stdout2.trim())) { - throw new Error('Unable to get current sha', err) - } - const sha = typeof gitSha === 'string' && gitSha.trim() - ? gitSha.trim() - : stdout2.trim() + if (!gitSha && (err2 || typeof stdout2 !== 'string' || !stdout2.trim())) { + throw new Error('Unable to get current sha', err) + } + const sha = typeof gitSha === 'string' && gitSha.trim() + ? gitSha.trim() + : stdout2.trim() - exec(`git ls-remote https://github.com/WatWowMap/ReactMap/ refs/heads/${branch}`, (err3, stdout3) => { - if (err3 || typeof stdout3 !== 'string' || !stdout3?.split('\t')?.[0]) { - throw new Error('Unable to get remote sha', err3) - } - const remoteSha = stdout3.split('\t')[0] + exec(`git ls-remote https://github.com/WatWowMap/ReactMap/ refs/heads/${branch}`, (err3, stdout3) => { + try { + if (err3 || typeof stdout3 !== 'string' || !stdout3?.split('\t')?.[0]) { + throw new Error('Unable to get remote sha', err3) + } + const remoteSha = stdout3.split('\t')[0] - if (remoteSha !== sha) { - console.log('There is a new version available:', remoteSha) + if (remoteSha !== sha) { + console.log('There is a new version available:', remoteSha) + } + } catch (e) { + console.warn('Unable to get remote SHA', e.message, 'Branch:', branch, 'Local SHA:', sha) + } + }) + } catch (e) { + console.warn('Unable to get current SHA', e.message, 'Branch:', branch) } }) - }) + } catch (e) { + console.warn('Unable to get current branch', e.message) + } }) } catch (e) { console.log(e.message) From 1fb2795e0ae729ab0f7aadc0013249e6ceff9b18 Mon Sep 17 00:00:00 2001 From: TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com> Date: Fri, 21 Jan 2022 19:01:45 -0500 Subject: [PATCH 14/14] Update docker-compose.example.yml --- docker-compose.example.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.example.yml b/docker-compose.example.yml index feebd444a..e9f9dfad4 100644 --- a/docker-compose.example.yml +++ b/docker-compose.example.yml @@ -3,11 +3,11 @@ services: reactmap: image: ghcr.io/watwowmap/reactmap:main container_name: reactmap - command: sh -c "yarn migrate:latest && yarn start" + command: sh -c "yarn start" restart: unless-stopped volumes: - ./server/src/configs/areas.json:/home/node/server/src/configs/areas.json - - ./server/src/configs/local.json:/home/node/server/src/local/config.json + - ./server/src/configs/local.json:/home/node/server/src/configs/local.json - ./example.env:/home/node/.env ports: - "9090:8080"