rez_core 2.2.262 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module/integration/controller/integration.controller.d.ts +16 -0
- package/dist/module/integration/controller/integration.controller.js +64 -0
- package/dist/module/integration/controller/integration.controller.js.map +1 -1
- package/dist/module/integration/entity/integration-source.entity.js +1 -1
- package/dist/module/integration/entity/integration-source.entity.js.map +1 -1
- package/dist/module/integration/service/integration.service.d.ts +1 -0
- package/dist/module/integration/service/integration.service.js +14 -0
- package/dist/module/integration/service/integration.service.js.map +1 -1
- package/dist/module/notification/controller/notification.controller.d.ts +1 -0
- package/dist/module/notification/controller/notification.controller.js +1 -1
- package/dist/module/notification/controller/notification.controller.js.map +1 -1
- package/dist/module/notification/service/notification.service.d.ts +1 -1
- package/dist/module/notification/service/notification.service.js +11 -2
- package/dist/module/notification/service/notification.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/integration/controller/integration.controller.ts +64 -0
- package/src/module/integration/entity/integration-source.entity.ts +1 -1
- package/src/module/integration/service/integration.service.ts +21 -0
- package/src/module/notification/controller/notification.controller.ts +8 -1
- package/src/module/notification/service/notification.service.ts +19 -4
package/package.json
CHANGED
|
@@ -429,4 +429,68 @@ export class IntegrationController {
|
|
|
429
429
|
|
|
430
430
|
return allIntegrationData;
|
|
431
431
|
}
|
|
432
|
+
|
|
433
|
+
@Get('provider-urls')
|
|
434
|
+
getProviderUrls(
|
|
435
|
+
@Query('integration_type')
|
|
436
|
+
integration_type?: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE',
|
|
437
|
+
@Query('integration_provider') integration_provider?: string,
|
|
438
|
+
) {
|
|
439
|
+
if (integration_type === 'TELEPHONE' && integration_provider) {
|
|
440
|
+
if (integration_provider.toLowerCase() == 'ozonetel') {
|
|
441
|
+
return {
|
|
442
|
+
success: true,
|
|
443
|
+
data: {
|
|
444
|
+
baseUrl: 'https://in1-ccaas-api.ozonetel.com',
|
|
445
|
+
agentLoginUrl: 'https://agent.cloudagent.ozonetel.com/login',
|
|
446
|
+
},
|
|
447
|
+
};
|
|
448
|
+
} else if (integration_provider.toLowerCase() == 'tubelight') {
|
|
449
|
+
return {
|
|
450
|
+
success: true,
|
|
451
|
+
data: {
|
|
452
|
+
baseUrl: 'https://portal.tubelightcommunications.com',
|
|
453
|
+
agentLoginUrl: 'https://dashboard.hellotubelight.com/sign-in',
|
|
454
|
+
},
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
@Get('active-config')
|
|
461
|
+
async getActiveConfig(
|
|
462
|
+
@Query('level_id', ParseIntPipe) levelId: number,
|
|
463
|
+
@Query('level_type') levelType: string,
|
|
464
|
+
@Query('app_code') appCode: string,
|
|
465
|
+
@Query('integration_type') integrationType: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE',
|
|
466
|
+
) {
|
|
467
|
+
try {
|
|
468
|
+
const config = await this.integrationService.getSingleActiveConfig(
|
|
469
|
+
levelId,
|
|
470
|
+
levelType,
|
|
471
|
+
appCode,
|
|
472
|
+
integrationType,
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
if (!config) {
|
|
476
|
+
return {
|
|
477
|
+
success: false,
|
|
478
|
+
message: 'No active configuration found',
|
|
479
|
+
data: null,
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
return {
|
|
484
|
+
success: true,
|
|
485
|
+
data: config,
|
|
486
|
+
};
|
|
487
|
+
} catch (error) {
|
|
488
|
+
throw new BadRequestException({
|
|
489
|
+
success: false,
|
|
490
|
+
error: 'GET_ACTIVE_CONFIG_ERROR',
|
|
491
|
+
message: error.message || 'Failed to fetch active configuration',
|
|
492
|
+
code: 'FETCH_ERROR',
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
432
496
|
}
|
|
@@ -12,6 +12,6 @@ export class IntegrationSource extends BaseEntity {
|
|
|
12
12
|
@Column({ name: 'integration_type', type: 'varchar', length: 20 })
|
|
13
13
|
integration_type: string;
|
|
14
14
|
|
|
15
|
-
@Column({ name: 'description', type: 'varchar', length:
|
|
15
|
+
@Column({ name: 'description', type: 'varchar', length: 500 })
|
|
16
16
|
description: string;
|
|
17
17
|
}
|
|
@@ -170,6 +170,27 @@ export class IntegrationService {
|
|
|
170
170
|
return await queryBuilder.getMany();
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
async getSingleActiveConfig(
|
|
174
|
+
levelId: number,
|
|
175
|
+
levelType: string,
|
|
176
|
+
app_code: string,
|
|
177
|
+
integration_type: 'EMAIL' | 'SMS' | 'WA' | 'TELEPHONE',
|
|
178
|
+
): Promise<IntegrationConfig | null> {
|
|
179
|
+
const configs = await this.configRepository
|
|
180
|
+
.createQueryBuilder('config')
|
|
181
|
+
.where('config.level_id = :levelId', { levelId })
|
|
182
|
+
.andWhere('config.level_type = :levelType', { levelType })
|
|
183
|
+
.andWhere('config.app_code = :app_code', { app_code })
|
|
184
|
+
.andWhere('config.integration_type = :integration_type', { integration_type })
|
|
185
|
+
.andWhere('config.status = 1')
|
|
186
|
+
.orderBy('config.is_default', 'DESC')
|
|
187
|
+
.addOrderBy('config.priority', 'ASC')
|
|
188
|
+
.addOrderBy('config.created_at', 'DESC')
|
|
189
|
+
.getMany();
|
|
190
|
+
|
|
191
|
+
return configs.length > 0 ? configs[0] : null;
|
|
192
|
+
}
|
|
193
|
+
|
|
173
194
|
async getAllIntegrationData(
|
|
174
195
|
loggedInUser,
|
|
175
196
|
integration_type?: string,
|
|
@@ -23,12 +23,19 @@ export class NotificationsController {
|
|
|
23
23
|
|
|
24
24
|
@Post('send')
|
|
25
25
|
async sendNotification(
|
|
26
|
-
@Body()
|
|
26
|
+
@Body()
|
|
27
|
+
body: {
|
|
28
|
+
token: string;
|
|
29
|
+
title: string;
|
|
30
|
+
message: string;
|
|
31
|
+
data?: Record<string, any>;
|
|
32
|
+
},
|
|
27
33
|
) {
|
|
28
34
|
return this.notificationsService.sendToDevice(
|
|
29
35
|
body.token,
|
|
30
36
|
body.title,
|
|
31
37
|
body.message,
|
|
38
|
+
body.data,
|
|
32
39
|
);
|
|
33
40
|
}
|
|
34
41
|
|
|
@@ -20,13 +20,28 @@ export class NotificationsService {
|
|
|
20
20
|
return { success: true, token };
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async sendToDevice(
|
|
24
|
-
|
|
23
|
+
async sendToDevice(
|
|
24
|
+
token: string,
|
|
25
|
+
title: string,
|
|
26
|
+
body: string,
|
|
27
|
+
data?: Record<string, any>,
|
|
28
|
+
) {
|
|
29
|
+
const message: admin.messaging.Message = {
|
|
25
30
|
token,
|
|
26
|
-
notification: { title, body },
|
|
31
|
+
notification: { title, body }, // system notification
|
|
32
|
+
data: data
|
|
33
|
+
? Object.fromEntries(
|
|
34
|
+
Object.entries(data).map(([k, v]) => [k, v.toString()]),
|
|
35
|
+
)
|
|
36
|
+
: undefined, // FCM requires all values to be strings
|
|
27
37
|
};
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
try {
|
|
40
|
+
return await this.firebaseAdmin.messaging().send(message);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error(error);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
30
45
|
}
|
|
31
46
|
|
|
32
47
|
// Helper: send to a registered user by userId
|