Merge branch 'fixAdValidation' into 'main'

Fix ad validation

See merge request v3/service/ad!32
This commit is contained in:
Sylvain Briat 2023-12-07 10:16:04 +00:00
commit 99017b0e55
5 changed files with 34 additions and 22 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@mobicoop/ad", "name": "@mobicoop/ad",
"version": "2.4.0", "version": "2.4.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@mobicoop/ad", "name": "@mobicoop/ad",
"version": "2.4.0", "version": "2.4.1",
"license": "AGPL", "license": "AGPL",
"dependencies": { "dependencies": {
"@grpc/grpc-js": "^1.9.11", "@grpc/grpc-js": "^1.9.11",

View File

@ -1,6 +1,6 @@
{ {
"name": "@mobicoop/ad", "name": "@mobicoop/ad",
"version": "2.4.0", "version": "2.4.1",
"description": "Mobicoop V3 Ad", "description": "Mobicoop V3 Ad",
"author": "sbriat", "author": "sbriat",
"private": true, "private": true,

View File

@ -5,16 +5,18 @@ export const SERVICE_NAME = 'ad';
export const GRPC_PACKAGE_NAME = 'ad'; export const GRPC_PACKAGE_NAME = 'ad';
export const GRPC_SERVICE_NAME = 'AdService'; export const GRPC_SERVICE_NAME = 'AdService';
// messaging // messaging output
export const AD_CREATED_ROUTING_KEY = 'ad.created'; export const AD_CREATED_ROUTING_KEY = 'ad.created';
// messaging input
export const MATCHER_AD_CREATED_MESSAGE_HANDLER = 'matcherAdCreated'; export const MATCHER_AD_CREATED_MESSAGE_HANDLER = 'matcherAdCreated';
export const MATCHER_AD_CREATED_ROUTING_KEY = 'matcher.ad.created'; export const MATCHER_AD_CREATED_ROUTING_KEY = 'matcher-ad.created';
export const MATCHER_AD_CREATED_QUEUE = 'matcher-ad-created'; export const MATCHER_AD_CREATED_QUEUE = 'ad.matcher-ad.created';
export const MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER = export const MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER =
'matcherAdCreationFailed'; 'matcherAdCreationFailed';
export const MATCHER_AD_CREATION_FAILED_ROUTING_KEY = export const MATCHER_AD_CREATION_FAILED_ROUTING_KEY =
'matcher.ad.creation.failed'; 'matcher-ad.creation-failed';
export const MATCHER_AD_CREATION_FAILED_QUEUE = 'matcher-ad-creation-failed'; export const MATCHER_AD_CREATION_FAILED_QUEUE = 'ad.matcher-ad.creation-failed';
// configuration // configuration
export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set'; export const SERVICE_CONFIGURATION_SET_QUEUE = 'ad-configuration-set';

View File

@ -13,12 +13,17 @@ export class MatcherAdCreatedMessageHandler {
name: MATCHER_AD_CREATED_MESSAGE_HANDLER, name: MATCHER_AD_CREATED_MESSAGE_HANDLER,
}) })
public async matcherAdCreated(message: string) { public async matcherAdCreated(message: string) {
const matcherAdCreatedIntegrationEvent: MatcherAdCreatedIntegrationEvent = try {
JSON.parse(message); const matcherAdCreatedIntegrationEvent: MatcherAdCreatedIntegrationEvent =
await this.commandBus.execute( JSON.parse(message);
new ValidateAdCommand({ await this.commandBus.execute(
id: matcherAdCreatedIntegrationEvent.id, new ValidateAdCommand({
}), id: matcherAdCreatedIntegrationEvent.id,
); }),
);
} catch (error: any) {
// do not throw error to acknowledge incoming message
// error handling should be done in the command handler, if relevant
}
} }
} }

View File

@ -13,12 +13,17 @@ export class MatcherAdCreationFailedMessageHandler {
name: MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER, name: MATCHER_AD_CREATION_FAILED_MESSAGE_HANDLER,
}) })
public async matcherAdCreationFailed(message: string) { public async matcherAdCreationFailed(message: string) {
const matcherAdCreationFailedIntegrationEvent: MatcherAdCreationFailedIntegrationEvent = try {
JSON.parse(message); const matcherAdCreationFailedIntegrationEvent: MatcherAdCreationFailedIntegrationEvent =
await this.commandBus.execute( JSON.parse(message);
new InvalidateAdCommand({ await this.commandBus.execute(
id: matcherAdCreationFailedIntegrationEvent.id, new InvalidateAdCommand({
}), id: matcherAdCreationFailedIntegrationEvent.id,
); }),
);
} catch (error: any) {
// do not throw error to acknowledge incoming message
// error handling should be done in the command handler, if relevant
}
} }
} }