modification of payload
This commit is contained in:
parent
0ceff9bd68
commit
d99264af93
@ -18,21 +18,21 @@ import { APP_GUARD } from '@nestjs/core';
|
|||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
KeycloakConnectModule.registerAsync({
|
KeycloakConnectModule.registerAsync({
|
||||||
imports: [ConfigModule],
|
imports: [ConfigModule],
|
||||||
useFactory: (configService: ConfigService) => {
|
useFactory: (configService: ConfigService) => {
|
||||||
const keycloakConfig = configService.get('appConfig.keycloak');
|
const keycloakConfig = configService.get('appConfig.keycloak');
|
||||||
return {
|
return {
|
||||||
authServerUrl: keycloakConfig.authServerUrl,
|
authServerUrl: keycloakConfig.authServerUrl,
|
||||||
realm: keycloakConfig.realm,
|
realm: keycloakConfig.realm,
|
||||||
clientId: keycloakConfig.clientId,
|
clientId: keycloakConfig.clientId,
|
||||||
secret: keycloakConfig.clientSecret,
|
secret: keycloakConfig.clientSecret,
|
||||||
policyEnforcement: PolicyEnforcementMode.PERMISSIVE,
|
policyEnforcement: PolicyEnforcementMode.PERMISSIVE,
|
||||||
tokenValidation: TokenValidation.ONLINE,
|
tokenValidation: TokenValidation.ONLINE,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
inject: [ConfigService],
|
inject: [ConfigService],
|
||||||
}),
|
}),
|
||||||
ConfigModule.forRoot({ isGlobal: true, load: [appConfig] }),
|
ConfigModule.forRoot({ isGlobal: true, load: [appConfig] }),
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -41,18 +41,18 @@ import { APP_GUARD } from '@nestjs/core';
|
|||||||
AppService,
|
AppService,
|
||||||
WebhookService,
|
WebhookService,
|
||||||
RabbitMQService,
|
RabbitMQService,
|
||||||
{
|
{
|
||||||
provide: APP_GUARD,
|
provide: APP_GUARD,
|
||||||
useClass: AuthGuard,
|
useClass: AuthGuard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: APP_GUARD,
|
provide: APP_GUARD,
|
||||||
useClass: ResourceGuard,
|
useClass: ResourceGuard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: APP_GUARD,
|
provide: APP_GUARD,
|
||||||
useClass: RoleGuard,
|
useClass: RoleGuard,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|||||||
@ -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',
|
||||||
|
|||||||
@ -31,7 +31,7 @@ export class WebhookController {
|
|||||||
|
|
||||||
@Post('sms-mo/:operator/:country')
|
@Post('sms-mo/:operator/:country')
|
||||||
@HttpCode(HttpStatus.CREATED)
|
@HttpCode(HttpStatus.CREATED)
|
||||||
@Roles({ roles: ['admin_webhook'] })
|
@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({
|
||||||
@ -60,7 +60,7 @@ export class WebhookController {
|
|||||||
|
|
||||||
@Post('subscription/:operator/:country')
|
@Post('subscription/:operator/:country')
|
||||||
@HttpCode(HttpStatus.CREATED)
|
@HttpCode(HttpStatus.CREATED)
|
||||||
@Roles({ roles: ['admin_webhook'] })
|
@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({
|
||||||
@ -88,7 +88,7 @@ export class WebhookController {
|
|||||||
|
|
||||||
@Get('he/:operator/:country')
|
@Get('he/:operator/:country')
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Roles({ roles: ['admin_webhook'] })
|
@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',
|
||||||
@ -110,8 +110,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' };
|
||||||
|
|||||||
@ -44,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)
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user