rez_core 5.0.220 → 5.0.221
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/service/integration.service.js +3 -0
- package/dist/module/integration/service/integration.service.js.map +1 -1
- package/dist/module/integration/strategies/email/gmail-api.strategy.js +23 -7
- package/dist/module/integration/strategies/email/gmail-api.strategy.js.map +1 -1
- package/dist/module/meta/service/resolver.service.js +1 -1
- package/dist/module/meta/service/resolver.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/integration/service/integration.service.ts +4 -0
- package/src/module/integration/strategies/email/gmail-api.strategy.ts +45 -19
- package/src/module/meta/service/resolver.service.ts +2 -1
package/package.json
CHANGED
|
@@ -1544,6 +1544,9 @@ export class IntegrationService {
|
|
|
1544
1544
|
const oauth2 = google.oauth2({ version: 'v2', auth: oauth2Client });
|
|
1545
1545
|
const userInfo = await oauth2.userinfo.get();
|
|
1546
1546
|
const email = userInfo.data.email;
|
|
1547
|
+
console.log('userInfo', userInfo);
|
|
1548
|
+
|
|
1549
|
+
const fromName = userInfo.data.name || email;
|
|
1547
1550
|
|
|
1548
1551
|
if (!email) {
|
|
1549
1552
|
throw new Error('Failed to get user email');
|
|
@@ -1558,6 +1561,7 @@ export class IntegrationService {
|
|
|
1558
1561
|
clientId,
|
|
1559
1562
|
clientSecret,
|
|
1560
1563
|
email: email,
|
|
1564
|
+
fromName,
|
|
1561
1565
|
accessToken: tokens.access_token,
|
|
1562
1566
|
refreshToken: tokens.refresh_token,
|
|
1563
1567
|
scope: tokens.scope,
|
|
@@ -10,8 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
@Injectable()
|
|
12
12
|
export class GmailApiStrategy implements IntegrationStrategy {
|
|
13
|
-
constructor(private readonly configService: ConfigService) {
|
|
14
|
-
}
|
|
13
|
+
constructor(private readonly configService: ConfigService) {}
|
|
15
14
|
|
|
16
15
|
async sendMessage(
|
|
17
16
|
to: string | string[],
|
|
@@ -45,23 +44,30 @@ export class GmailApiStrategy implements IntegrationStrategy {
|
|
|
45
44
|
: bcc
|
|
46
45
|
: undefined;
|
|
47
46
|
|
|
47
|
+
const fromEmail = config.email;
|
|
48
|
+
const fromName = config.fromName;
|
|
49
|
+
|
|
48
50
|
const emailContent =
|
|
49
51
|
attachments && attachments.length > 0
|
|
50
52
|
? this.buildMultipartEmail(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
toRecipients,
|
|
54
|
+
ccRecipients,
|
|
55
|
+
bccRecipients,
|
|
56
|
+
subject,
|
|
57
|
+
config.richText || message,
|
|
58
|
+
attachments,
|
|
59
|
+
fromEmail,
|
|
60
|
+
fromName,
|
|
61
|
+
)
|
|
58
62
|
: this.buildSimpleEmail(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
toRecipients,
|
|
64
|
+
ccRecipients,
|
|
65
|
+
bccRecipients,
|
|
66
|
+
subject,
|
|
67
|
+
config.richText || message,
|
|
68
|
+
fromEmail,
|
|
69
|
+
fromName,
|
|
70
|
+
);
|
|
65
71
|
|
|
66
72
|
const encodedMessage = Buffer.from(emailContent)
|
|
67
73
|
.toString('base64')
|
|
@@ -85,7 +91,7 @@ export class GmailApiStrategy implements IntegrationStrategy {
|
|
|
85
91
|
provider: 'gmail',
|
|
86
92
|
service: 'API',
|
|
87
93
|
timestamp: new Date(),
|
|
88
|
-
message:
|
|
94
|
+
message: 'Email sent successfully',
|
|
89
95
|
};
|
|
90
96
|
} catch (error) {
|
|
91
97
|
console.error('---- Gmail SDK API Error ----');
|
|
@@ -202,8 +208,18 @@ export class GmailApiStrategy implements IntegrationStrategy {
|
|
|
202
208
|
bcc?: string,
|
|
203
209
|
subject?: string,
|
|
204
210
|
message?: string,
|
|
211
|
+
fromEmail?: string,
|
|
212
|
+
fromName?: string,
|
|
205
213
|
): string {
|
|
206
|
-
const
|
|
214
|
+
const fromHeader = fromEmail
|
|
215
|
+
? `From: "${fromName || fromEmail}" <${fromEmail}>`
|
|
216
|
+
: undefined;
|
|
217
|
+
|
|
218
|
+
const emailLines = [
|
|
219
|
+
...(fromHeader ? [fromHeader] : []),
|
|
220
|
+
`To: ${to}`,
|
|
221
|
+
`Subject: ${subject || 'Notification'}`,
|
|
222
|
+
];
|
|
207
223
|
|
|
208
224
|
if (cc) {
|
|
209
225
|
emailLines.push(`Cc: ${cc}`);
|
|
@@ -228,10 +244,20 @@ export class GmailApiStrategy implements IntegrationStrategy {
|
|
|
228
244
|
subject?: string,
|
|
229
245
|
message?: string,
|
|
230
246
|
attachments?: EmailAttachment[],
|
|
247
|
+
fromEmail?: string,
|
|
248
|
+
fromName?: string,
|
|
231
249
|
): string {
|
|
232
250
|
const boundary = `----GmailBoundary${Date.now()}${Math.random().toString(36).substr(2, 9)}`;
|
|
233
251
|
|
|
234
|
-
const
|
|
252
|
+
const fromHeader = fromEmail
|
|
253
|
+
? `From: "${fromName || fromEmail}" <${fromEmail}>`
|
|
254
|
+
: undefined;
|
|
255
|
+
|
|
256
|
+
const emailLines = [
|
|
257
|
+
...(fromHeader ? [fromHeader] : []),
|
|
258
|
+
`To: ${to}`,
|
|
259
|
+
`Subject: ${subject || 'Notification'}`,
|
|
260
|
+
];
|
|
235
261
|
|
|
236
262
|
if (cc) {
|
|
237
263
|
emailLines.push(`Cc: ${cc}`);
|
|
@@ -278,4 +304,4 @@ export class GmailApiStrategy implements IntegrationStrategy {
|
|
|
278
304
|
|
|
279
305
|
return emailLines.join('\n');
|
|
280
306
|
}
|
|
281
|
-
}
|
|
307
|
+
}
|
|
@@ -75,7 +75,8 @@ export class ResolverService {
|
|
|
75
75
|
);
|
|
76
76
|
resolvedValues.push(item?.[attr.data_source_attribute] ?? code);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
// make resolved values to a comma separated string
|
|
79
|
+
resolvedEntityData[field] = resolvedValues.join(', ');
|
|
79
80
|
} else {
|
|
80
81
|
// if we r resolving a ListMaster then we get the name of the item from ListMasterItems table directly
|
|
81
82
|
if (
|