use new integration events

This commit is contained in:
sbriat 2023-07-24 16:02:49 +02:00
parent 66bfa89e8f
commit 3d746df9bc
4 changed files with 11 additions and 11 deletions

View File

@ -13,10 +13,10 @@ export class UserDeletedMessageHandler {
public async userDeleted(message: string) {
const deletedUser = JSON.parse(message);
try {
if (!deletedUser.hasOwnProperty('userId')) throw new Error();
if (!deletedUser.hasOwnProperty('id')) throw new Error();
await this.commandBus.execute(
new DeleteAuthenticationCommand({
userId: deletedUser.userId,
userId: deletedUser.id,
}),
);
} catch (e: any) {}

View File

@ -14,11 +14,11 @@ export class UserUpdatedMessageHandler {
public async userUpdated(message: string) {
const updatedUser = JSON.parse(message);
try {
if (!updatedUser.hasOwnProperty('userId')) throw new Error();
if (!updatedUser.hasOwnProperty('id')) throw new Error();
if (updatedUser.hasOwnProperty('email') && updatedUser.email) {
await this.commandBus.execute(
new UpdateUsernameCommand({
userId: updatedUser.userId,
userId: updatedUser.id,
username: {
name: updatedUser.email,
type: Type.EMAIL,
@ -29,7 +29,7 @@ export class UserUpdatedMessageHandler {
if (updatedUser.hasOwnProperty('phone') && updatedUser.phone) {
await this.commandBus.execute(
new UpdateUsernameCommand({
userId: updatedUser.userId,
userId: updatedUser.if,
username: {
name: updatedUser.phone,
type: Type.PHONE,

View File

@ -2,10 +2,10 @@ import { UserDeletedMessageHandler } from '@modules/authentication/interface/mes
import { CommandBus } from '@nestjs/cqrs';
import { Test, TestingModule } from '@nestjs/testing';
const userDeletedMessage = '{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca"}';
const userDeletedMessage = '{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca"}';
const userIdNotProvidedDeletedMessage =
'{"user":"2436d413-b7c7-429e-9792-b78edc17b300"}';
'{"userId":"2436d413-b7c7-429e-9792-b78edc17b300"}';
const mockCommandBus = {
execute: jest.fn().mockImplementationOnce(() => 'john.doe@email.com'),

View File

@ -3,16 +3,16 @@ import { CommandBus } from '@nestjs/cqrs';
import { Test, TestingModule } from '@nestjs/testing';
const userEmailUpdatedMessage =
'{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca","email":"new-john.doe@email.com"}';
'{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca","email":"new-john.doe@email.com"}';
const userPhoneUpdatedMessage =
'{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca","phone":"+33611224455"}';
'{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca","phone":"+33611224455"}';
const userBirthDateUpdatedMessage =
'{"userId":"2436d413-b7c7-429e-9792-b78edc17b3ca","birthDate":"1976-10-23"}';
'{"id":"2436d413-b7c7-429e-9792-b78edc17b3ca","birthDate":"1976-10-23"}';
const userIdNotProvidedUpdatedMessage =
'{"user":"2436d413-b7c7-429e-9792-b78edc17b300","email":"new-john.doe@email.com"}';
'{"userId":"2436d413-b7c7-429e-9792-b78edc17b300","email":"new-john.doe@email.com"}';
const mockCommandBus = {
execute: jest