diff --git a/CHANGELOG.md b/CHANGELOG.md index 352286e45..46a704739 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). +#### [1.12.1](https://github.com/gradido/gradido/compare/1.12.0...1.12.1) + +- fix: 🍰 Show Not Icons In `allContribution` List [`#2195`](https://github.com/gradido/gradido/pull/2195) + #### [1.12.0](https://github.com/gradido/gradido/compare/1.11.0...1.12.0) +> 12 September 2022 + +- release: v1.12.0 [`#2191`](https://github.com/gradido/gradido/pull/2191) - if message empty else disabled button [`#2189`](https://github.com/gradido/gradido/pull/2189) - messages show if Confirmed [`#2185`](https://github.com/gradido/gradido/pull/2185) - text in messages smaller [`#2186`](https://github.com/gradido/gradido/pull/2186) diff --git a/admin/package.json b/admin/package.json index f31b43bbd..f56ae0a87 100644 --- a/admin/package.json +++ b/admin/package.json @@ -3,7 +3,7 @@ "description": "Administraion Interface for Gradido", "main": "index.js", "author": "Moriz Wahl", - "version": "1.12.0", + "version": "1.12.1", "license": "Apache-2.0", "private": false, "scripts": { diff --git a/backend/package.json b/backend/package.json index b826183b6..2a054314f 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "gradido-backend", - "version": "1.12.0", + "version": "1.12.1", "description": "Gradido unified backend providing an API-Service for Gradido Transactions", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/backend", diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 9de1a7116..27e3c6385 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -40,6 +40,7 @@ import Decimal from 'decimal.js-light' import { Contribution } from '@entity/Contribution' import { Transaction as DbTransaction } from '@entity/Transaction' import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import { sendContributionConfirmedEmail } from '@/mailer/sendContributionConfirmedEmail' // mock account activation email to avoid console spam jest.mock('@/mailer/sendAccountActivationEmail', () => { @@ -49,6 +50,14 @@ jest.mock('@/mailer/sendAccountActivationEmail', () => { } }) +// mock account activation email to avoid console spam +jest.mock('@/mailer/sendContributionConfirmedEmail', () => { + return { + __esModule: true, + sendContributionConfirmedEmail: jest.fn(), + } +}) + let mutate: any, query: any, con: any let testEnv: any @@ -1452,6 +1461,20 @@ describe('AdminResolver', () => { expect(transaction[0].linkedUserId).toEqual(null) expect(transaction[0].typeId).toEqual(1) }) + + it('calls sendContributionConfirmedEmail', async () => { + expect(sendContributionConfirmedEmail).toBeCalledWith( + expect.objectContaining({ + contributionMemo: 'Herzlich Willkommen bei Gradido liebe Bibi!', + overviewURL: 'http://localhost/overview', + recipientEmail: 'bibi@bloxberg.de', + recipientFirstName: 'Bibi', + recipientLastName: 'Bloxberg', + senderFirstName: 'Peter', + senderLastName: 'Lustig', + }), + ) + }) }) describe('confirm two creations one after the other quickly', () => { diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 488a39a22..7bdc4d59b 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -64,6 +64,8 @@ import { ContributionMessage as DbContributionMessage } from '@entity/Contributi import ContributionMessageArgs from '@arg/ContributionMessageArgs' import { ContributionMessageType } from '@enum/MessageType' import { ContributionMessage } from '@model/ContributionMessage' +import { sendContributionConfirmedEmail } from '@/mailer/sendContributionConfirmedEmail' +import { sendAddedContributionMessageEmail } from '@/mailer/sendAddedContributionMessageEmail' // const EMAIL_OPT_IN_REGISTER = 1 // const EMAIL_OPT_UNKNOWN = 3 // elopage? @@ -480,6 +482,16 @@ export class AdminResolver { await queryRunner.commitTransaction() logger.info('creation commited successfuly.') + sendContributionConfirmedEmail({ + senderFirstName: moderatorUser.firstName, + senderLastName: moderatorUser.lastName, + recipientFirstName: user.firstName, + recipientLastName: user.lastName, + recipientEmail: user.email, + contributionMemo: contribution.memo, + contributionAmount: contribution.amount, + overviewURL: CONFIG.EMAIL_LINK_OVERVIEW, + }) } catch (e) { await queryRunner.rollbackTransaction() logger.error(`Creation was not successful: ${e}`) @@ -726,7 +738,10 @@ export class AdminResolver { await queryRunner.startTransaction('READ UNCOMMITTED') const contributionMessage = DbContributionMessage.create() try { - const contribution = await Contribution.findOne({ id: contributionId }) + const contribution = await Contribution.findOne({ + where: { id: contributionId }, + relations: ['user'], + }) if (!contribution) { throw new Error('Contribution not found') } @@ -750,6 +765,18 @@ export class AdminResolver { await queryRunner.manager.update(Contribution, { id: contributionId }, contribution) } await queryRunner.commitTransaction() + + await sendAddedContributionMessageEmail({ + senderFirstName: user.firstName, + senderLastName: user.lastName, + recipientFirstName: contribution.user.firstName, + recipientLastName: contribution.user.lastName, + recipientEmail: contribution.user.email, + senderEmail: user.email, + contributionMemo: contribution.memo, + message, + overviewURL: CONFIG.EMAIL_LINK_OVERVIEW, + }) } catch (e) { await queryRunner.rollbackTransaction() logger.error(`ContributionMessage was not successful: ${e}`) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index c0e330750..40e9e2ace 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -12,6 +12,14 @@ import { listContributionMessages, login } from '@/seeds/graphql/queries' import { userFactory } from '@/seeds/factory/user' import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' import { peterLustig } from '@/seeds/users/peter-lustig' +import { sendAddedContributionMessageEmail } from '@/mailer/sendAddedContributionMessageEmail' + +jest.mock('@/mailer/sendAddedContributionMessageEmail', () => { + return { + __esModule: true, + sendAddedContributionMessageEmail: jest.fn(), + } +}) let mutate: any, query: any, con: any let testEnv: any @@ -151,6 +159,20 @@ describe('ContributionMessageResolver', () => { }), ) }) + + it('calls sendAddedContributionMessageEmail', async () => { + expect(sendAddedContributionMessageEmail).toBeCalledWith({ + senderFirstName: 'Peter', + senderLastName: 'Lustig', + recipientFirstName: 'Bibi', + recipientLastName: 'Bloxberg', + recipientEmail: 'bibi@bloxberg.de', + senderEmail: 'peter@lustig.de', + contributionMemo: 'Test env contribution', + message: 'Admin Test', + overviewURL: 'http://localhost/overview', + }) + }) }) }) }) diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 3cd871fc3..4b46804f1 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -8,7 +8,10 @@ import { Context, getUser } from '@/server/context' import { Resolver, Query, Args, Authorized, Ctx, Mutation } from 'type-graphql' import { getCustomRepository, getConnection } from '@dbTools/typeorm' -import { sendTransactionReceivedEmail } from '@/mailer/sendTransactionReceivedEmail' +import { + sendTransactionLinkRedeemedEmail, + sendTransactionReceivedEmail, +} from '@/mailer/sendTransactionReceivedEmail' import { Transaction } from '@model/Transaction' import { TransactionList } from '@model/TransactionList' @@ -156,6 +159,19 @@ export const executeTransaction = async ( memo, overviewURL: CONFIG.EMAIL_LINK_OVERVIEW, }) + if (transactionLink) { + await sendTransactionLinkRedeemedEmail({ + senderFirstName: recipient.firstName, + senderLastName: recipient.lastName, + recipientFirstName: sender.firstName, + recipientLastName: sender.lastName, + email: sender.email, + senderEmail: recipient.email, + amount, + memo, + overviewURL: CONFIG.EMAIL_LINK_OVERVIEW, + }) + } logger.info(`finished executeTransaction successfully`) return true } diff --git a/backend/src/mailer/sendAddedContributionMessageEmail.test.ts b/backend/src/mailer/sendAddedContributionMessageEmail.test.ts new file mode 100644 index 000000000..1151a0abc --- /dev/null +++ b/backend/src/mailer/sendAddedContributionMessageEmail.test.ts @@ -0,0 +1,40 @@ +import { sendAddedContributionMessageEmail } from './sendAddedContributionMessageEmail' +import { sendEMail } from './sendEMail' + +jest.mock('./sendEMail', () => { + return { + __esModule: true, + sendEMail: jest.fn(), + } +}) + +describe('sendAddedContributionMessageEmail', () => { + beforeEach(async () => { + await sendAddedContributionMessageEmail({ + senderFirstName: 'Peter', + senderLastName: 'Lustig', + recipientFirstName: 'Bibi', + recipientLastName: 'Bloxberg', + recipientEmail: 'bibi@bloxberg.de', + senderEmail: 'peter@lustig.de', + contributionMemo: 'Vielen herzlichen Dank für den neuen Hexenbesen!', + message: 'Was für ein Besen ist es geworden?', + overviewURL: 'http://localhost/overview', + }) + }) + + it('calls sendEMail', () => { + expect(sendEMail).toBeCalledWith({ + to: `Bibi Bloxberg `, + subject: 'Gradido Frage zur Schöpfung', + text: + expect.stringContaining('Hallo Bibi Bloxberg') && + expect.stringContaining('Peter Lustig') && + expect.stringContaining( + 'Du hast soeben zu deinem eingereichten Gradido Schöpfungsantrag "Vielen herzlichen Dank für den neuen Hexenbesen!" eine Rückfrage von Peter Lustig erhalten.', + ) && + expect.stringContaining('Was für ein Besen ist es geworden?') && + expect.stringContaining('http://localhost/overview'), + }) + }) +}) diff --git a/backend/src/mailer/sendAddedContributionMessageEmail.ts b/backend/src/mailer/sendAddedContributionMessageEmail.ts new file mode 100644 index 000000000..14d5f6d31 --- /dev/null +++ b/backend/src/mailer/sendAddedContributionMessageEmail.ts @@ -0,0 +1,26 @@ +import { backendLogger as logger } from '@/server/logger' +import { sendEMail } from './sendEMail' +import { contributionMessageReceived } from './text/contributionMessageReceived' + +export const sendAddedContributionMessageEmail = (data: { + senderFirstName: string + senderLastName: string + recipientFirstName: string + recipientLastName: string + recipientEmail: string + senderEmail: string + contributionMemo: string + message: string + overviewURL: string +}): Promise => { + logger.info( + `sendEmail(): to=${data.recipientFirstName} ${data.recipientLastName} <${data.recipientEmail}>, + subject=${contributionMessageReceived.de.subject}, + text=${contributionMessageReceived.de.text(data)}`, + ) + return sendEMail({ + to: `${data.recipientFirstName} ${data.recipientLastName} <${data.recipientEmail}>`, + subject: contributionMessageReceived.de.subject, + text: contributionMessageReceived.de.text(data), + }) +} diff --git a/backend/src/mailer/sendContributionConfirmedEmail.test.ts b/backend/src/mailer/sendContributionConfirmedEmail.test.ts new file mode 100644 index 000000000..1935144fd --- /dev/null +++ b/backend/src/mailer/sendContributionConfirmedEmail.test.ts @@ -0,0 +1,39 @@ +import Decimal from 'decimal.js-light' +import { sendContributionConfirmedEmail } from './sendContributionConfirmedEmail' +import { sendEMail } from './sendEMail' + +jest.mock('./sendEMail', () => { + return { + __esModule: true, + sendEMail: jest.fn(), + } +}) + +describe('sendContributionConfirmedEmail', () => { + beforeEach(async () => { + await sendContributionConfirmedEmail({ + senderFirstName: 'Peter', + senderLastName: 'Lustig', + recipientFirstName: 'Bibi', + recipientLastName: 'Bloxberg', + recipientEmail: 'bibi@bloxberg.de', + contributionMemo: 'Vielen herzlichen Dank für den neuen Hexenbesen!', + contributionAmount: new Decimal(200.0), + overviewURL: 'http://localhost/overview', + }) + }) + + it('calls sendEMail', () => { + expect(sendEMail).toBeCalledWith({ + to: 'Bibi Bloxberg ', + subject: 'Schöpfung wurde bestätigt', + text: + expect.stringContaining('Hallo Bibi Bloxberg') && + expect.stringContaining( + 'Dein Gradido Schöpfungsantrag "Vielen herzlichen Dank für den neuen Hexenbesen!" wurde soeben bestätigt.', + ) && + expect.stringContaining('Betrag: 200,00 GDD') && + expect.stringContaining('Link zu deinem Konto: http://localhost/overview'), + }) + }) +}) diff --git a/backend/src/mailer/sendContributionConfirmedEmail.ts b/backend/src/mailer/sendContributionConfirmedEmail.ts new file mode 100644 index 000000000..439d240eb --- /dev/null +++ b/backend/src/mailer/sendContributionConfirmedEmail.ts @@ -0,0 +1,26 @@ +import { backendLogger as logger } from '@/server/logger' +import Decimal from 'decimal.js-light' +import { sendEMail } from './sendEMail' +import { contributionConfirmed } from './text/contributionConfirmed' + +export const sendContributionConfirmedEmail = (data: { + senderFirstName: string + senderLastName: string + recipientFirstName: string + recipientLastName: string + recipientEmail: string + contributionMemo: string + contributionAmount: Decimal + overviewURL: string +}): Promise => { + logger.info( + `sendEmail(): to=${data.recipientFirstName} ${data.recipientLastName} <${data.recipientEmail}>, + subject=${contributionConfirmed.de.subject}, + text=${contributionConfirmed.de.text(data)}`, + ) + return sendEMail({ + to: `${data.recipientFirstName} ${data.recipientLastName} <${data.recipientEmail}>`, + subject: contributionConfirmed.de.subject, + text: contributionConfirmed.de.text(data), + }) +} diff --git a/backend/src/mailer/sendTransactionReceivedEmail.ts b/backend/src/mailer/sendTransactionReceivedEmail.ts index 692f92f9a..55f63e37e 100644 --- a/backend/src/mailer/sendTransactionReceivedEmail.ts +++ b/backend/src/mailer/sendTransactionReceivedEmail.ts @@ -1,7 +1,7 @@ import { backendLogger as logger } from '@/server/logger' import Decimal from 'decimal.js-light' import { sendEMail } from './sendEMail' -import { transactionReceived } from './text/transactionReceived' +import { transactionLinkRedeemed, transactionReceived } from './text/transactionReceived' export const sendTransactionReceivedEmail = (data: { senderFirstName: string @@ -26,3 +26,27 @@ export const sendTransactionReceivedEmail = (data: { text: transactionReceived.de.text(data), }) } + +export const sendTransactionLinkRedeemedEmail = (data: { + email: string + senderFirstName: string + senderLastName: string + recipientFirstName: string + recipientLastName: string + senderEmail: string + amount: Decimal + memo: string + overviewURL: string +}): Promise => { + logger.info( + `sendEmail(): to=${data.recipientFirstName} ${data.recipientLastName}, + <${data.email}>, + subject=${transactionLinkRedeemed.de.subject}, + text=${transactionLinkRedeemed.de.text(data)}`, + ) + return sendEMail({ + to: `${data.recipientFirstName} ${data.recipientLastName} <${data.email}>`, + subject: transactionLinkRedeemed.de.subject, + text: transactionLinkRedeemed.de.text(data), + }) +} diff --git a/backend/src/mailer/text/contributionConfirmed.ts b/backend/src/mailer/text/contributionConfirmed.ts new file mode 100644 index 000000000..2d9fce6a8 --- /dev/null +++ b/backend/src/mailer/text/contributionConfirmed.ts @@ -0,0 +1,30 @@ +import Decimal from 'decimal.js-light' + +export const contributionConfirmed = { + de: { + subject: 'Schöpfung wurde bestätigt', + text: (data: { + senderFirstName: string + senderLastName: string + recipientFirstName: string + recipientLastName: string + contributionMemo: string + contributionAmount: Decimal + overviewURL: string + }): string => + `Hallo ${data.recipientFirstName} ${data.recipientLastName}, + +Dein Gradido Schöpfungsantrag "${data.contributionMemo}" wurde soeben von ${data.senderFirstName} ${ + data.senderLastName + } bestätigt. +Betrag: ${data.contributionAmount.toFixed(2).replace('.', ',')} GDD + +Bitte antworte nicht auf diese E-Mail! + +Mit freundlichen Grüßen, +dein Gradido-Team + + +Link zu deinem Konto: ${data.overviewURL}`, + }, +} diff --git a/backend/src/mailer/text/contributionMessageReceived.ts b/backend/src/mailer/text/contributionMessageReceived.ts new file mode 100644 index 000000000..4affb71a8 --- /dev/null +++ b/backend/src/mailer/text/contributionMessageReceived.ts @@ -0,0 +1,30 @@ +export const contributionMessageReceived = { + de: { + subject: 'Gradido Frage zur Schöpfung', + text: (data: { + senderFirstName: string + senderLastName: string + recipientFirstName: string + recipientLastName: string + recipientEmail: string + senderEmail: string + contributionMemo: string + message: string + overviewURL: string + }): string => + `Hallo ${data.recipientFirstName} ${data.recipientLastName}, + +Du hast soeben zu deinem eingereichten Gradido Schöpfungsantrag "${data.contributionMemo}" eine Rückfrage von ${data.senderFirstName} ${data.senderLastName} erhalten. +Die Rückfrage lautet: + +${data.message} + +Bitte antworte nicht auf diese E-Mail! + +Mit freundlichen Grüßen, +dein Gradido-Team + + +Link zu deinem Konto: ${data.overviewURL}`, + }, +} diff --git a/backend/src/mailer/text/transactionReceived.ts b/backend/src/mailer/text/transactionReceived.ts index 07d03ad45..2764d1b60 100644 --- a/backend/src/mailer/text/transactionReceived.ts +++ b/backend/src/mailer/text/transactionReceived.ts @@ -29,6 +29,37 @@ Mit freundlichen Grüßen, dein Gradido-Team +Link zu deinem Konto: ${data.overviewURL}`, + }, +} + +export const transactionLinkRedeemed = { + de: { + subject: 'Gradido link eingelösst', + text: (data: { + email: string + senderFirstName: string + senderLastName: string + recipientFirstName: string + recipientLastName: string + senderEmail: string + amount: Decimal + memo: string + overviewURL: string + }): string => + `Hallo ${data.recipientFirstName} ${data.recipientLastName} + +${data.senderFirstName} ${data.senderLastName} (${ + data.senderEmail + }) hat soeben deinen Link eingelösst. +Betrag: ${data.amount.toFixed(2).replace('.', ',')} GDD, +Memo: ${data.memo} + +Bitte antworte nicht auf diese E-Mail! + +Mit freundlichen Grüßen, +dein Gradido-Team + Link zu deinem Konto: ${data.overviewURL}`, }, } diff --git a/database/package.json b/database/package.json index 40e5d0294..cabb1b47a 100644 --- a/database/package.json +++ b/database/package.json @@ -1,6 +1,6 @@ { "name": "gradido-database", - "version": "1.12.0", + "version": "1.12.1", "description": "Gradido Database Tool to execute database migrations", "main": "src/index.ts", "repository": "https://github.com/gradido/gradido/database", diff --git a/frontend/package.json b/frontend/package.json index b3832b080..011193b58 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-vue-gradido-wallet", - "version": "1.12.0", + "version": "1.12.1", "private": true, "scripts": { "start": "node run/server.js", diff --git a/frontend/src/components/Contributions/ContributionList.vue b/frontend/src/components/Contributions/ContributionList.vue index 11cc0f9dd..ca4e7a9a0 100644 --- a/frontend/src/components/Contributions/ContributionList.vue +++ b/frontend/src/components/Contributions/ContributionList.vue @@ -4,6 +4,7 @@ {{ memo }}
@@ -141,6 +141,11 @@ export default { type: Number, required: true, }, + allContribution: { + type: Boolean, + required: false, + default: false, + }, }, data() { return { diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue index 8906f40e7..c98bfff2d 100644 --- a/frontend/src/pages/Community.vue +++ b/frontend/src/pages/Community.vue @@ -73,6 +73,7 @@ :contributionCount="contributionCountAll" :showPagination="true" :pageSize="pageSizeAll" + :allContribution="true" /> diff --git a/package.json b/package.json index 0fb7ad7cb..d0b45a8c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gradido", - "version": "1.12.0", + "version": "1.12.1", "description": "Gradido", "main": "index.js", "repository": "git@github.com:gradido/gradido.git",