Compare commits

...

10 Commits

Author SHA1 Message Date
Mamadou Khoussa [028918 DSI/DAC/DIF/DS]
2d725188aa update default role to default-roles-dcb-prod 2025-12-17 19:01:59 +00:00
Mamadou Khoussa [028918 DSI/DAC/DIF/DS]
9ef596e80e update default role to default-roles-dcb-prod 2025-12-17 18:57:53 +00:00
Mamadou Khoussa [028918 DSI/DAC/DIF/DS]
6ef6b7911d update default role to default-roles-dcb-prod 2025-12-17 18:57:25 +00:00
KurtisMelkisedec
5d7b628516
Merge pull request #3 from Cameleonapp/feature/keycloak-config
modification of payload
2025-11-13 10:35:24 +00:00
KurtisMelkisedec
d99264af93 modification of payload 2025-11-13 10:33:09 +00:00
KurtisMelkisedec
a6343f791b
Merge pull request #2 from Cameleonapp/feature/keycloak-config
Feature/keycloak config
2025-10-31 21:25:02 +00:00
KurtisMelkisedec
0ceff9bd68 removing tag in main 2025-10-31 21:23:35 +00:00
KurtisMelkisedec
3e615eda42 modification of InboundSMSMessageNotificationDto 2025-10-31 21:22:13 +00:00
KurtisMelkisedec
eb83c8dc1b
Merge pull request #1 from Cameleonapp/feature/keycloak-config
Feature/keycloak config
2025-10-30 23:30:43 +00:00
KurtisMelkisedec
1ed8d6854d fixing webhookservice config 2025-10-30 23:27:40 +00:00
7 changed files with 50 additions and 47 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: process.env.RABBITMQ_USER || 'user',
pass: process.env.RABBITMQ_PASS, pass: process.env.RABBITMQ_PASS || 'passer',
host: process.env.RABBITMQ_HOST, host: process.env.RABBITMQ_HOST || 'localhost',
port: process.env.RABBITMQ_PORT, port: process.env.RABBITMQ_PORT || '5672',
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,12 +26,13 @@ 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: ['admin_webhook'] }) //@Roles({ roles: ['default-roles-dcb-prod'] })
@ApiOperation({ summary: 'Receive callback for SMS MO notification' }) @ApiOperation({ summary: 'Receive callback for SMS MO notification' })
@ApiBody({ type: InboundSMSMessageNotificationWrapperDto }) @ApiBody({ type: InboundSMSMessageNotificationWrapperDto })
@ApiCreatedResponse({ @ApiCreatedResponse({
@ -60,7 +61,7 @@ export class WebhookController {
@Post('subscription/:operator/:country') @Post('subscription/:operator/:country')
@HttpCode(HttpStatus.CREATED) @HttpCode(HttpStatus.CREATED)
@Roles({ roles: ['admin_webhook'] }) //@Roles({ roles: ['default-roles-dcb-prod'] })
@ApiOperation({ summary: 'Receive callback for management of subscription' }) @ApiOperation({ summary: 'Receive callback for management of subscription' })
@ApiBody({ type: SubscriptionDto }) @ApiBody({ type: SubscriptionDto })
@ApiCreatedResponse({ @ApiCreatedResponse({
@ -88,7 +89,7 @@ export class WebhookController {
@Get('he/:operator/:country') @Get('he/:operator/:country')
@HttpCode(HttpStatus.OK) @HttpCode(HttpStatus.OK)
@Roles({ roles: ['admin_webhook'] }) //@Roles({ roles: ['default-roles-dcb-prod'] })
@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',
@ -110,8 +111,8 @@ export class WebhookController {
await this.webhookService.handleHeNotification( await this.webhookService.handleHeNotification(
country, country,
operator, operator,
ise,
callback, callback,
ise,
); );
return { status: 'queued' }; return { status: 'queued' };

View File

@ -4,12 +4,14 @@ 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' })
@ -20,6 +22,7 @@ export class InboundSMSMessageDto {
@ApiProperty({ example: 'mes1234' }) @ApiProperty({ example: 'mes1234' })
@IsString() @IsString()
@IsNotEmpty() @IsNotEmpty()
@IsOptional()
messageId: string; messageId: string;
@ApiProperty({ @ApiProperty({
@ -41,6 +44,11 @@ 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,7 +17,6 @@ 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,15 +13,10 @@ export class WebhookService {
private readonly rabbitMQService: RabbitMQService, private readonly rabbitMQService: RabbitMQService,
private configService: ConfigService, private configService: ConfigService,
) { ) {
this.smsMoQueue = this.configService.get( const config = this.configService.get('appConfig.queues');
'RABBITMQ_QUEUE_WEBHOOK', this.smsMoQueue = config.smsmo as string;
) as string; this.heQueue = config.he as string;
this.heQueue = this.configService.get( this.subscriptionEventQueue = config.subscription as string;
'RABBITMQ_QUEUE_NOTIFICATION',
) as string;
this.subscriptionEventQueue = this.configService.get(
'RABBITMQ_QUEUE_PAYMENT',
) as string;
} }
async smsMoNotification( async smsMoNotification(