Compare commits
No commits in common. "2d725188aaad2d4f663718915a897a087a1a9311" and "9b06c771a21a231a1628842cde36ee6ef4eb12de" have entirely different histories.
2d725188aa
...
9b06c771a2
@ -1,10 +1,10 @@
|
||||
import { registerAs } from '@nestjs/config';
|
||||
|
||||
export default registerAs('appConfig', () => ({
|
||||
user: process.env.RABBITMQ_USER || 'user',
|
||||
pass: process.env.RABBITMQ_PASS || 'passer',
|
||||
host: process.env.RABBITMQ_HOST || 'localhost',
|
||||
port: process.env.RABBITMQ_PORT || '5672',
|
||||
user: process.env.RABBITMQ_USER,
|
||||
pass: process.env.RABBITMQ_PASS,
|
||||
host: process.env.RABBITMQ_HOST,
|
||||
port: process.env.RABBITMQ_PORT,
|
||||
apiUrl: process.env.RABBITMQ_API_URL || 'https://rabbitmq.dcb.pixpay.sn/api',
|
||||
queues: {
|
||||
smsmo: process.env.RABBITMQ_QUEUE_WEBHOOK || 'smsmo_queue',
|
||||
|
||||
@ -26,13 +26,12 @@ 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: ['default-roles-dcb-prod'] })
|
||||
@Roles({ roles: ['admin_webhook'] })
|
||||
@ApiOperation({ summary: 'Receive callback for SMS MO notification' })
|
||||
@ApiBody({ type: InboundSMSMessageNotificationWrapperDto })
|
||||
@ApiCreatedResponse({
|
||||
@ -61,7 +60,7 @@ export class WebhookController {
|
||||
|
||||
@Post('subscription/:operator/:country')
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
//@Roles({ roles: ['default-roles-dcb-prod'] })
|
||||
@Roles({ roles: ['admin_webhook'] })
|
||||
@ApiOperation({ summary: 'Receive callback for management of subscription' })
|
||||
@ApiBody({ type: SubscriptionDto })
|
||||
@ApiCreatedResponse({
|
||||
@ -89,7 +88,7 @@ export class WebhookController {
|
||||
|
||||
@Get('he/:operator/:country')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
//@Roles({ roles: ['default-roles-dcb-prod'] })
|
||||
@Roles({ roles: ['admin_webhook'] })
|
||||
@ApiOperation({ summary: 'Receive callback for HE notification' })
|
||||
@ApiOkResponse({
|
||||
description: 'HE notification successfully queued',
|
||||
@ -111,8 +110,8 @@ export class WebhookController {
|
||||
await this.webhookService.handleHeNotification(
|
||||
country,
|
||||
operator,
|
||||
callback,
|
||||
ise,
|
||||
callback,
|
||||
);
|
||||
|
||||
return { status: 'queued' };
|
||||
|
||||
@ -4,14 +4,12 @@ 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' })
|
||||
@ -22,7 +20,6 @@ export class InboundSMSMessageDto {
|
||||
@ApiProperty({ example: 'mes1234' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
@IsOptional()
|
||||
messageId: string;
|
||||
|
||||
@ApiProperty({
|
||||
@ -44,11 +41,6 @@ export class InboundSMSMessageNotificationDto {
|
||||
@IsNotEmpty()
|
||||
callbackData: string;
|
||||
|
||||
@ApiProperty({ example: '1' })
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
partnerId: string;
|
||||
|
||||
@ApiProperty({ type: InboundSMSMessageDto })
|
||||
@ValidateNested()
|
||||
@Type(() => InboundSMSMessageDto)
|
||||
|
||||
@ -17,6 +17,7 @@ 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,10 +13,15 @@ export class WebhookService {
|
||||
private readonly rabbitMQService: RabbitMQService,
|
||||
private configService: ConfigService,
|
||||
) {
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
async smsMoNotification(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user