Compare commits
10 Commits
9b06c771a2
...
2d725188aa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2d725188aa | ||
|
|
9ef596e80e | ||
|
|
6ef6b7911d | ||
|
|
5d7b628516 | ||
|
|
d99264af93 | ||
|
|
a6343f791b | ||
|
|
0ceff9bd68 | ||
|
|
3e615eda42 | ||
|
|
eb83c8dc1b | ||
|
|
1ed8d6854d |
@ -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',
|
||||
|
||||
@ -26,12 +26,13 @@ import { WebhookService } from 'src/services/webhook.service';
|
||||
@Controller('webhook')
|
||||
@ApiTags('webhook')
|
||||
@ApiBearerAuth()
|
||||
//todo default role should be changed based on environment
|
||||
export class WebhookController {
|
||||
constructor(private readonly webhookService: WebhookService) {}
|
||||
|
||||
@Post('sms-mo/:operator/:country')
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@Roles({ roles: ['admin_webhook'] })
|
||||
//@Roles({ roles: ['default-roles-dcb-prod'] })
|
||||
@ApiOperation({ summary: 'Receive callback for SMS MO notification' })
|
||||
@ApiBody({ type: InboundSMSMessageNotificationWrapperDto })
|
||||
@ApiCreatedResponse({
|
||||
@ -60,7 +61,7 @@ export class WebhookController {
|
||||
|
||||
@Post('subscription/:operator/:country')
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
@Roles({ roles: ['admin_webhook'] })
|
||||
//@Roles({ roles: ['default-roles-dcb-prod'] })
|
||||
@ApiOperation({ summary: 'Receive callback for management of subscription' })
|
||||
@ApiBody({ type: SubscriptionDto })
|
||||
@ApiCreatedResponse({
|
||||
@ -88,7 +89,7 @@ export class WebhookController {
|
||||
|
||||
@Get('he/:operator/:country')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@Roles({ roles: ['admin_webhook'] })
|
||||
//@Roles({ roles: ['default-roles-dcb-prod'] })
|
||||
@ApiOperation({ summary: 'Receive callback for HE notification' })
|
||||
@ApiOkResponse({
|
||||
description: 'HE notification successfully queued',
|
||||
@ -110,8 +111,8 @@ export class WebhookController {
|
||||
await this.webhookService.handleHeNotification(
|
||||
country,
|
||||
operator,
|
||||
ise,
|
||||
callback,
|
||||
ise,
|
||||
);
|
||||
|
||||
return { status: 'queued' };
|
||||
|
||||
@ -4,12 +4,14 @@ import {
|
||||
ValidateNested,
|
||||
IsNotEmpty,
|
||||
IsDateString,
|
||||
IsOptional,
|
||||
} from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class InboundSMSMessageDto {
|
||||
@ApiProperty({ example: '2025-10-30T14:00:00Z' })
|
||||
@IsDateString()
|
||||
@IsOptional()
|
||||
dateTime: string;
|
||||
|
||||
@ApiProperty({ example: '+33612345678' })
|
||||
@ -20,6 +22,7 @@ export class InboundSMSMessageDto {
|
||||
@ApiProperty({ example: 'mes1234' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
messageId: string;
|
||||
|
||||
@ApiProperty({
|
||||
@ -41,6 +44,11 @@ export class InboundSMSMessageNotificationDto {
|
||||
@IsNotEmpty()
|
||||
callbackData: string;
|
||||
|
||||
@ApiProperty({ example: '1' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
partnerId: string;
|
||||
|
||||
@ApiProperty({ type: InboundSMSMessageDto })
|
||||
@ValidateNested()
|
||||
@Type(() => InboundSMSMessageDto)
|
||||
|
||||
@ -17,7 +17,6 @@ async function bootstrap() {
|
||||
'This is a service dedicated to the reception of callback from external source and sending to rabbitMQ',
|
||||
)
|
||||
.addBearerAuth()
|
||||
.addTag('auth')
|
||||
.setVersion('1.0')
|
||||
.build();
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -13,15 +13,10 @@ export class WebhookService {
|
||||
private readonly rabbitMQService: RabbitMQService,
|
||||
private configService: ConfigService,
|
||||
) {
|
||||
this.smsMoQueue = this.configService.get(
|
||||
'RABBITMQ_QUEUE_WEBHOOK',
|
||||
) as string;
|
||||
this.heQueue = this.configService.get(
|
||||
'RABBITMQ_QUEUE_NOTIFICATION',
|
||||
) as string;
|
||||
this.subscriptionEventQueue = this.configService.get(
|
||||
'RABBITMQ_QUEUE_PAYMENT',
|
||||
) as string;
|
||||
const config = this.configService.get('appConfig.queues');
|
||||
this.smsMoQueue = config.smsmo as string;
|
||||
this.heQueue = config.he as string;
|
||||
this.subscriptionEventQueue = config.subscription as string;
|
||||
}
|
||||
|
||||
async smsMoNotification(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user