diff --git a/src/app.module.ts b/src/app.module.ts index b3a9bba..c631ae7 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -18,21 +18,21 @@ import { APP_GUARD } from '@nestjs/core'; @Module({ imports: [ - KeycloakConnectModule.registerAsync({ - imports: [ConfigModule], - useFactory: (configService: ConfigService) => { - const keycloakConfig = configService.get('appConfig.keycloak'); - return { - authServerUrl: keycloakConfig.authServerUrl, - realm: keycloakConfig.realm, - clientId: keycloakConfig.clientId, - secret: keycloakConfig.clientSecret, - policyEnforcement: PolicyEnforcementMode.PERMISSIVE, - tokenValidation: TokenValidation.ONLINE, - }; - }, - inject: [ConfigService], - }), + KeycloakConnectModule.registerAsync({ + imports: [ConfigModule], + useFactory: (configService: ConfigService) => { + const keycloakConfig = configService.get('appConfig.keycloak'); + return { + authServerUrl: keycloakConfig.authServerUrl, + realm: keycloakConfig.realm, + clientId: keycloakConfig.clientId, + secret: keycloakConfig.clientSecret, + policyEnforcement: PolicyEnforcementMode.PERMISSIVE, + tokenValidation: TokenValidation.ONLINE, + }; + }, + inject: [ConfigService], + }), ConfigModule.forRoot({ isGlobal: true, load: [appConfig] }), ], @@ -41,18 +41,18 @@ import { APP_GUARD } from '@nestjs/core'; AppService, WebhookService, RabbitMQService, - { - provide: APP_GUARD, - useClass: AuthGuard, - }, - { - provide: APP_GUARD, - useClass: ResourceGuard, - }, - { - provide: APP_GUARD, - useClass: RoleGuard, - }, + { + provide: APP_GUARD, + useClass: AuthGuard, + }, + { + provide: APP_GUARD, + useClass: ResourceGuard, + }, + { + provide: APP_GUARD, + useClass: RoleGuard, + }, ], }) export class AppModule {} diff --git a/src/config/app.config.ts b/src/config/app.config.ts index 21fda24..52f049a 100644 --- a/src/config/app.config.ts +++ b/src/config/app.config.ts @@ -1,10 +1,10 @@ import { registerAs } from '@nestjs/config'; export default registerAs('appConfig', () => ({ - user: process.env.RABBITMQ_USER, - pass: process.env.RABBITMQ_PASS, - host: process.env.RABBITMQ_HOST, - port: process.env.RABBITMQ_PORT, + user: process.env.RABBITMQ_USER || 'user', + pass: process.env.RABBITMQ_PASS || 'passer', + host: process.env.RABBITMQ_HOST || 'localhost', + port: process.env.RABBITMQ_PORT || '5672', apiUrl: process.env.RABBITMQ_API_URL || 'https://rabbitmq.dcb.pixpay.sn/api', queues: { smsmo: process.env.RABBITMQ_QUEUE_WEBHOOK || 'smsmo_queue', diff --git a/src/controllers/webhook.controller.ts b/src/controllers/webhook.controller.ts index 0b13a09..0bcd6df 100644 --- a/src/controllers/webhook.controller.ts +++ b/src/controllers/webhook.controller.ts @@ -31,7 +31,7 @@ export class WebhookController { @Post('sms-mo/:operator/:country') @HttpCode(HttpStatus.CREATED) - @Roles({ roles: ['admin_webhook'] }) + @Roles({ roles: ['admin_webhook'] }) @ApiOperation({ summary: 'Receive callback for SMS MO notification' }) @ApiBody({ type: InboundSMSMessageNotificationWrapperDto }) @ApiCreatedResponse({ @@ -60,7 +60,7 @@ export class WebhookController { @Post('subscription/:operator/:country') @HttpCode(HttpStatus.CREATED) - @Roles({ roles: ['admin_webhook'] }) + @Roles({ roles: ['admin_webhook'] }) @ApiOperation({ summary: 'Receive callback for management of subscription' }) @ApiBody({ type: SubscriptionDto }) @ApiCreatedResponse({ @@ -88,7 +88,7 @@ export class WebhookController { @Get('he/:operator/:country') @HttpCode(HttpStatus.OK) - @Roles({ roles: ['admin_webhook'] }) + @Roles({ roles: ['admin_webhook'] }) @ApiOperation({ summary: 'Receive callback for HE notification' }) @ApiOkResponse({ description: 'HE notification successfully queued', @@ -110,8 +110,8 @@ export class WebhookController { await this.webhookService.handleHeNotification( country, operator, - ise, callback, + ise, ); return { status: 'queued' }; diff --git a/src/dtos/sms.mo.dto.ts b/src/dtos/sms.mo.dto.ts index 7e2c9b0..37f118b 100644 --- a/src/dtos/sms.mo.dto.ts +++ b/src/dtos/sms.mo.dto.ts @@ -44,6 +44,11 @@ export class InboundSMSMessageNotificationDto { @IsNotEmpty() callbackData: string; + @ApiProperty({ example: '1' }) + @IsString() + @IsNotEmpty() + partnerId: string; + @ApiProperty({ type: InboundSMSMessageDto }) @ValidateNested() @Type(() => InboundSMSMessageDto) diff --git a/src/services/rabbit.service.ts b/src/services/rabbit.service.ts index 32963f7..404644e 100644 --- a/src/services/rabbit.service.ts +++ b/src/services/rabbit.service.ts @@ -48,8 +48,8 @@ export class RabbitMQService implements OnModuleInit { async sendToQueue(queue: string, message: any) { if (!this.channel) throw new Error('RabbitMQ channel not initialized'); - //check if the queue exist and create it if not - await this.channel.assertQueue(queue, { durable: true }); + // //check if the queue exist and create it if not + // await this.channel.assertQueue(queue, { durable: true }); for (let attempt = 1; attempt <= this.maxRetry; attempt++) { try {