From f9b6b887e0e0aae32e0f88072dc38f529c4357f5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 10 Feb 2023 03:37:48 +0100 Subject: [PATCH] things are working properly --- backend/src/event/Event.ts | 157 +++++++----------- backend/src/event/EventProtocolType.ts | 64 +++---- .../graphql/resolver/ContributionResolver.ts | 16 +- .../graphql/resolver/TransactionResolver.ts | 4 +- backend/src/graphql/resolver/UserResolver.ts | 26 +-- 5 files changed, 117 insertions(+), 150 deletions(-) diff --git a/backend/src/event/Event.ts b/backend/src/event/Event.ts index 2545bdc63..310bf6601 100644 --- a/backend/src/event/Event.ts +++ b/backend/src/event/Event.ts @@ -1,8 +1,9 @@ -import { EventProtocol as dbEvent } from '@entity/EventProtocol' +import { EventProtocol as DbEvent } from '@entity/EventProtocol' import Decimal from 'decimal.js-light' import { EventProtocolType } from './EventProtocolType' -export class Event extends dbEvent { +export class Event { + event: DbEvent constructor( type: EventProtocolType, userId: number, @@ -12,31 +13,28 @@ export class Event extends dbEvent { contributionId: number | null = null, amount: Decimal | null = null, messageId: number | null = null, - autosave = true, ) { - super() - this.type = type - this.userId = userId - this.xUserId = xUserId - this.xCommunityId = xCommunityId - this.transactionId = transactionId - this.contributionId = contributionId - this.amount = amount - this.messageId = messageId + this.event = new DbEvent() + this.event.type = type + this.event.userId = userId + this.event.xUserId = xUserId + this.event.xCommunityId = xCommunityId + this.event.transactionId = transactionId + this.event.contributionId = contributionId + this.event.amount = amount + this.event.messageId = messageId + } - if (autosave) { - // This is unsafe, since we cannot wait for this in the constructor - the saving process is async therefore - this.save() - } + save(): Promise { + return this.event.save() } } -export const EVENT_CONTRIBUTION_CREATE = ( +export const EVENT_CONTRIBUTION_CREATE = async ( userId: number, contributionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.CONTRIBUTION_CREATE, userId, @@ -46,14 +44,13 @@ export const EVENT_CONTRIBUTION_CREATE = ( contributionId, amount, null, - autosave, - ) -export const EVENT_CONTRIBUTION_DELETE = ( + ).save() + +export const EVENT_CONTRIBUTION_DELETE = async ( userId: number, contributionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.CONTRIBUTION_DELETE, userId, @@ -63,14 +60,13 @@ export const EVENT_CONTRIBUTION_DELETE = ( contributionId, amount, null, - autosave, - ) -export const EVENT_CONTRIBUTION_UPDATE = ( + ).save() + +export const EVENT_CONTRIBUTION_UPDATE = async ( userId: number, contributionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.CONTRIBUTION_UPDATE, userId, @@ -80,15 +76,13 @@ export const EVENT_CONTRIBUTION_UPDATE = ( contributionId, amount, null, - autosave, - ) + ).save() -export const EVENT_ADMIN_CONTRIBUTION_CREATE = ( +export const EVENT_ADMIN_CONTRIBUTION_CREATE = async ( userId: number, contributionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.ADMIN_CONTRIBUTION_CREATE, userId, @@ -98,15 +92,13 @@ export const EVENT_ADMIN_CONTRIBUTION_CREATE = ( contributionId, amount, null, - autosave, - ) + ).save() -export const EVENT_ADMIN_CONTRIBUTION_UPDATE = ( +export const EVENT_ADMIN_CONTRIBUTION_UPDATE = async ( userId: number, contributionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.ADMIN_CONTRIBUTION_UPDATE, userId, @@ -116,15 +108,13 @@ export const EVENT_ADMIN_CONTRIBUTION_UPDATE = ( contributionId, amount, null, - autosave, - ) + ).save() -export const EVENT_ADMIN_CONTRIBUTION_DELETE = ( +export const EVENT_ADMIN_CONTRIBUTION_DELETE = async ( userId: number, contributionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.ADMIN_CONTRIBUTION_DELETE, userId, @@ -134,15 +124,13 @@ export const EVENT_ADMIN_CONTRIBUTION_DELETE = ( contributionId, amount, null, - autosave, - ) + ).save() -export const EVENT_CONTRIBUTION_CONFIRM = ( +export const EVENT_CONTRIBUTION_CONFIRM = async ( userId: number, contributionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.CONTRIBUTION_CONFIRM, userId, @@ -152,15 +140,13 @@ export const EVENT_CONTRIBUTION_CONFIRM = ( contributionId, amount, null, - autosave, - ) + ).save() -export const EVENT_ADMIN_CONTRIBUTION_DENY = ( +export const EVENT_ADMIN_CONTRIBUTION_DENY = async ( userId: number, contributionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.ADMIN_CONTRIBUTION_DENY, userId, @@ -170,16 +156,14 @@ export const EVENT_ADMIN_CONTRIBUTION_DENY = ( contributionId, amount, null, - autosave, - ) + ).save() -export const EVENT_TRANSACTION_SEND = ( +export const EVENT_TRANSACTION_SEND = async ( userId: number, xUserId: number, transactionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.TRANSACTION_SEND, userId, @@ -189,16 +173,14 @@ export const EVENT_TRANSACTION_SEND = ( null, amount, null, - autosave, - ) + ).save() -export const EVENT_TRANSACTION_RECEIVE = ( +export const EVENT_TRANSACTION_RECEIVE = async ( userId: number, xUserId: number, transactionId: number, amount: Decimal, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.TRANSACTION_RECEIVE, userId, @@ -208,16 +190,14 @@ export const EVENT_TRANSACTION_RECEIVE = ( null, amount, null, - autosave, - ) + ).save() -export const EVENT_LOGIN = (userId: number, autosave = true): Event => - new Event(EventProtocolType.LOGIN, userId, null, null, null, null, null, null, autosave) +export const EVENT_LOGIN = async (userId: number): Promise => + new Event(EventProtocolType.LOGIN, userId, null, null, null, null, null, null).save() -export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = ( +export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = async ( userId: number, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, userId, @@ -227,10 +207,9 @@ export const EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = ( null, null, null, - autosave, - ) + ).save() -export const EVENT_SEND_CONFIRMATION_EMAIL = (userId: number, autosave = true): Event => +export const EVENT_SEND_CONFIRMATION_EMAIL = async (userId: number): Promise => new Event( EventProtocolType.SEND_CONFIRMATION_EMAIL, userId, @@ -240,15 +219,13 @@ export const EVENT_SEND_CONFIRMATION_EMAIL = (userId: number, autosave = true): null, null, null, - autosave, - ) + ).save() -export const EVENT_REDEEM_REGISTER = ( +/* export const EVENT_REDEEM_REGISTER = async ( userId: number, transactionId: number | null = null, contributionId: number | null = null, - autosave = true, -): Event => +): Promise => new Event( EventProtocolType.REDEEM_REGISTER, userId, @@ -258,21 +235,11 @@ export const EVENT_REDEEM_REGISTER = ( contributionId, null, null, - autosave, - ) + ).save() +*/ -export const EVENT_REGISTER = (userId: number, autosave = true): Event => - new Event(EventProtocolType.REGISTER, userId, null, null, null, null, null, null, autosave) +export const EVENT_REGISTER = async (userId: number): Promise => + new Event(EventProtocolType.REGISTER, userId, null, null, null, null, null, null).save() -export const EVENT_ACTIVATE_ACCOUNT = (userId: number, autosave = true): Event => - new Event( - EventProtocolType.ACTIVATE_ACCOUNT, - userId, - null, - null, - null, - null, - null, - null, - autosave, - ) +export const EVENT_ACTIVATE_ACCOUNT = async (userId: number): Promise => + new Event(EventProtocolType.ACTIVATE_ACCOUNT, userId, null, null, null, null, null, null).save() diff --git a/backend/src/event/EventProtocolType.ts b/backend/src/event/EventProtocolType.ts index ccd15d238..b3ade4c5c 100644 --- a/backend/src/event/EventProtocolType.ts +++ b/backend/src/event/EventProtocolType.ts @@ -1,50 +1,50 @@ export enum EventProtocolType { - BASIC = 'BASIC', - VISIT_GRADIDO = 'VISIT_GRADIDO', + // BASIC = 'BASIC', + // VISIT_GRADIDO = 'VISIT_GRADIDO', REGISTER = 'REGISTER', REDEEM_REGISTER = 'REDEEM_REGISTER', - VERIFY_REDEEM = 'VERIFY_REDEEM', - INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT', + // VERIFY_REDEEM = 'VERIFY_REDEEM', + // INACTIVE_ACCOUNT = 'INACTIVE_ACCOUNT', SEND_CONFIRMATION_EMAIL = 'SEND_CONFIRMATION_EMAIL', SEND_ACCOUNT_MULTIREGISTRATION_EMAIL = 'SEND_ACCOUNT_MULTIREGISTRATION_EMAIL', - CONFIRM_EMAIL = 'CONFIRM_EMAIL', - REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP', + // CONFIRM_EMAIL = 'CONFIRM_EMAIL', + // REGISTER_EMAIL_KLICKTIPP = 'REGISTER_EMAIL_KLICKTIPP', LOGIN = 'LOGIN', - LOGOUT = 'LOGOUT', - REDEEM_LOGIN = 'REDEEM_LOGIN', + // LOGOUT = 'LOGOUT', + // REDEEM_LOGIN = 'REDEEM_LOGIN', ACTIVATE_ACCOUNT = 'ACTIVATE_ACCOUNT', - SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL', - PASSWORD_CHANGE = 'PASSWORD_CHANGE', - SEND_TRANSACTION_SEND_EMAIL = 'SEND_TRANSACTION_SEND_EMAIL', - SEND_TRANSACTION_RECEIVE_EMAIL = 'SEND_TRANSACTION_RECEIVE_EMAIL', + // SEND_FORGOT_PASSWORD_EMAIL = 'SEND_FORGOT_PASSWORD_EMAIL', + // PASSWORD_CHANGE = 'PASSWORD_CHANGE', + // SEND_TRANSACTION_SEND_EMAIL = 'SEND_TRANSACTION_SEND_EMAIL', + // SEND_TRANSACTION_RECEIVE_EMAIL = 'SEND_TRANSACTION_RECEIVE_EMAIL', TRANSACTION_SEND = 'TRANSACTION_SEND', - TRANSACTION_SEND_REDEEM = 'TRANSACTION_SEND_REDEEM', - TRANSACTION_REPEATE_REDEEM = 'TRANSACTION_REPEATE_REDEEM', - TRANSACTION_CREATION = 'TRANSACTION_CREATION', + // TRANSACTION_SEND_REDEEM = 'TRANSACTION_SEND_REDEEM', + // TRANSACTION_REPEATE_REDEEM = 'TRANSACTION_REPEATE_REDEEM', + // TRANSACTION_CREATION = 'TRANSACTION_CREATION', TRANSACTION_RECEIVE = 'TRANSACTION_RECEIVE', - TRANSACTION_RECEIVE_REDEEM = 'TRANSACTION_RECEIVE_REDEEM', - SEND_TRANSACTION_LINK_REDEEM_EMAIL = 'SEND_TRANSACTION_LINK_REDEEM_EMAIL', - SEND_ADDED_CONTRIBUTION_EMAIL = 'SEND_ADDED_CONTRIBUTION_EMAIL', - SEND_CONTRIBUTION_CONFIRM_EMAIL = 'SEND_CONTRIBUTION_CONFIRM_EMAIL', + // TRANSACTION_RECEIVE_REDEEM = 'TRANSACTION_RECEIVE_REDEEM', + // SEND_TRANSACTION_LINK_REDEEM_EMAIL = 'SEND_TRANSACTION_LINK_REDEEM_EMAIL', + // SEND_ADDED_CONTRIBUTION_EMAIL = 'SEND_ADDED_CONTRIBUTION_EMAIL', + // SEND_CONTRIBUTION_CONFIRM_EMAIL = 'SEND_CONTRIBUTION_CONFIRM_EMAIL', CONTRIBUTION_CREATE = 'CONTRIBUTION_CREATE', CONTRIBUTION_CONFIRM = 'CONTRIBUTION_CONFIRM', - CONTRIBUTION_DENY = 'CONTRIBUTION_DENY', - CONTRIBUTION_LINK_DEFINE = 'CONTRIBUTION_LINK_DEFINE', - CONTRIBUTION_LINK_ACTIVATE_REDEEM = 'CONTRIBUTION_LINK_ACTIVATE_REDEEM', + // CONTRIBUTION_DENY = 'CONTRIBUTION_DENY', + // CONTRIBUTION_LINK_DEFINE = 'CONTRIBUTION_LINK_DEFINE', + // CONTRIBUTION_LINK_ACTIVATE_REDEEM = 'CONTRIBUTION_LINK_ACTIVATE_REDEEM', CONTRIBUTION_DELETE = 'CONTRIBUTION_DELETE', CONTRIBUTION_UPDATE = 'CONTRIBUTION_UPDATE', ADMIN_CONTRIBUTION_CREATE = 'ADMIN_CONTRIBUTION_CREATE', ADMIN_CONTRIBUTION_DELETE = 'ADMIN_CONTRIBUTION_DELETE', ADMIN_CONTRIBUTION_DENY = 'ADMIN_CONTRIBUTION_DENY', ADMIN_CONTRIBUTION_UPDATE = 'ADMIN_CONTRIBUTION_UPDATE', - USER_CREATE_CONTRIBUTION_MESSAGE = 'USER_CREATE_CONTRIBUTION_MESSAGE', - ADMIN_CREATE_CONTRIBUTION_MESSAGE = 'ADMIN_CREATE_CONTRIBUTION_MESSAGE', - DELETE_USER = 'DELETE_USER', - UNDELETE_USER = 'UNDELETE_USER', - CHANGE_USER_ROLE = 'CHANGE_USER_ROLE', - ADMIN_UPDATE_CONTRIBUTION = 'ADMIN_UPDATE_CONTRIBUTION', - ADMIN_DELETE_CONTRIBUTION = 'ADMIN_DELETE_CONTRIBUTION', - CREATE_CONTRIBUTION_LINK = 'CREATE_CONTRIBUTION_LINK', - DELETE_CONTRIBUTION_LINK = 'DELETE_CONTRIBUTION_LINK', - UPDATE_CONTRIBUTION_LINK = 'UPDATE_CONTRIBUTION_LINK', + // USER_CREATE_CONTRIBUTION_MESSAGE = 'USER_CREATE_CONTRIBUTION_MESSAGE', + // ADMIN_CREATE_CONTRIBUTION_MESSAGE = 'ADMIN_CREATE_CONTRIBUTION_MESSAGE', + // DELETE_USER = 'DELETE_USER', + // UNDELETE_USER = 'UNDELETE_USER', + // CHANGE_USER_ROLE = 'CHANGE_USER_ROLE', + // ADMIN_UPDATE_CONTRIBUTION = 'ADMIN_UPDATE_CONTRIBUTION', + // ADMIN_DELETE_CONTRIBUTION = 'ADMIN_DELETE_CONTRIBUTION', + // CREATE_CONTRIBUTION_LINK = 'CREATE_CONTRIBUTION_LINK', + // DELETE_CONTRIBUTION_LINK = 'DELETE_CONTRIBUTION_LINK', + // UPDATE_CONTRIBUTION_LINK = 'UPDATE_CONTRIBUTION_LINK', } diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index b374275c4..62001c6e8 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -93,7 +93,7 @@ export class ContributionResolver { logger.trace('contribution to save', contribution) await DbContribution.save(contribution) - EVENT_CONTRIBUTION_CREATE(user.id, contribution.id, amount) + await EVENT_CONTRIBUTION_CREATE(user.id, contribution.id, amount) return new UnconfirmedContribution(contribution, user, creations) } @@ -124,7 +124,7 @@ export class ContributionResolver { contribution.deletedAt = new Date() await contribution.save() - EVENT_CONTRIBUTION_DELETE(user.id, contribution.id, contribution.amount) + await EVENT_CONTRIBUTION_DELETE(user.id, contribution.id, contribution.amount) const res = await contribution.softRemove() return !!res @@ -275,7 +275,7 @@ export class ContributionResolver { contributionToUpdate.updatedAt = new Date() DbContribution.save(contributionToUpdate) - EVENT_CONTRIBUTION_UPDATE(user.id, contributionId, amount) + await EVENT_CONTRIBUTION_UPDATE(user.id, contributionId, amount) return new UnconfirmedContribution(contributionToUpdate, user, creations) } @@ -337,7 +337,7 @@ export class ContributionResolver { await DbContribution.save(contribution) - EVENT_ADMIN_CONTRIBUTION_CREATE(moderator.id, contribution.id, amount) + await EVENT_ADMIN_CONTRIBUTION_CREATE(moderator.id, contribution.id, amount) return getUserCreation(emailContact.userId, clientTimezoneOffset) } @@ -442,7 +442,7 @@ export class ContributionResolver { result.creation = await getUserCreation(user.id, clientTimezoneOffset) - EVENT_ADMIN_CONTRIBUTION_UPDATE(user.id, contributionToUpdate.id, amount) + await EVENT_ADMIN_CONTRIBUTION_UPDATE(user.id, contributionToUpdate.id, amount) return result } @@ -515,7 +515,7 @@ export class ContributionResolver { await contribution.save() const res = await contribution.softRemove() - EVENT_ADMIN_CONTRIBUTION_DELETE(contribution.userId, contribution.id, contribution.amount) + await EVENT_ADMIN_CONTRIBUTION_DELETE(contribution.userId, contribution.id, contribution.amount) sendContributionDeletedEmail({ firstName: user.firstName, @@ -634,7 +634,7 @@ export class ContributionResolver { await queryRunner.release() } - EVENT_CONTRIBUTION_CONFIRM(user.id, contribution.id, contribution.amount) + await EVENT_CONTRIBUTION_CONFIRM(user.id, contribution.id, contribution.amount) } finally { releaseLock() } @@ -728,7 +728,7 @@ export class ContributionResolver { contributionToUpdate.deniedAt = new Date() const res = await contributionToUpdate.save() - EVENT_ADMIN_CONTRIBUTION_DENY( + await EVENT_ADMIN_CONTRIBUTION_DENY( contributionToUpdate.userId, contributionToUpdate.id, contributionToUpdate.amount, diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 1d3864f27..46fb812f7 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -140,14 +140,14 @@ export const executeTransaction = async ( await queryRunner.commitTransaction() logger.info(`commit Transaction successful...`) - EVENT_TRANSACTION_SEND( + await EVENT_TRANSACTION_SEND( transactionSend.userId, transactionSend.linkedUserId, transactionSend.id, transactionSend.amount.mul(-1), ) - EVENT_TRANSACTION_RECEIVE( + await EVENT_TRANSACTION_RECEIVE( transactionReceive.userId, transactionReceive.linkedUserId, transactionReceive.id, diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 7a9eebe65..96bb62aef 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -49,10 +49,10 @@ import { klicktippSignIn } from '@/apis/KlicktippController' import { RIGHTS } from '@/auth/RIGHTS' import { hasElopageBuys } from '@/util/hasElopageBuys' import { + Event, EVENT_LOGIN, EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL, EVENT_SEND_CONFIRMATION_EMAIL, - EVENT_REDEEM_REGISTER, EVENT_REGISTER, EVENT_ACTIVATE_ACCOUNT, } from '@/event/Event' @@ -62,6 +62,7 @@ import { FULL_CREATION_AVAILABLE } from './const/const' import { encryptPassword, verifyPassword } from '@/password/PasswordEncryptor' import { PasswordEncryptionType } from '../enum/PasswordEncryptionType' import LogError from '@/server/LogError' +import { EventProtocolType } from '@/event/EventProtocolType' // eslint-disable-next-line @typescript-eslint/no-var-requires const sodium = require('sodium-native') @@ -176,8 +177,7 @@ export class UserResolver { value: encode(dbUser.gradidoID), }) - EVENT_LOGIN(user.id) - + await EVENT_LOGIN(user.id) logger.info(`successful Login: ${JSON.stringify(user, null, 2)}`) return user } @@ -247,7 +247,7 @@ export class UserResolver { language: foundUser.language, // use language of the emails owner for sending }) - EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL(foundUser.id) + await EVENT_SEND_ACCOUNT_MULTIREGISTRATION_EMAIL(foundUser.id) logger.info( `sendAccountMultiRegistrationEmail by ${firstName} ${lastName} to ${foundUser.firstName} ${foundUser.lastName} <${email}>`, @@ -265,7 +265,7 @@ export class UserResolver { const gradidoID = await newGradidoID() - const eventRegisterRedeem = EVENT_REDEEM_REGISTER(0, null, null, false) + const eventRegisterRedeem = new Event(EventProtocolType.REDEEM_REGISTER, 0) let dbUser = new DbUser() dbUser.gradidoID = gradidoID dbUser.firstName = firstName @@ -282,14 +282,14 @@ export class UserResolver { logger.info('redeemCode found contributionLink=' + contributionLink) if (contributionLink) { dbUser.contributionLinkId = contributionLink.id - eventRegisterRedeem.contributionId = contributionLink.id + eventRegisterRedeem.event.contributionId = contributionLink.id } } else { const transactionLink = await DbTransactionLink.findOne({ code: redeemCode }) logger.info('redeemCode found transactionLink=' + transactionLink) if (transactionLink) { dbUser.referrerId = transactionLink.userId - eventRegisterRedeem.transactionId = transactionLink.id + eventRegisterRedeem.event.transactionId = transactionLink.id } } } @@ -329,7 +329,7 @@ export class UserResolver { logger.info(`sendAccountActivationEmail of ${firstName}.${lastName} to ${email}`) // TODO: this event is used twice, why? - EVENT_SEND_CONFIRMATION_EMAIL(dbUser.id) + await EVENT_SEND_CONFIRMATION_EMAIL(dbUser.id) if (!emailSent) { logger.debug(`Account confirmation link: ${activationLink}`) @@ -346,10 +346,10 @@ export class UserResolver { logger.info('createUser() successful...') if (redeemCode) { - eventRegisterRedeem.userId = dbUser.id - eventRegisterRedeem.save() + eventRegisterRedeem.event.userId = dbUser.id + await eventRegisterRedeem.save() } else { - EVENT_REGISTER(dbUser.id) + await EVENT_REGISTER(dbUser.id) } return new User(dbUser) @@ -465,7 +465,7 @@ export class UserResolver { await queryRunner.commitTransaction() logger.info('User and UserContact data written successfully...') - EVENT_ACTIVATE_ACCOUNT(user.id) + await EVENT_ACTIVATE_ACCOUNT(user.id) } catch (e) { await queryRunner.rollbackTransaction() throw new LogError('Error on writing User and User Contact data', e) @@ -810,7 +810,7 @@ export class UserResolver { logger.info(`Account confirmation link: ${activationLink}`) } else { // TODO: this event is used twice, why? - EVENT_SEND_CONFIRMATION_EMAIL(user.id) + await EVENT_SEND_CONFIRMATION_EMAIL(user.id) } return true