From c79d186a45d8c4c269b83cac282c4dee2f249f88 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 7 Nov 2022 10:32:26 +0100 Subject: [PATCH] Log error when contribution is in the wrong state. Write full content in changeMessage. --- .../graphql/resolver/ContributionResolver.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index 246be6254..ede61b413 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -198,6 +198,9 @@ export class ContributionResolver { contributionToUpdate.contributionStatus !== ContributionStatus.IN_PROGRESS && contributionToUpdate.contributionStatus !== ContributionStatus.PENDING ) { + logger.error( + `Contribution can not be updated since the state is ${contributionToUpdate.contributionStatus}`, + ) throw new Error( `Contribution can not be updated since the state is ${contributionToUpdate.contributionStatus}`, ) @@ -219,16 +222,11 @@ export class ContributionResolver { contributionMessage.createdAt = contributionToUpdate.updatedAt ? contributionToUpdate.updatedAt : contributionToUpdate.createdAt - let changeMessage = '' - if (contributionToUpdate.contributionDate.getTime() !== new Date(creationDate).getTime()) { - changeMessage += contributionToUpdate.contributionDate + '\n' - } - if (contributionToUpdate.memo !== memo) { - changeMessage += '---\n' + contributionToUpdate.memo + '\n' - } - if (contributionToUpdate.amount.toFixed(6) !== amount.toFixed(6)) { - changeMessage += '---\n' + contributionToUpdate.amount - } + const changeMessage = `${contributionToUpdate.contributionDate} + --- + ${contributionToUpdate.memo} + --- + ${contributionToUpdate.amount}` contributionMessage.message = changeMessage contributionMessage.isModerator = false contributionMessage.userId = user.id