From ea5589a8400e69704fd947a29126e10dc0ccdca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 12 Apr 2022 12:18:04 +0200 Subject: [PATCH 1/5] Add wallet link to transaction mail, first approach --- backend/src/graphql/resolver/TransactionResolver.ts | 2 ++ backend/src/mailer/sendTransactionReceivedEmail.ts | 1 + backend/src/mailer/text/transactionReceived.ts | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 8747f14a3..5b7956656 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -125,6 +125,7 @@ export const executeTransaction = async ( } // send notification email + const overviewURL = new URL('/overview' /* , XXX CONFIG.CLIENT_URI */) // http://localhost/overview // TODO: translate await sendTransactionReceivedEmail({ senderFirstName: sender.firstName, @@ -135,6 +136,7 @@ export const executeTransaction = async ( senderEmail: sender.email, amount, memo, + overviewURL: overviewURL.toString(), }) return true diff --git a/backend/src/mailer/sendTransactionReceivedEmail.ts b/backend/src/mailer/sendTransactionReceivedEmail.ts index 934783449..537c13d85 100644 --- a/backend/src/mailer/sendTransactionReceivedEmail.ts +++ b/backend/src/mailer/sendTransactionReceivedEmail.ts @@ -11,6 +11,7 @@ export const sendTransactionReceivedEmail = (data: { senderEmail: string amount: Decimal memo: string + overviewURL: string }): Promise => { return sendEMail({ to: `${data.recipientFirstName} ${data.recipientLastName} <${data.email}>`, diff --git a/backend/src/mailer/text/transactionReceived.ts b/backend/src/mailer/text/transactionReceived.ts index 520ee43bf..a976bd842 100644 --- a/backend/src/mailer/text/transactionReceived.ts +++ b/backend/src/mailer/text/transactionReceived.ts @@ -12,6 +12,7 @@ export const transactionReceived = { senderEmail: string amount: Decimal memo: string + overviewURL: string }): string => `Hallo ${data.recipientFirstName} ${data.recipientLastName} @@ -25,6 +26,9 @@ ${data.memo} Bitte antworte nicht auf diese E-Mail! Mit freundlichen Grüßen, -dein Gradido-Team`, +dein Gradido-Team + + +Link zur Übersicht: Deine Übersicht`, }, } From 563afcbf2a72d8bd8e13ef864db23babe4666563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 12 Apr 2022 15:36:05 +0200 Subject: [PATCH 2/5] Add EMAIL_CLIENT_URI in config - Increment config version. - Correct usage of EMAIL_CLIENT_URI. --- backend/.env.dist | 3 ++- backend/.env.template | 1 + backend/src/config/index.ts | 3 ++- backend/src/graphql/resolver/TransactionResolver.ts | 4 +++- deployment/bare_metal/.env.dist | 3 ++- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/backend/.env.dist b/backend/.env.dist index 033417025..a820780ab 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -1,4 +1,4 @@ -CONFIG_VERSION=v4.2022-04-05 +CONFIG_VERSION=v5.2022-04-12 # Server PORT=4000 @@ -45,6 +45,7 @@ EMAIL_LINK_SETPASSWORD=http://localhost/reset-password/{optin} EMAIL_LINK_FORGOTPASSWORD=http://localhost/forgot-password EMAIL_CODE_VALID_TIME=1440 EMAIL_CODE_REQUEST_TIME=10 +EMAIL_CLIENT_URI=http://localhost # Webhook WEBHOOK_ELOPAGE_SECRET=secret \ No newline at end of file diff --git a/backend/.env.template b/backend/.env.template index 011e413df..d66217ebf 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -43,6 +43,7 @@ EMAIL_LINK_VERIFICATION=$EMAIL_LINK_VERIFICATION EMAIL_LINK_SETPASSWORD=$EMAIL_LINK_SETPASSWORD EMAIL_CODE_VALID_TIME=$EMAIL_CODE_VALID_TIME EMAIL_CODE_REQUEST_TIME=$EMAIL_CODE_REQUEST_TIME +EMAIL_CLIENT_URI=$EMAIL_CLIENT_URI # Webhook WEBHOOK_ELOPAGE_SECRET=$WEBHOOK_ELOPAGE_SECRET \ No newline at end of file diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index fe9b40ccc..c69f9c92a 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -14,7 +14,7 @@ const constants = { DECAY_START_TIME: new Date('2021-05-13 17:46:31'), // GMT+0 CONFIG_VERSION: { DEFAULT: 'DEFAULT', - EXPECTED: 'v4.2022-04-05', + EXPECTED: 'v5.2022-04-12', CURRENT: '', }, } @@ -80,6 +80,7 @@ const email = { EMAIL_CODE_REQUEST_TIME: process.env.EMAIL_CODE_REQUEST_TIME ? parseInt(process.env.EMAIL_CODE_REQUEST_TIME) || 10 : 10, + EMAIL_CLIENT_URI: process.env.EMAIL_CLIENT_URI || 'http://localhost', } const webhook = { diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 5b7956656..00caba002 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -3,6 +3,8 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/no-non-null-assertion */ +import CONFIG from '@/config' + import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' import { getCustomRepository, getConnection } from '@dbTools/typeorm' @@ -125,7 +127,7 @@ export const executeTransaction = async ( } // send notification email - const overviewURL = new URL('/overview' /* , XXX CONFIG.CLIENT_URI */) // http://localhost/overview + const overviewURL = new URL('/overview', CONFIG.EMAIL_CLIENT_URI) // TODO: translate await sendTransactionReceivedEmail({ senderFirstName: sender.firstName, diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 8254fd9c2..1b287fe47 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -18,7 +18,7 @@ WEBHOOK_GITHUB_SECRET=secret WEBHOOK_GITHUB_BRANCH=master # backend -BACKEND_CONFIG_VERSION=v4.2022-04-05 +BACKEND_CONFIG_VERSION=v5.2022-04-12 JWT_EXPIRES_IN=30m GDT_API_URL=https://gdt.gradido.net @@ -46,6 +46,7 @@ EMAIL_LINK_SETPASSWORD=https://stage1.gradido.net/reset-password/{optin} EMAIL_LINK_FORGOTPASSWORD=https://stage1.gradido.net/forgot-password EMAIL_CODE_VALID_TIME=1440 EMAIL_CODE_REQUEST_TIME=10 +EMAIL_CLIENT_URI=https://stage1.gradido.net WEBHOOK_ELOPAGE_SECRET=secret From ad0f3a8be4cb20d0ebfa55dcfcd1c7b6cc8b636f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 13 Apr 2022 10:36:39 +0200 Subject: [PATCH 3/5] Add test for existence of e-mail link to overview page --- backend/src/mailer/sendTransactionReceivedEmail.test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/mailer/sendTransactionReceivedEmail.test.ts b/backend/src/mailer/sendTransactionReceivedEmail.test.ts index 1ebc9dae3..d933e53d3 100644 --- a/backend/src/mailer/sendTransactionReceivedEmail.test.ts +++ b/backend/src/mailer/sendTransactionReceivedEmail.test.ts @@ -20,6 +20,7 @@ describe('sendTransactionReceivedEmail', () => { senderEmail: 'bibi@bloxberg.de', amount: new Decimal(42.0), memo: 'Vielen herzlichen Dank für den neuen Hexenbesen!', + overviewURL: 'http://localhost/overview', }) }) @@ -32,7 +33,8 @@ describe('sendTransactionReceivedEmail', () => { expect.stringContaining('42,00 GDD') && expect.stringContaining('Bibi Bloxberg') && expect.stringContaining('(bibi@bloxberg.de)') && - expect.stringContaining('Vielen herzlichen Dank für den neuen Hexenbesen!'), + expect.stringContaining('Vielen herzlichen Dank für den neuen Hexenbesen!') && + expect.stringContaining(''), }) }) }) From 8205e88b2fc974ac514f29c279438735bd38e7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 14 Apr 2022 14:19:40 +0200 Subject: [PATCH 4/5] Comply Ulf's suggestions --- backend/.env.dist | 2 +- backend/.env.template | 2 +- backend/src/config/index.ts | 2 +- backend/src/graphql/resolver/TransactionResolver.ts | 3 +-- backend/src/mailer/sendTransactionReceivedEmail.test.ts | 2 +- backend/src/mailer/text/transactionReceived.ts | 2 +- deployment/bare_metal/.env.dist | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/backend/.env.dist b/backend/.env.dist index a820780ab..b0a08753c 100644 --- a/backend/.env.dist +++ b/backend/.env.dist @@ -43,9 +43,9 @@ EMAIL_SMTP_PORT=587 EMAIL_LINK_VERIFICATION=http://localhost/checkEmail/{optin}{code} EMAIL_LINK_SETPASSWORD=http://localhost/reset-password/{optin} EMAIL_LINK_FORGOTPASSWORD=http://localhost/forgot-password +EMAIL_LINK_OVERVIEW=http://localhost/overview EMAIL_CODE_VALID_TIME=1440 EMAIL_CODE_REQUEST_TIME=10 -EMAIL_CLIENT_URI=http://localhost # Webhook WEBHOOK_ELOPAGE_SECRET=secret \ No newline at end of file diff --git a/backend/.env.template b/backend/.env.template index d66217ebf..5da108f53 100644 --- a/backend/.env.template +++ b/backend/.env.template @@ -41,9 +41,9 @@ EMAIL_SMTP_URL=$EMAIL_SMTP_URL EMAIL_SMTP_PORT=587 EMAIL_LINK_VERIFICATION=$EMAIL_LINK_VERIFICATION EMAIL_LINK_SETPASSWORD=$EMAIL_LINK_SETPASSWORD +EMAIL_LINK_OVERVIEW=$EMAIL_LINK_OVERVIEW EMAIL_CODE_VALID_TIME=$EMAIL_CODE_VALID_TIME EMAIL_CODE_REQUEST_TIME=$EMAIL_CODE_REQUEST_TIME -EMAIL_CLIENT_URI=$EMAIL_CLIENT_URI # Webhook WEBHOOK_ELOPAGE_SECRET=$WEBHOOK_ELOPAGE_SECRET \ No newline at end of file diff --git a/backend/src/config/index.ts b/backend/src/config/index.ts index c69f9c92a..91f450369 100644 --- a/backend/src/config/index.ts +++ b/backend/src/config/index.ts @@ -72,6 +72,7 @@ const email = { process.env.EMAIL_LINK_SETPASSWORD || 'http://localhost/reset-password/{optin}', EMAIL_LINK_FORGOTPASSWORD: process.env.EMAIL_LINK_FORGOTPASSWORD || 'http://localhost/forgot-password', + EMAIL_LINK_OVERVIEW: process.env.EMAIL_LINK_OVERVIEW || 'http://localhost/overview', // time in minutes a optin code is valid EMAIL_CODE_VALID_TIME: process.env.EMAIL_CODE_VALID_TIME ? parseInt(process.env.EMAIL_CODE_VALID_TIME) || 1440 @@ -80,7 +81,6 @@ const email = { EMAIL_CODE_REQUEST_TIME: process.env.EMAIL_CODE_REQUEST_TIME ? parseInt(process.env.EMAIL_CODE_REQUEST_TIME) || 10 : 10, - EMAIL_CLIENT_URI: process.env.EMAIL_CLIENT_URI || 'http://localhost', } const webhook = { diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 2d54e8167..69e1899d9 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -126,7 +126,6 @@ export const executeTransaction = async ( } // send notification email - const overviewURL = new URL('/overview', CONFIG.EMAIL_CLIENT_URI) // TODO: translate await sendTransactionReceivedEmail({ senderFirstName: sender.firstName, @@ -137,7 +136,7 @@ export const executeTransaction = async ( senderEmail: sender.email, amount, memo, - overviewURL: overviewURL.toString(), + overviewURL: CONFIG.EMAIL_LINK_OVERVIEW, }) return true diff --git a/backend/src/mailer/sendTransactionReceivedEmail.test.ts b/backend/src/mailer/sendTransactionReceivedEmail.test.ts index d933e53d3..75631cc7a 100644 --- a/backend/src/mailer/sendTransactionReceivedEmail.test.ts +++ b/backend/src/mailer/sendTransactionReceivedEmail.test.ts @@ -34,7 +34,7 @@ describe('sendTransactionReceivedEmail', () => { expect.stringContaining('Bibi Bloxberg') && expect.stringContaining('(bibi@bloxberg.de)') && expect.stringContaining('Vielen herzlichen Dank für den neuen Hexenbesen!') && - expect.stringContaining(''), + expect.stringContaining('http://localhost/overview'), }) }) }) diff --git a/backend/src/mailer/text/transactionReceived.ts b/backend/src/mailer/text/transactionReceived.ts index a976bd842..c56a923b4 100644 --- a/backend/src/mailer/text/transactionReceived.ts +++ b/backend/src/mailer/text/transactionReceived.ts @@ -29,6 +29,6 @@ Mit freundlichen Grüßen, dein Gradido-Team -Link zur Übersicht: Deine Übersicht`, +Link zu deiner Übersicht: ${data.overviewURL}`, }, } diff --git a/deployment/bare_metal/.env.dist b/deployment/bare_metal/.env.dist index 1b287fe47..4c6e956af 100644 --- a/deployment/bare_metal/.env.dist +++ b/deployment/bare_metal/.env.dist @@ -44,9 +44,9 @@ EMAIL_SMTP_URL=smtp.lustig.de EMAIL_LINK_VERIFICATION=https://stage1.gradido.net/checkEmail/{optin}{code} EMAIL_LINK_SETPASSWORD=https://stage1.gradido.net/reset-password/{optin} EMAIL_LINK_FORGOTPASSWORD=https://stage1.gradido.net/forgot-password +EMAIL_LINK_OVERVIEW=https://stage1.gradido.net/overview EMAIL_CODE_VALID_TIME=1440 EMAIL_CODE_REQUEST_TIME=10 -EMAIL_CLIENT_URI=https://stage1.gradido.net WEBHOOK_ELOPAGE_SECRET=secret From d0215f2885ae2f4c0b4a57fb1b0d370a1828b1b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 19 Apr 2022 10:03:56 +0200 Subject: [PATCH 5/5] Update backend/src/mailer/text/transactionReceived.ts - Follow Ulf's suggestion. Co-authored-by: Ulf Gebhardt --- backend/src/mailer/text/transactionReceived.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/mailer/text/transactionReceived.ts b/backend/src/mailer/text/transactionReceived.ts index c56a923b4..07d03ad45 100644 --- a/backend/src/mailer/text/transactionReceived.ts +++ b/backend/src/mailer/text/transactionReceived.ts @@ -29,6 +29,6 @@ Mit freundlichen Grüßen, dein Gradido-Team -Link zu deiner Übersicht: ${data.overviewURL}`, +Link zu deinem Konto: ${data.overviewURL}`, }, }