rez_core 2.2.180 → 2.2.181
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/communication/controller/communication.controller.d.ts +4 -1
- package/dist/module/communication/controller/communication.controller.js +2 -2
- package/dist/module/communication/controller/communication.controller.js.map +1 -1
- package/dist/module/communication/service/communication.service.d.ts +6 -1
- package/dist/module/communication/service/communication.service.js +191 -2
- package/dist/module/communication/service/communication.service.js.map +1 -1
- package/dist/module/user/controller/user.controller.js +0 -1
- package/dist/module/user/controller/user.controller.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/communication/controller/communication.controller.ts +2 -2
- package/src/module/communication/service/communication.service.ts +265 -3
- package/src/module/user/controller/user.controller.ts +0 -1
package/package.json
CHANGED
|
@@ -112,10 +112,10 @@ export class CommunicationController {
|
|
|
112
112
|
@HttpCode(HttpStatus.OK)
|
|
113
113
|
async activateConfig(
|
|
114
114
|
@Param('id', ParseIntPipe) hubId: number,
|
|
115
|
-
@
|
|
115
|
+
@Query('status') status: number,
|
|
116
116
|
) {
|
|
117
117
|
await this.communicationService.updateConfigStatus(hubId, status);
|
|
118
|
-
return { message: 'Configuration
|
|
118
|
+
return { message: 'Configuration updated' };
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
@Post('gmail/oauth/init')
|
|
@@ -327,8 +327,8 @@ export class CommunicationService {
|
|
|
327
327
|
service?: 'API' | 'THIRD_PARTY' | 'SMTP';
|
|
328
328
|
provider?: string;
|
|
329
329
|
},
|
|
330
|
-
): Promise<CommunicationHub
|
|
331
|
-
const where: any = { level_id: levelId, level_type: levelType };
|
|
330
|
+
): Promise<Array<CommunicationHub & { linkedSource?: string; configDetails?: any }>> {
|
|
331
|
+
const where: any = { level_id: levelId, level_type: levelType, status: 1 };
|
|
332
332
|
|
|
333
333
|
if (filters?.communication_config_type) {
|
|
334
334
|
where.communication_config_type = filters.communication_config_type;
|
|
@@ -342,10 +342,272 @@ export class CommunicationService {
|
|
|
342
342
|
where.provider = filters.provider;
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
const hubs = await this.hubRepository.find({
|
|
346
346
|
where,
|
|
347
347
|
order: { created_at: 'DESC' },
|
|
348
348
|
});
|
|
349
|
+
|
|
350
|
+
// Enhance hubs with linked source information
|
|
351
|
+
const enhancedHubs = await Promise.all(
|
|
352
|
+
hubs.map(async (hub) => {
|
|
353
|
+
try {
|
|
354
|
+
const config = await this.configRepository.findOne({
|
|
355
|
+
where: { id: hub.config_id },
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
if (!config) {
|
|
359
|
+
return {
|
|
360
|
+
...hub,
|
|
361
|
+
linkedSource: 'Configuration not found',
|
|
362
|
+
configDetails: null,
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const linkedSource = this.extractLinkedSource(
|
|
367
|
+
hub.communication_config_type,
|
|
368
|
+
hub.service,
|
|
369
|
+
hub.provider,
|
|
370
|
+
config.config_json,
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
const configDetails = this.extractConfigDetails(
|
|
374
|
+
hub.communication_config_type,
|
|
375
|
+
hub.service,
|
|
376
|
+
hub.provider,
|
|
377
|
+
config.config_json,
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
return {
|
|
381
|
+
...hub,
|
|
382
|
+
linkedSource,
|
|
383
|
+
configDetails,
|
|
384
|
+
};
|
|
385
|
+
} catch (error) {
|
|
386
|
+
this.logger.warn(
|
|
387
|
+
`Error extracting linked source for hub ${hub.id}:`,
|
|
388
|
+
error.message,
|
|
389
|
+
);
|
|
390
|
+
return {
|
|
391
|
+
...hub,
|
|
392
|
+
linkedSource: 'Error retrieving source',
|
|
393
|
+
configDetails: null,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
}),
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
return enhancedHubs;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
private extractLinkedSource(
|
|
403
|
+
configType: string,
|
|
404
|
+
service: string,
|
|
405
|
+
provider: string,
|
|
406
|
+
configJson: any,
|
|
407
|
+
): string {
|
|
408
|
+
const key = `${configType.toLowerCase()}_${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
409
|
+
|
|
410
|
+
try {
|
|
411
|
+
switch (key) {
|
|
412
|
+
// Gmail configurations
|
|
413
|
+
case 'email_api_gmail':
|
|
414
|
+
case 'email_smtp_gmail':
|
|
415
|
+
return configJson?.email || 'Gmail account not configured';
|
|
416
|
+
|
|
417
|
+
// Outlook configurations
|
|
418
|
+
case 'email_api_outlook':
|
|
419
|
+
case 'email_smtp_outlook':
|
|
420
|
+
return configJson?.email || 'Outlook account not configured';
|
|
421
|
+
|
|
422
|
+
// WhatsApp configurations
|
|
423
|
+
case 'wa_api_whatsapp':
|
|
424
|
+
return configJson?.phoneNumberId
|
|
425
|
+
? `WhatsApp Business: ${configJson.phoneNumberId}`
|
|
426
|
+
: 'WhatsApp not configured';
|
|
427
|
+
|
|
428
|
+
// SMS configurations
|
|
429
|
+
case 'sms_third_party_twilio':
|
|
430
|
+
return configJson?.fromNumber
|
|
431
|
+
? `Twilio: ${configJson.fromNumber}`
|
|
432
|
+
: 'Twilio number not configured';
|
|
433
|
+
|
|
434
|
+
case 'sms_third_party_knowlarity':
|
|
435
|
+
return configJson?.callerNumber
|
|
436
|
+
? `Knowlarity: ${configJson.callerNumber}`
|
|
437
|
+
: 'Knowlarity number not configured';
|
|
438
|
+
|
|
439
|
+
// Telephone configurations
|
|
440
|
+
case 'telephone_third_party_knowlarity':
|
|
441
|
+
return configJson?.callerNumber
|
|
442
|
+
? `Knowlarity Voice: ${configJson.callerNumber}`
|
|
443
|
+
: 'Knowlarity voice number not configured';
|
|
444
|
+
|
|
445
|
+
// AWS SES configurations
|
|
446
|
+
case 'email_api_aws-ses':
|
|
447
|
+
case 'email_api_ses':
|
|
448
|
+
return configJson?.fromEmail || 'AWS SES not configured';
|
|
449
|
+
|
|
450
|
+
// SendGrid configurations
|
|
451
|
+
case 'email_smtp_sendgrid':
|
|
452
|
+
return configJson?.from || 'SendGrid not configured';
|
|
453
|
+
|
|
454
|
+
// Generic SMTP configurations
|
|
455
|
+
case 'email_smtp_custom':
|
|
456
|
+
case 'email_smtp_generic':
|
|
457
|
+
return configJson?.from || configJson?.user || 'SMTP not configured';
|
|
458
|
+
|
|
459
|
+
default:
|
|
460
|
+
// Generic fallback - try to find common identifier fields
|
|
461
|
+
if (configJson?.email) return configJson.email;
|
|
462
|
+
if (configJson?.from) return configJson.from;
|
|
463
|
+
if (configJson?.user) return configJson.user;
|
|
464
|
+
if (configJson?.phoneNumberId) return configJson.phoneNumberId;
|
|
465
|
+
if (configJson?.fromNumber) return configJson.fromNumber;
|
|
466
|
+
if (configJson?.callerNumber) return configJson.callerNumber;
|
|
467
|
+
|
|
468
|
+
return `${provider} configured`;
|
|
469
|
+
}
|
|
470
|
+
} catch (error) {
|
|
471
|
+
return 'Configuration error';
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
private extractConfigDetails(
|
|
476
|
+
configType: string,
|
|
477
|
+
service: string,
|
|
478
|
+
provider: string,
|
|
479
|
+
configJson: any,
|
|
480
|
+
): any {
|
|
481
|
+
const key = `${configType.toLowerCase()}_${service.toLowerCase()}_${provider.toLowerCase()}`;
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
switch (key) {
|
|
485
|
+
// Gmail configurations
|
|
486
|
+
case 'email_api_gmail':
|
|
487
|
+
return {
|
|
488
|
+
email: configJson?.email,
|
|
489
|
+
authMethod: configJson?.authMethod || 'OAUTH2',
|
|
490
|
+
hasRefreshToken: !!configJson?.refreshToken,
|
|
491
|
+
isExpired: configJson?.expiryDate ? new Date(configJson.expiryDate) < new Date() : false,
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
case 'email_smtp_gmail':
|
|
495
|
+
return {
|
|
496
|
+
email: configJson?.email,
|
|
497
|
+
authMethod: 'SMTP',
|
|
498
|
+
hasPassword: !!configJson?.password,
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// Outlook configurations
|
|
502
|
+
case 'email_api_outlook':
|
|
503
|
+
return {
|
|
504
|
+
email: configJson?.email,
|
|
505
|
+
authMethod: 'OAUTH2',
|
|
506
|
+
hasRefreshToken: !!configJson?.refreshToken,
|
|
507
|
+
tenantId: configJson?.tenantId,
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
case 'email_smtp_outlook':
|
|
511
|
+
return {
|
|
512
|
+
email: configJson?.email,
|
|
513
|
+
authMethod: 'SMTP',
|
|
514
|
+
hasPassword: !!configJson?.password,
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
// WhatsApp configurations
|
|
518
|
+
case 'wa_api_whatsapp':
|
|
519
|
+
return {
|
|
520
|
+
phoneNumberId: configJson?.phoneNumberId,
|
|
521
|
+
apiVersion: configJson?.apiVersion || 'v17.0',
|
|
522
|
+
hasAccessToken: !!configJson?.accessToken,
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
// SMS configurations
|
|
526
|
+
case 'sms_third_party_twilio':
|
|
527
|
+
return {
|
|
528
|
+
fromNumber: configJson?.fromNumber,
|
|
529
|
+
accountSid: configJson?.accountSid ? configJson.accountSid.substring(0, 8) + '...' : null,
|
|
530
|
+
hasAuthToken: !!configJson?.authToken,
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
case 'sms_third_party_knowlarity':
|
|
534
|
+
return {
|
|
535
|
+
callerNumber: configJson?.callerNumber,
|
|
536
|
+
callType: configJson?.callType || 'sms',
|
|
537
|
+
hasApiSecret: !!configJson?.apiSecret,
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
// Telephone configurations
|
|
541
|
+
case 'telephone_third_party_knowlarity':
|
|
542
|
+
return {
|
|
543
|
+
callerNumber: configJson?.callerNumber,
|
|
544
|
+
callType: configJson?.callType || 'voice',
|
|
545
|
+
language: configJson?.language || 'en',
|
|
546
|
+
hasApiSecret: !!configJson?.apiSecret,
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
// AWS SES configurations
|
|
550
|
+
case 'email_api_aws-ses':
|
|
551
|
+
case 'email_api_ses':
|
|
552
|
+
return {
|
|
553
|
+
fromEmail: configJson?.fromEmail,
|
|
554
|
+
region: configJson?.region,
|
|
555
|
+
hasCredentials: !!(configJson?.accessKeyId && configJson?.secretAccessKey),
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
// SendGrid configurations
|
|
559
|
+
case 'email_smtp_sendgrid':
|
|
560
|
+
return {
|
|
561
|
+
from: configJson?.from,
|
|
562
|
+
hasApiKey: !!configJson?.apiKey,
|
|
563
|
+
templateId: configJson?.templateId,
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// Generic SMTP configurations
|
|
567
|
+
case 'email_smtp_custom':
|
|
568
|
+
case 'email_smtp_generic':
|
|
569
|
+
return {
|
|
570
|
+
host: configJson?.host,
|
|
571
|
+
port: configJson?.port || 587,
|
|
572
|
+
secure: configJson?.secure || false,
|
|
573
|
+
from: configJson?.from || configJson?.user,
|
|
574
|
+
hasCredentials: !!(configJson?.user && configJson?.password),
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
default:
|
|
578
|
+
// Generic details - return safe subset of config
|
|
579
|
+
const safeConfig: any = {};
|
|
580
|
+
|
|
581
|
+
// Include non-sensitive fields
|
|
582
|
+
const safeFields = [
|
|
583
|
+
'email', 'from', 'user', 'host', 'port', 'secure',
|
|
584
|
+
'phoneNumberId', 'fromNumber', 'callerNumber', 'region',
|
|
585
|
+
'apiVersion', 'callType', 'language', 'templateId'
|
|
586
|
+
];
|
|
587
|
+
|
|
588
|
+
safeFields.forEach(field => {
|
|
589
|
+
if (configJson?.[field]) {
|
|
590
|
+
safeConfig[field] = configJson[field];
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// Include boolean indicators for sensitive fields
|
|
595
|
+
const sensitiveFields = [
|
|
596
|
+
'accessToken', 'refreshToken', 'password', 'authToken',
|
|
597
|
+
'apiKey', 'apiSecret', 'clientSecret', 'secretAccessKey'
|
|
598
|
+
];
|
|
599
|
+
|
|
600
|
+
sensitiveFields.forEach(field => {
|
|
601
|
+
if (configJson?.[field]) {
|
|
602
|
+
safeConfig[`has${field.charAt(0).toUpperCase() + field.slice(1)}`] = true;
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
return safeConfig;
|
|
607
|
+
}
|
|
608
|
+
} catch (error) {
|
|
609
|
+
return { error: 'Unable to extract configuration details' };
|
|
610
|
+
}
|
|
349
611
|
}
|
|
350
612
|
|
|
351
613
|
async updateConfigStatus(hubId: number, status: number): Promise<void> {
|
|
@@ -31,7 +31,6 @@ export class UserController {
|
|
|
31
31
|
@HttpCode(HttpStatus.OK)
|
|
32
32
|
async checkEmail(@Body() body, @Res() res: Response) {
|
|
33
33
|
const { email_id, subdomain } = body;
|
|
34
|
-
console.log(body, 'body-----------------------------body');
|
|
35
34
|
const result = await this.userService.checkEmailExists({
|
|
36
35
|
email_id,
|
|
37
36
|
subdomain,
|