rez_core 2.2.197 → 2.2.199
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 +1 -1
- package/dist/module/communication/controller/communication.controller.js +1 -1
- package/dist/module/communication/controller/communication.controller.js.map +1 -1
- package/dist/module/communication/dto/create-config.dto.d.ts +1 -2
- package/dist/module/communication/dto/create-config.dto.js +1 -6
- package/dist/module/communication/dto/create-config.dto.js.map +1 -1
- package/dist/module/communication/service/communication.service.d.ts +1 -1
- package/dist/module/communication/service/communication.service.js +6 -14
- package/dist/module/communication/service/communication.service.js.map +1 -1
- package/dist/module/communication/service/wrapper.service.js +3 -3
- package/dist/module/communication/service/wrapper.service.js.map +1 -1
- package/dist/module/notification/controller/otp.controller.d.ts +2 -1
- package/dist/module/notification/controller/otp.controller.js +18 -3
- package/dist/module/notification/controller/otp.controller.js.map +1 -1
- package/dist/module/notification/service/otp.service.d.ts +3 -0
- package/dist/module/notification/service/otp.service.js +7 -4
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/user/entity/user.entity.d.ts +3 -0
- package/dist/module/user/entity/user.entity.js +12 -0
- package/dist/module/user/entity/user.entity.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +3 -0
- package/dist/module/user/service/login.service.js +10 -1
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.d.ts +1 -3
- package/dist/module/workflow/service/task.service.js +2 -5
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/module/communication/controller/communication.controller.ts +2 -7
- package/src/module/communication/dto/create-config.dto.ts +1 -5
- package/src/module/communication/service/communication.service.ts +19 -30
- package/src/module/communication/service/wrapper.service.ts +3 -3
- package/src/module/notification/controller/otp.controller.ts +20 -1
- package/src/module/notification/service/otp.service.ts +11 -4
- package/src/module/user/entity/user.entity.ts +9 -0
- package/src/module/user/service/login.service.ts +25 -1
- package/src/module/workflow/service/task.service.ts +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rez_core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.199",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "",
|
|
6
6
|
"private": false,
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"rxjs": "^7.8.1",
|
|
63
63
|
"twilio": "^5.9.0",
|
|
64
64
|
"typeorm": "^0.3.20",
|
|
65
|
+
"ua-parser-js": "^2.0.5",
|
|
65
66
|
"uuid": "^11.1.0",
|
|
66
67
|
"winston": "^3.17.0",
|
|
67
68
|
"xlsx": "^0.18.5"
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
Param,
|
|
9
9
|
ParseIntPipe,
|
|
10
10
|
Post,
|
|
11
|
-
Put,
|
|
12
11
|
Query,
|
|
13
12
|
} from '@nestjs/common';
|
|
14
13
|
import { CommunicationService } from '../service/communication.service';
|
|
@@ -18,10 +17,9 @@ import {
|
|
|
18
17
|
GenericSendMessageDto,
|
|
19
18
|
GmailOAuthInitDto,
|
|
20
19
|
OutlookOAuthInitDto,
|
|
21
|
-
SendGridVerifiedSendersDto,
|
|
22
20
|
SendGridTemplatesDto,
|
|
21
|
+
SendGridVerifiedSendersDto,
|
|
23
22
|
UpdateConfigDto,
|
|
24
|
-
UpdateConfigStatusDto,
|
|
25
23
|
} from '../dto/create-config.dto';
|
|
26
24
|
|
|
27
25
|
export class ScheduledMessageDto extends GenericSendMessageDto {
|
|
@@ -232,10 +230,7 @@ export class CommunicationController {
|
|
|
232
230
|
@Post('sendgrid/verified-senders')
|
|
233
231
|
@HttpCode(HttpStatus.OK)
|
|
234
232
|
async getSendGridVerifiedSenders(@Body() dto: SendGridVerifiedSendersDto) {
|
|
235
|
-
return this.communicationService.getSendGridVerifiedSenders(
|
|
236
|
-
dto.levelId,
|
|
237
|
-
dto.levelType,
|
|
238
|
-
);
|
|
233
|
+
return this.communicationService.getSendGridVerifiedSenders(dto.apiKey);
|
|
239
234
|
}
|
|
240
235
|
|
|
241
236
|
@Post('sendgrid/templates')
|
|
@@ -324,13 +324,9 @@ export class OutlookOAuthInitDto {
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
export class SendGridVerifiedSendersDto {
|
|
327
|
-
@IsNotEmpty()
|
|
328
|
-
@IsNumber()
|
|
329
|
-
levelId: number;
|
|
330
|
-
|
|
331
327
|
@IsNotEmpty()
|
|
332
328
|
@IsString()
|
|
333
|
-
|
|
329
|
+
apiKey: string;
|
|
334
330
|
}
|
|
335
331
|
|
|
336
332
|
export class SendGridTemplatesDto {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common';
|
|
2
2
|
import { InjectRepository } from '@nestjs/typeorm';
|
|
3
|
-
import {
|
|
3
|
+
import { Not, Repository } from 'typeorm';
|
|
4
4
|
import { ConfigService } from '@nestjs/config';
|
|
5
5
|
import { google } from 'googleapis';
|
|
6
6
|
import {
|
|
@@ -923,7 +923,10 @@ export class CommunicationService {
|
|
|
923
923
|
// Process template if provided
|
|
924
924
|
let processedMessage = message;
|
|
925
925
|
if (templateId && variables) {
|
|
926
|
-
processedMessage = this.processTemplate(
|
|
926
|
+
processedMessage = this.processTemplate(
|
|
927
|
+
html ? html : message,
|
|
928
|
+
variables,
|
|
929
|
+
);
|
|
927
930
|
}
|
|
928
931
|
|
|
929
932
|
// Merge config with enhanced parameters
|
|
@@ -1467,7 +1470,8 @@ export class CommunicationService {
|
|
|
1467
1470
|
excludeHubId?: number,
|
|
1468
1471
|
): Promise<void> {
|
|
1469
1472
|
// Find all active configurations of the same type for this level
|
|
1470
|
-
const query = this.hubRepository
|
|
1473
|
+
const query = this.hubRepository
|
|
1474
|
+
.createQueryBuilder('hub')
|
|
1471
1475
|
.where('hub.level_id = :levelId', { levelId })
|
|
1472
1476
|
.andWhere('hub.level_type = :levelType', { levelType })
|
|
1473
1477
|
.andWhere('hub.communication_config_type = :configType', { configType })
|
|
@@ -1490,7 +1494,7 @@ export class CommunicationService {
|
|
|
1490
1494
|
status: 1,
|
|
1491
1495
|
...(excludeHubId && { id: Not(excludeHubId) }),
|
|
1492
1496
|
},
|
|
1493
|
-
{ status: 0 } // Deactivate
|
|
1497
|
+
{ status: 0 }, // Deactivate
|
|
1494
1498
|
);
|
|
1495
1499
|
|
|
1496
1500
|
this.logger.log(
|
|
@@ -1875,11 +1879,15 @@ export class CommunicationService {
|
|
|
1875
1879
|
}> {
|
|
1876
1880
|
try {
|
|
1877
1881
|
// Find active SendGrid configurations for this level
|
|
1878
|
-
const hubs = await this.getActiveHubs(
|
|
1879
|
-
|
|
1882
|
+
const hubs = await this.getActiveHubs(
|
|
1883
|
+
levelId,
|
|
1884
|
+
levelType,
|
|
1885
|
+
CommunicationConfigType.EMAIL,
|
|
1886
|
+
);
|
|
1887
|
+
|
|
1880
1888
|
// Look for SendGrid provider
|
|
1881
|
-
const sendGridHub = hubs.find(hub => hub.provider === 'sendgrid');
|
|
1882
|
-
|
|
1889
|
+
const sendGridHub = hubs.find((hub) => hub.provider === 'sendgrid');
|
|
1890
|
+
|
|
1883
1891
|
if (!sendGridHub) {
|
|
1884
1892
|
return {
|
|
1885
1893
|
success: false,
|
|
@@ -1889,7 +1897,7 @@ export class CommunicationService {
|
|
|
1889
1897
|
|
|
1890
1898
|
// Extract API key from configuration
|
|
1891
1899
|
const apiKey = sendGridHub.config?.config_json?.apiKey;
|
|
1892
|
-
|
|
1900
|
+
|
|
1893
1901
|
if (!apiKey) {
|
|
1894
1902
|
return {
|
|
1895
1903
|
success: false,
|
|
@@ -1911,10 +1919,7 @@ export class CommunicationService {
|
|
|
1911
1919
|
}
|
|
1912
1920
|
}
|
|
1913
1921
|
|
|
1914
|
-
async getSendGridVerifiedSenders(
|
|
1915
|
-
levelId: number,
|
|
1916
|
-
levelType: string,
|
|
1917
|
-
): Promise<{
|
|
1922
|
+
async getSendGridVerifiedSenders(apiKey: string): Promise<{
|
|
1918
1923
|
success: boolean;
|
|
1919
1924
|
data?: Array<{
|
|
1920
1925
|
label: string;
|
|
@@ -1923,22 +1928,6 @@ export class CommunicationService {
|
|
|
1923
1928
|
error?: string;
|
|
1924
1929
|
}> {
|
|
1925
1930
|
try {
|
|
1926
|
-
// Find active SendGrid configurations for this level
|
|
1927
|
-
const hubs = await this.getActiveHubs(levelId, levelType, CommunicationConfigType.EMAIL);
|
|
1928
|
-
|
|
1929
|
-
// Look for SendGrid provider
|
|
1930
|
-
const sendGridHub = hubs.find(hub => hub.provider === 'sendgrid');
|
|
1931
|
-
|
|
1932
|
-
if (!sendGridHub) {
|
|
1933
|
-
return {
|
|
1934
|
-
success: false,
|
|
1935
|
-
error: 'No active SendGrid configuration found for this level',
|
|
1936
|
-
};
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
// Extract API key from configuration
|
|
1940
|
-
const apiKey = sendGridHub.config?.config_json?.apiKey;
|
|
1941
|
-
|
|
1942
1931
|
if (!apiKey) {
|
|
1943
1932
|
return {
|
|
1944
1933
|
success: false,
|
|
@@ -1950,7 +1939,7 @@ export class CommunicationService {
|
|
|
1950
1939
|
return this.sendGridApiStrategy.getVerifiedSenders(apiKey);
|
|
1951
1940
|
} catch (error) {
|
|
1952
1941
|
this.logger.error(
|
|
1953
|
-
`Error fetching SendGrid verified senders
|
|
1942
|
+
`Error fetching SendGrid verified senders`,
|
|
1954
1943
|
error.message,
|
|
1955
1944
|
);
|
|
1956
1945
|
return {
|
|
@@ -40,12 +40,12 @@ export class WrapperService {
|
|
|
40
40
|
if (payload.templateCode) {
|
|
41
41
|
// Try current level first
|
|
42
42
|
const template = await this.datasource.query(
|
|
43
|
-
`SELECT
|
|
43
|
+
`SELECT rich_text FROM cr_wf_comm_template WHERE code = ? AND level_id = ? AND level_type = ? LIMIT 1`,
|
|
44
44
|
[payload.templateCode, level_id, level_type],
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
if (template && template.length > 0) {
|
|
48
|
-
templateCode = template[0].
|
|
48
|
+
templateCode = template[0].rich_text;
|
|
49
49
|
} else {
|
|
50
50
|
// Fallback → ORG level
|
|
51
51
|
const fallbackTemplate = await this.datasource.query(
|
|
@@ -75,7 +75,7 @@ export class WrapperService {
|
|
|
75
75
|
type: 'EMAIL',
|
|
76
76
|
cc: payload.cc,
|
|
77
77
|
bcc: payload.bcc,
|
|
78
|
-
html:
|
|
78
|
+
html: templateCode,
|
|
79
79
|
attachments: payload.attachments,
|
|
80
80
|
templateId: templateCode,
|
|
81
81
|
variables: payload.variables,
|
|
@@ -7,10 +7,13 @@ import {
|
|
|
7
7
|
HttpStatus,
|
|
8
8
|
Post,
|
|
9
9
|
Query,
|
|
10
|
+
Req,
|
|
10
11
|
} from '@nestjs/common';
|
|
11
12
|
import { OtpService } from '../service/otp.service';
|
|
12
13
|
import { ConfigService } from '@nestjs/config';
|
|
13
14
|
import { EmailService } from '../service/email.service';
|
|
15
|
+
import { UAParser } from 'ua-parser-js';
|
|
16
|
+
import { Request } from 'express';
|
|
14
17
|
|
|
15
18
|
@Controller('otp')
|
|
16
19
|
export class OtpController {
|
|
@@ -52,8 +55,24 @@ export class OtpController {
|
|
|
52
55
|
subdomain: string;
|
|
53
56
|
fcm_token: string;
|
|
54
57
|
},
|
|
58
|
+
@Req() req: Request,
|
|
55
59
|
) {
|
|
56
|
-
|
|
60
|
+
const ip =
|
|
61
|
+
(req.headers['x-forwarded-for'] as string)?.split(',')[0].trim() ||
|
|
62
|
+
req.socket.remoteAddress ||
|
|
63
|
+
req.ip ||
|
|
64
|
+
'';
|
|
65
|
+
|
|
66
|
+
const userAgent = req.headers['user-agent'] || '';
|
|
67
|
+
const parser = new UAParser(userAgent);
|
|
68
|
+
const browser = parser.getBrowser().name || 'Unknown';
|
|
69
|
+
const os = parser.getOS().name || 'Unknown';
|
|
70
|
+
return await this.otpService.verifyOtp({
|
|
71
|
+
...data,
|
|
72
|
+
ip,
|
|
73
|
+
browser,
|
|
74
|
+
os,
|
|
75
|
+
});
|
|
57
76
|
}
|
|
58
77
|
|
|
59
78
|
@Post('send-mail')
|
|
@@ -59,8 +59,12 @@ export class OtpService {
|
|
|
59
59
|
identifier: string;
|
|
60
60
|
subdomain: string;
|
|
61
61
|
fcm_token: string;
|
|
62
|
+
browser?: string;
|
|
63
|
+
ip?: string;
|
|
64
|
+
os?: string;
|
|
62
65
|
}) {
|
|
63
|
-
const { otp, otp_id, identifier, subdomain, fcm_token } =
|
|
66
|
+
const { otp, otp_id, identifier, subdomain, fcm_token, browser, ip, os } =
|
|
67
|
+
data;
|
|
64
68
|
const verifyOTPResponse = { isValid: false };
|
|
65
69
|
|
|
66
70
|
// Find OTP entity by ID
|
|
@@ -100,10 +104,13 @@ export class OtpService {
|
|
|
100
104
|
|
|
101
105
|
// Proceed to login
|
|
102
106
|
return this.loginService.login({
|
|
103
|
-
email:
|
|
107
|
+
email: identifier,
|
|
104
108
|
is_otp: true,
|
|
105
|
-
subdomain
|
|
106
|
-
fcm_token
|
|
109
|
+
subdomain,
|
|
110
|
+
fcm_token,
|
|
111
|
+
browser,
|
|
112
|
+
ip,
|
|
113
|
+
os,
|
|
107
114
|
});
|
|
108
115
|
}
|
|
109
116
|
|
|
@@ -56,4 +56,13 @@ export class UserData extends BaseEntity {
|
|
|
56
56
|
|
|
57
57
|
@Column({ type: 'varchar', nullable: true })
|
|
58
58
|
fcm_token: string;
|
|
59
|
+
|
|
60
|
+
@Column({ type: 'varchar', nullable: true })
|
|
61
|
+
browser: string;
|
|
62
|
+
|
|
63
|
+
@Column({ type: 'varchar', nullable: true })
|
|
64
|
+
ip: string;
|
|
65
|
+
|
|
66
|
+
@Column({ type: 'varchar', nullable: true })
|
|
67
|
+
os: string;
|
|
59
68
|
}
|
|
@@ -44,8 +44,20 @@ export class LoginService {
|
|
|
44
44
|
subdomain: string;
|
|
45
45
|
fcm_token: string;
|
|
46
46
|
is_otp?: boolean;
|
|
47
|
+
browser?: string;
|
|
48
|
+
ip?: string;
|
|
49
|
+
os?: string;
|
|
47
50
|
}) {
|
|
48
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
email,
|
|
53
|
+
password,
|
|
54
|
+
is_otp = false,
|
|
55
|
+
subdomain,
|
|
56
|
+
fcm_token,
|
|
57
|
+
browser,
|
|
58
|
+
ip,
|
|
59
|
+
os,
|
|
60
|
+
} = data;
|
|
49
61
|
|
|
50
62
|
let organization;
|
|
51
63
|
|
|
@@ -72,6 +84,18 @@ export class LoginService {
|
|
|
72
84
|
await this.userRepository.update({ id: user.id }, { fcm_token });
|
|
73
85
|
}
|
|
74
86
|
|
|
87
|
+
if (browser) {
|
|
88
|
+
await this.userRepository.update({ id: user.id }, { browser });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (ip) {
|
|
92
|
+
await this.userRepository.update({ id: user.id }, { ip });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (os) {
|
|
96
|
+
await this.userRepository.update({ id: user.id }, { os });
|
|
97
|
+
}
|
|
98
|
+
|
|
75
99
|
// 🔹 Step 3: Verify org status
|
|
76
100
|
const userOrgData = await this.organizationRepository.findOrganizationById(
|
|
77
101
|
user.organization_id,
|
|
@@ -8,8 +8,6 @@ import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
|
8
8
|
import { ActivityLogService } from './activity-log.service';
|
|
9
9
|
import { ACTIVITY_CATEGORIES } from '../repository/activity-log.repository';
|
|
10
10
|
import { MediaDataService } from 'src/module/meta/service/media-data.service';
|
|
11
|
-
// import { Cron, CronExpression } from '@nestjs/schedule';
|
|
12
|
-
import { NotificationsService } from 'src/module/notification/service/notification.service';
|
|
13
11
|
|
|
14
12
|
@Injectable()
|
|
15
13
|
export class TaskService extends EntityServiceImpl {
|
|
@@ -20,7 +18,6 @@ export class TaskService extends EntityServiceImpl {
|
|
|
20
18
|
@Inject('ActivityLogService')
|
|
21
19
|
private readonly activityLogService: ActivityLogService,
|
|
22
20
|
private readonly mediaDataService: MediaDataService,
|
|
23
|
-
private readonly notificationsService: NotificationsService, // 👈 inject here
|
|
24
21
|
) {
|
|
25
22
|
super();
|
|
26
23
|
}
|