From a622fe02cd146df4368dedc46dd124e6f9467269 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Thu, 7 Oct 2021 13:24:47 +0200 Subject: [PATCH] linting --- backend/src/config/index.ts | 2 +- .../graphql/resolver/TransactionResolver.ts | 53 ++++++++++++------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index f8e0bd3e9..c38db54d0 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -50,6 +50,6 @@ const email = { // This is needed by graphql-directive-auth process.env.APP_SECRET = server.JWT_SECRET -const CONFIG = { ...server, ...database, ...klicktipp, ...community } +const CONFIG = { ...server, ...database, ...klicktipp, ...community, ...email } export default CONFIG diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index d0cd86ed0..063ad69d7 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -368,8 +368,9 @@ async function sendCoins( transactionRepository.save(transaction).catch(() => { throw new Error('error saving transaction') }) - console.log('transaction after saving: %o', transaction) - + // eslint-disable-next-line no-console + console.log('transaction after saving: %o', transaction) + if (!recipiantUser) { throw new Error('Cannot find recipiant user by local send coins transaction') } @@ -439,32 +440,48 @@ async function sendCoins( }) }) // send notification email - if(CONFIG.EMAIL) { - let transporter = createTransport({ + if (CONFIG.EMAIL) { + const transporter = createTransport({ host: CONFIG.EMAIL_SMTP_URL, port: Number(CONFIG.EMAIL_SMTP_PORT), secure: false, // true for 465, false for other ports requireTLS: true, auth: { user: CONFIG.EMAIL_USERNAME, - pass: CONFIG.EMAIL_PASSWORD, + pass: CONFIG.EMAIL_PASSWORD, }, - }); - + }) + // send mail with defined transport object // TODO: translate - let info = await transporter.sendMail({ + const info = await transporter.sendMail({ from: 'Gradido (nicht antworten) <' + CONFIG.EMAIL_SENDER + '>', // sender address - to: recipiantUser.firstName + ' ' + recipiantUser.lastName + ' <' + recipiantUser.email + '>', // list of receivers - subject: 'Gradido Überweisung', // Subject line - text: 'Hallo ' + recipiantUser.firstName + ' ' + recipiantUser.lastName + ',\n\n' - + 'Du hast soeben ' + amount + ' GDD von ' + senderUser.firstName + ' ' + senderUser.lastName + ' erhalten.\n' - + senderUser.firstName + ' ' + senderUser.lastName + ' schreibt: \n\n' - + memo + '\n\n' - + 'Bitte antworte nicht auf diese E-Mail!\n\n' - + 'Mit freundlichen Grüßen\ņ Gradido Community Server', // plain text body - }); - if(!info.messageId) { + to: + recipiantUser.firstName + ' ' + recipiantUser.lastName + ' <' + recipiantUser.email + '>', // list of receivers + subject: 'Gradido Überweisung', // Subject line + text: + 'Hallo ' + + recipiantUser.firstName + + ' ' + + recipiantUser.lastName + + ',\n\n' + + 'Du hast soeben ' + + amount + + ' GDD von ' + + senderUser.firstName + + ' ' + + senderUser.lastName + + ' erhalten.\n' + + senderUser.firstName + + ' ' + + senderUser.lastName + + ' schreibt: \n\n' + + memo + + '\n\n' + + 'Bitte antworte nicht auf diese E-Mail!\n\n' + + 'Mit freundlichen Grüßenņ Gradido Community Server', // plain text body + }) + if (!info.messageId) { throw new Error('error sending notification email, but transaction succeed') } }