Compare commits

..

No commits in common. "2d725188aaad2d4f663718915a897a087a1a9311" and "9b06c771a21a231a1628842cde36ee6ef4eb12de" have entirely different histories.

7 changed files with 47 additions and 50 deletions

View File

@ -1,10 +1,10 @@
import { registerAs } from '@nestjs/config'; import { registerAs } from '@nestjs/config';
export default registerAs('appConfig', () => ({ export default registerAs('appConfig', () => ({
user: process.env.RABBITMQ_USER || 'user', user: process.env.RABBITMQ_USER,
pass: process.env.RABBITMQ_PASS || 'passer', pass: process.env.RABBITMQ_PASS,
host: process.env.RABBITMQ_HOST || 'localhost', host: process.env.RABBITMQ_HOST,
port: process.env.RABBITMQ_PORT || '5672', port: process.env.RABBITMQ_PORT,
apiUrl: process.env.RABBITMQ_API_URL || 'https://rabbitmq.dcb.pixpay.sn/api', apiUrl: process.env.RABBITMQ_API_URL || 'https://rabbitmq.dcb.pixpay.sn/api',
queues: { queues: {
smsmo: process.env.RABBITMQ_QUEUE_WEBHOOK || 'smsmo_queue', smsmo: process.env.RABBITMQ_QUEUE_WEBHOOK || 'smsmo_queue',

View File

@ -26,13 +26,12 @@ import { WebhookService } from 'src/services/webhook.service';
@Controller('webhook') @Controller('webhook')
@ApiTags('webhook') @ApiTags('webhook')
@ApiBearerAuth() @ApiBearerAuth()
//todo default role should be changed based on environment
export class WebhookController { export class WebhookController {
constructor(private readonly webhookService: WebhookService) {} constructor(private readonly webhookService: WebhookService) {}
@Post('sms-mo/:operator/:country') @Post('sms-mo/:operator/:country')
@HttpCode(HttpStatus.CREATED) @HttpCode(HttpStatus.CREATED)
//@Roles({ roles: ['default-roles-dcb-prod'] }) @Roles({ roles: ['admin_webhook'] })
@ApiOperation({ summary: 'Receive callback for SMS MO notification' }) @ApiOperation({ summary: 'Receive callback for SMS MO notification' })
@ApiBody({ type: InboundSMSMessageNotificationWrapperDto }) @ApiBody({ type: InboundSMSMessageNotificationWrapperDto })
@ApiCreatedResponse({ @ApiCreatedResponse({
@ -61,7 +60,7 @@ export class WebhookController {
@Post('subscription/:operator/:country') @Post('subscription/:operator/:country')
@HttpCode(HttpStatus.CREATED) @HttpCode(HttpStatus.CREATED)
//@Roles({ roles: ['default-roles-dcb-prod'] }) @Roles({ roles: ['admin_webhook'] })
@ApiOperation({ summary: 'Receive callback for management of subscription' }) @ApiOperation({ summary: 'Receive callback for management of subscription' })
@ApiBody({ type: SubscriptionDto }) @ApiBody({ type: SubscriptionDto })
@ApiCreatedResponse({ @ApiCreatedResponse({
@ -89,7 +88,7 @@ export class WebhookController {
@Get('he/:operator/:country') @Get('he/:operator/:country')
@HttpCode(HttpStatus.OK) @HttpCode(HttpStatus.OK)
//@Roles({ roles: ['default-roles-dcb-prod'] }) @Roles({ roles: ['admin_webhook'] })
@ApiOperation({ summary: 'Receive callback for HE notification' }) @ApiOperation({ summary: 'Receive callback for HE notification' })
@ApiOkResponse({ @ApiOkResponse({
description: 'HE notification successfully queued', description: 'HE notification successfully queued',
@ -111,8 +110,8 @@ export class WebhookController {
await this.webhookService.handleHeNotification( await this.webhookService.handleHeNotification(
country, country,
operator, operator,
callback,
ise, ise,
callback,
); );
return { status: 'queued' }; return { status: 'queued' };

View File

@ -4,14 +4,12 @@ import {
ValidateNested, ValidateNested,
IsNotEmpty, IsNotEmpty,
IsDateString, IsDateString,
IsOptional,
} from 'class-validator'; } from 'class-validator';
import { Type } from 'class-transformer'; import { Type } from 'class-transformer';
export class InboundSMSMessageDto { export class InboundSMSMessageDto {
@ApiProperty({ example: '2025-10-30T14:00:00Z' }) @ApiProperty({ example: '2025-10-30T14:00:00Z' })
@IsDateString() @IsDateString()
@IsOptional()
dateTime: string; dateTime: string;
@ApiProperty({ example: '+33612345678' }) @ApiProperty({ example: '+33612345678' })
@ -22,7 +20,6 @@ export class InboundSMSMessageDto {
@ApiProperty({ example: 'mes1234' }) @ApiProperty({ example: 'mes1234' })
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
@IsOptional()
messageId: string; messageId: string;
@ApiProperty({ @ApiProperty({
@ -44,11 +41,6 @@ export class InboundSMSMessageNotificationDto {
@IsNotEmpty() @IsNotEmpty()
callbackData: string; callbackData: string;
@ApiProperty({ example: '1' })
@IsString()
@IsNotEmpty()
partnerId: string;
@ApiProperty({ type: InboundSMSMessageDto }) @ApiProperty({ type: InboundSMSMessageDto })
@ValidateNested() @ValidateNested()
@Type(() => InboundSMSMessageDto) @Type(() => InboundSMSMessageDto)

View File

@ -17,6 +17,7 @@ async function bootstrap() {
'This is a service dedicated to the reception of callback from external source and sending to rabbitMQ', 'This is a service dedicated to the reception of callback from external source and sending to rabbitMQ',
) )
.addBearerAuth() .addBearerAuth()
.addTag('auth')
.setVersion('1.0') .setVersion('1.0')
.build(); .build();

View File

@ -48,8 +48,8 @@ export class RabbitMQService implements OnModuleInit {
async sendToQueue(queue: string, message: any) { async sendToQueue(queue: string, message: any) {
if (!this.channel) throw new Error('RabbitMQ channel not initialized'); if (!this.channel) throw new Error('RabbitMQ channel not initialized');
// //check if the queue exist and create it if not //check if the queue exist and create it if not
// await this.channel.assertQueue(queue, { durable: true }); await this.channel.assertQueue(queue, { durable: true });
for (let attempt = 1; attempt <= this.maxRetry; attempt++) { for (let attempt = 1; attempt <= this.maxRetry; attempt++) {
try { try {

View File

@ -13,10 +13,15 @@ export class WebhookService {
private readonly rabbitMQService: RabbitMQService, private readonly rabbitMQService: RabbitMQService,
private configService: ConfigService, private configService: ConfigService,
) { ) {
const config = this.configService.get('appConfig.queues'); this.smsMoQueue = this.configService.get(
this.smsMoQueue = config.smsmo as string; 'RABBITMQ_QUEUE_WEBHOOK',
this.heQueue = config.he as string; ) as string;
this.subscriptionEventQueue = config.subscription as string; this.heQueue = this.configService.get(
'RABBITMQ_QUEUE_NOTIFICATION',
) as string;
this.subscriptionEventQueue = this.configService.get(
'RABBITMQ_QUEUE_PAYMENT',
) as string;
} }
async smsMoNotification( async smsMoNotification(