From 9f31d8ef9cf73dacfaa812165cc905737236668b Mon Sep 17 00:00:00 2001 From: hatim boufnichel Date: Wed, 21 Apr 2021 22:35:38 +0200 Subject: [PATCH] less chatter, pub check --- services/gunDB/contact-api/utils/index.js | 18 ++++++++++++------ src/routes.js | 7 +++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/services/gunDB/contact-api/utils/index.js b/services/gunDB/contact-api/utils/index.js index 3af89742..530588e8 100644 --- a/services/gunDB/contact-api/utils/index.js +++ b/services/gunDB/contact-api/utils/index.js @@ -120,8 +120,9 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => { if (shouldRetry(resolvedValue)) { logger.info( - 'force retrying' + + 'force retrying' /* + ` args: ${promGen.toString()} -- ${shouldRetry.toString()} \n resolvedValue: ${resolvedValue}, type: ${typeof resolvedValue}` + */ ) } else { return resolvedValue @@ -135,8 +136,9 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => { } logger.info( - `\n retrying \n` + + `\n retrying \n` /* + ` args: ${promGen.toString()} -- ${shouldRetry.toString()}` + */ ) await delay(200) @@ -151,8 +153,9 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => { if (shouldRetry(resolvedValue)) { logger.info( - 'force retrying' + + 'force retrying' /* + ` args: ${promGen.toString()} -- ${shouldRetry.toString()} \n resolvedValue: ${resolvedValue}, type: ${typeof resolvedValue}` + */ ) } else { return resolvedValue @@ -165,8 +168,9 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => { } logger.info( - `\n retrying \n` + + `\n retrying \n` /* + ` args: ${promGen.toString()} -- ${shouldRetry.toString()}` + */ ) await delay(3000) @@ -181,8 +185,9 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => { if (shouldRetry(resolvedValue)) { logger.info( - 'force retrying' + + 'force retrying' /* + ` args: ${promGen.toString()} -- ${shouldRetry.toString()} \n resolvedValue: ${resolvedValue}, type: ${typeof resolvedValue}` + */ ) } else { return resolvedValue @@ -195,8 +200,9 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => { } logger.info( - `\n NOT recreating a fresh gun but retrying one last time \n` + + `\n NOT recreating a fresh gun but retrying one last time \n` /* + ` args: ${promGen.toString()} -- ${shouldRetry.toString()}` + */ ) const { gun, user } = require('../../Mediator/index').freshGun() diff --git a/src/routes.js b/src/routes.js index 0b50fd65..11c9831a 100644 --- a/src/routes.js +++ b/src/routes.js @@ -3160,6 +3160,13 @@ module.exports = async ( const publicKeyForDecryption = req.header(PUBKEY_FOR_DECRYPT_HEADER) const { path, publicKey, type } = req.params + if (!publicKey || publicKey === 'undefined') { + res.status(400).json({ + errorMessage: 'Invalid publicKey specified' + }) + return + } + if (!allowedTypes.includes(type)) { res.status(400).json({ errorMessage: 'Invalid type specified'