diff --git a/server/data/chatter.js b/server/data/chatter.js index e610f9791..5c9ce9ddc 100644 --- a/server/data/chatter.js +++ b/server/data/chatter.js @@ -135,17 +135,17 @@ exports.default = async (req, res) => { logger.log("chatter-sftp-error", "ERROR", "api", null, { ...error }); } finally { sftp.end(); + sendServerEmail({ + subject: `Chatter Report ${moment().format("MM-DD-YY")}`, + text: `Errors: ${allErrors.map((e) => JSON.stringify(e, null, 2))} + Uploaded: ${JSON.stringify( + allcsvsToUpload.map((x) => ({ filename: x.filename, count: x.count })), + null, + 2 + )}` + }); + res.sendStatus(200); } - sendServerEmail({ - subject: `Chatter Report ${moment().format("MM-DD-YY")}`, - text: `Errors: ${allErrors.map((e) => JSON.stringify(e, null, 2))} - Uploaded: ${JSON.stringify( - allcsvsToUpload.map((x) => ({ filename: x.filename, count: x.count })), - null, - 2 - )}` - }); - res.sendStatus(200); } catch (error) { res.status(200).json(error); } @@ -160,8 +160,8 @@ async function getPrivateKey() { try { const { SecretString, SecretBinary } = await client.send(command); if (SecretString || SecretBinary) logger.log("chatter-retrieved-private-key", "DEBUG", "api", null, null); - const chatterPrivateKey = SecretString ? JSON.parse(SecretString) : JSON.parse(Buffer.from(SecretBinary, "base64").toString("ascii")); - return chatterPrivateKey.private_key; + const chatterPrivateKey = SecretString ? SecretString : Buffer.from(SecretBinary, "base64").toString("ascii"); + return chatterPrivateKey; } catch (error) { logger.log("chatter-get-private-key", "ERROR", "api", null, error); throw err;