rez_core 2.2.211 → 2.2.213
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/communication.module.js +11 -11
- package/dist/module/communication/communication.module.js.map +1 -1
- package/dist/module/communication/factories/email.factory.d.ts +6 -6
- package/dist/module/communication/factories/email.factory.js +9 -9
- package/dist/module/communication/factories/email.factory.js.map +1 -1
- package/dist/module/communication/factories/sms.factory.d.ts +2 -2
- package/dist/module/communication/factories/sms.factory.js +4 -4
- package/dist/module/communication/factories/sms.factory.js.map +1 -1
- package/dist/module/communication/factories/telephone.factory.d.ts +2 -2
- package/dist/module/communication/factories/telephone.factory.js +2 -2
- package/dist/module/communication/factories/telephone.factory.js.map +1 -1
- package/dist/module/communication/factories/whatsapp.factory.d.ts +1 -1
- package/dist/module/communication/factories/whatsapp.factory.js +1 -1
- package/dist/module/communication/factories/whatsapp.factory.js.map +1 -1
- package/dist/module/communication/service/communication.service.js +45 -39
- package/dist/module/communication/service/communication.service.js.map +1 -1
- package/dist/module/communication/service/wrapper.service.js +1 -1
- package/dist/module/communication/service/wrapper.service.js.map +1 -1
- package/dist/module/communication/strategies/communication.strategy.js.map +1 -1
- package/dist/module/communication/strategies/email/gmail-api.strategy.d.ts +1 -0
- package/dist/module/communication/strategies/email/gmail-api.strategy.js +53 -61
- package/dist/module/communication/strategies/email/gmail-api.strategy.js.map +1 -1
- package/dist/module/communication/strategies/{gmail-smtp.strategy.d.ts → email/gmail-smtp-v2.strategy.d.ts} +1 -1
- package/dist/module/communication/strategies/{gmail-smtp.strategy.js → email/gmail-smtp-v2.strategy.js} +1 -1
- package/dist/module/communication/strategies/email/gmail-smtp-v2.strategy.js.map +1 -0
- package/dist/module/communication/strategies/{outlook-smtp.strategy.d.ts → email/outlook-smtp.strategy.d.ts} +1 -1
- package/dist/module/communication/strategies/email/outlook-smtp.strategy.js.map +1 -0
- package/dist/module/communication/strategies/{outlook.strategy.d.ts → email/outlook.strategy.d.ts} +1 -1
- package/dist/module/communication/strategies/email/outlook.strategy.js.map +1 -0
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.js +1 -12
- package/dist/module/communication/strategies/email/sendgrid-api.strategy.js.map +1 -1
- package/dist/module/communication/strategies/{knowlarity.strategy.d.ts → sms/knowlarity-multi.strategy.d.ts} +1 -1
- package/dist/module/communication/strategies/{knowlarity.strategy.js → sms/knowlarity-multi.strategy.js} +1 -1
- package/dist/module/communication/strategies/sms/knowlarity-multi.strategy.js.map +1 -0
- package/dist/module/communication/strategies/{sms.strategy.d.ts → sms/twilio-v2.strategy.d.ts} +1 -1
- package/dist/module/communication/strategies/{sms.strategy.js → sms/twilio-v2.strategy.js} +1 -1
- package/dist/module/communication/strategies/sms/twilio-v2.strategy.js.map +1 -0
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.d.ts +6 -0
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.js +121 -0
- package/dist/module/communication/strategies/telephone/knowlarity-multi.strategy.js.map +1 -0
- package/dist/module/communication/strategies/{whatsapp.strategy.d.ts → whatsapp/whatsapp.strategy.d.ts} +1 -1
- package/dist/module/communication/strategies/whatsapp/whatsapp.strategy.js.map +1 -0
- package/dist/module/user/controller/login.controller.d.ts +1 -1
- package/dist/module/user/controller/login.controller.js +20 -2
- package/dist/module/user/controller/login.controller.js.map +1 -1
- package/dist/module/workflow/entity/task-data.entity.d.ts +1 -0
- package/dist/module/workflow/entity/task-data.entity.js +4 -0
- package/dist/module/workflow/entity/task-data.entity.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/communication/communication.module.ts +9 -9
- package/src/module/communication/factories/email.factory.ts +6 -6
- package/src/module/communication/factories/sms.factory.ts +2 -2
- package/src/module/communication/factories/telephone.factory.ts +2 -2
- package/src/module/communication/factories/whatsapp.factory.ts +1 -1
- package/src/module/communication/service/communication.service.ts +7 -3
- package/src/module/communication/service/wrapper.service.ts +1 -1
- package/src/module/communication/strategies/communication.strategy.ts +8 -2
- package/src/module/communication/strategies/email/gmail-api.strategy.ts +82 -79
- package/src/module/communication/strategies/{gmail-smtp.strategy.ts → email/gmail-smtp-v2.strategy.ts} +1 -1
- package/src/module/communication/strategies/{outlook-smtp.strategy.ts → email/outlook-smtp.strategy.ts} +1 -1
- package/src/module/communication/strategies/{outlook.strategy.ts → email/outlook.strategy.ts} +1 -1
- package/src/module/communication/strategies/email/sendgrid-api.strategy.ts +7 -9
- package/src/module/communication/strategies/{knowlarity.strategy.ts → sms/knowlarity-multi.strategy.ts} +1 -1
- package/src/module/communication/strategies/{sms.strategy.ts → sms/twilio-v2.strategy.ts} +1 -1
- package/src/module/communication/strategies/telephone/knowlarity-multi.strategy.ts +158 -0
- package/src/module/communication/strategies/{whatsapp.strategy.ts → whatsapp/whatsapp.strategy.ts} +1 -1
- package/src/module/user/controller/login.controller.ts +22 -2
- package/src/module/workflow/entity/task-data.entity.ts +3 -0
- package/dist/module/communication/strategies/gmail-smtp.strategy.js.map +0 -1
- package/dist/module/communication/strategies/gmail.strategy.d.ts +0 -8
- package/dist/module/communication/strategies/gmail.strategy.js +0 -100
- package/dist/module/communication/strategies/gmail.strategy.js.map +0 -1
- package/dist/module/communication/strategies/knowlarity.strategy.js.map +0 -1
- package/dist/module/communication/strategies/outlook-smtp.strategy.js.map +0 -1
- package/dist/module/communication/strategies/outlook.strategy.js.map +0 -1
- package/dist/module/communication/strategies/sms.strategy.js.map +0 -1
- package/dist/module/communication/strategies/whatsapp.strategy.js.map +0 -1
- package/src/module/communication/strategies/gmail.strategy.ts +0 -119
- /package/dist/module/communication/strategies/{outlook-smtp.strategy.js → email/outlook-smtp.strategy.js} +0 -0
- /package/dist/module/communication/strategies/{outlook.strategy.js → email/outlook.strategy.js} +0 -0
- /package/dist/module/communication/strategies/{whatsapp.strategy.js → whatsapp/whatsapp.strategy.js} +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import {
|
|
4
|
+
CommunicationStrategy,
|
|
5
|
+
CommunicationResult,
|
|
6
|
+
} from '../communication.strategy';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class KnowlarityStrategy implements CommunicationStrategy {
|
|
10
|
+
async sendMessage(
|
|
11
|
+
to: string,
|
|
12
|
+
message: string,
|
|
13
|
+
config: any,
|
|
14
|
+
): Promise<CommunicationResult> {
|
|
15
|
+
try {
|
|
16
|
+
const {
|
|
17
|
+
apiKey,
|
|
18
|
+
apiSecret,
|
|
19
|
+
callerNumber,
|
|
20
|
+
baseUrl = 'https://kpi.knowlarity.com/Basic',
|
|
21
|
+
callType = 'voice',
|
|
22
|
+
language = 'en',
|
|
23
|
+
} = config;
|
|
24
|
+
|
|
25
|
+
if (callType === 'voice') {
|
|
26
|
+
const callData = {
|
|
27
|
+
k_number: callerNumber,
|
|
28
|
+
agent_number: to,
|
|
29
|
+
caller_id: callerNumber,
|
|
30
|
+
voice_message: config.voiceMessage || message,
|
|
31
|
+
language: language,
|
|
32
|
+
api_key: apiKey,
|
|
33
|
+
api_secret: apiSecret,
|
|
34
|
+
format: 'json',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const response = await axios.post(
|
|
38
|
+
`${baseUrl}/start_call.php`,
|
|
39
|
+
callData,
|
|
40
|
+
{
|
|
41
|
+
headers: {
|
|
42
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
43
|
+
},
|
|
44
|
+
transformRequest: [
|
|
45
|
+
(data) => {
|
|
46
|
+
return Object.keys(data)
|
|
47
|
+
.map(
|
|
48
|
+
(key) =>
|
|
49
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`,
|
|
50
|
+
)
|
|
51
|
+
.join('&');
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
success: response.data.status === 'success',
|
|
59
|
+
provider: 'knowlarity',
|
|
60
|
+
service: 'THIRD_PARTY',
|
|
61
|
+
messageId: response.data.call_id,
|
|
62
|
+
timestamp: new Date(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (callType === 'sms') {
|
|
67
|
+
const smsData = {
|
|
68
|
+
k_number: callerNumber,
|
|
69
|
+
agent_number: to,
|
|
70
|
+
sms_text: message,
|
|
71
|
+
api_key: apiKey,
|
|
72
|
+
api_secret: apiSecret,
|
|
73
|
+
format: 'json',
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const response = await axios.post(`${baseUrl}/send_sms.php`, smsData, {
|
|
77
|
+
headers: {
|
|
78
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
79
|
+
},
|
|
80
|
+
transformRequest: [
|
|
81
|
+
(data) => {
|
|
82
|
+
return Object.keys(data)
|
|
83
|
+
.map(
|
|
84
|
+
(key) =>
|
|
85
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`,
|
|
86
|
+
)
|
|
87
|
+
.join('&');
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
success: response.data.status === 'success',
|
|
94
|
+
provider: 'knowlarity',
|
|
95
|
+
service: 'THIRD_PARTY',
|
|
96
|
+
messageId: response.data.message_id,
|
|
97
|
+
timestamp: new Date(),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
throw new Error('Invalid call type. Must be "voice" or "sms"');
|
|
102
|
+
} catch (error) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
provider: 'knowlarity',
|
|
106
|
+
service: 'THIRD_PARTY',
|
|
107
|
+
error: error.message,
|
|
108
|
+
timestamp: new Date(),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
validateConfig(config: any): boolean {
|
|
114
|
+
return !!(
|
|
115
|
+
config.apiKey &&
|
|
116
|
+
config.apiSecret &&
|
|
117
|
+
config.callerNumber &&
|
|
118
|
+
['voice', 'sms'].includes(config.callType)
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async getCallStatus(callId: string, config: any): Promise<any> {
|
|
123
|
+
const {
|
|
124
|
+
apiKey,
|
|
125
|
+
apiSecret,
|
|
126
|
+
baseUrl = 'https://kpi.knowlarity.com/Basic',
|
|
127
|
+
} = config;
|
|
128
|
+
|
|
129
|
+
const statusData = {
|
|
130
|
+
call_id: callId,
|
|
131
|
+
api_key: apiKey,
|
|
132
|
+
api_secret: apiSecret,
|
|
133
|
+
format: 'json',
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const response = await axios.post(
|
|
137
|
+
`${baseUrl}/call_details.php`,
|
|
138
|
+
statusData,
|
|
139
|
+
{
|
|
140
|
+
headers: {
|
|
141
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
142
|
+
},
|
|
143
|
+
transformRequest: [
|
|
144
|
+
(data) => {
|
|
145
|
+
return Object.keys(data)
|
|
146
|
+
.map(
|
|
147
|
+
(key) =>
|
|
148
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`,
|
|
149
|
+
)
|
|
150
|
+
.join('&');
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
return response.data;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -114,9 +114,29 @@ export class LoginController {
|
|
|
114
114
|
actualState,
|
|
115
115
|
);
|
|
116
116
|
|
|
117
|
-
return res.
|
|
117
|
+
return res.send(
|
|
118
|
+
`<html><body><script>
|
|
119
|
+
window.opener.postMessage({ type: 'CONFIG_SUCCESS' }, '*');
|
|
120
|
+
window.close();
|
|
121
|
+
</script> <p>Configuration successful. You can close this window.</p> </body></html>`,
|
|
122
|
+
);
|
|
118
123
|
} catch (error) {
|
|
119
|
-
return res.
|
|
124
|
+
return res.send(`
|
|
125
|
+
<html>
|
|
126
|
+
<body>
|
|
127
|
+
<script>
|
|
128
|
+
if (window.opener) {
|
|
129
|
+
window.opener.postMessage({
|
|
130
|
+
type: "CONFIG_FAILED",
|
|
131
|
+
error: "${error.message || 'Something went wrong'}"
|
|
132
|
+
}, "*");
|
|
133
|
+
}
|
|
134
|
+
window.close();
|
|
135
|
+
</script>
|
|
136
|
+
<p>Configuration failed. Please close this window.</p>
|
|
137
|
+
</body>
|
|
138
|
+
</html>
|
|
139
|
+
`);
|
|
120
140
|
}
|
|
121
141
|
}
|
|
122
142
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gmail-smtp.strategy.js","sourceRoot":"","sources":["../../../../src/module/communication/strategies/gmail-smtp.strategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,yCAAyC;AAOlC,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,KAAK,CAAC,WAAW,CACf,EAAU,EACV,OAAe,EACf,MAAW;QAEX,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,cAAc,EACxB,IAAI,EACJ,WAAW,EACX,EAAE,EACF,GAAG,GACJ,GAAG,MAAM,CAAC;YAEX,MAAM,WAAW,GAAG,UAAU,CAAC,eAAe,CAAC;gBAC7C,OAAO,EAAE,OAAO;gBAChB,IAAI,EAAE;oBACJ,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,QAAQ;iBACf;aACF,CAAC,CAAC;YAEH,MAAM,WAAW,GAAG;gBAClB,IAAI,EAAE,KAAK;gBACX,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;gBACzC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EA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} from './communication.strategy';
|
|
3
|
-
export declare class GmailStrategy implements CommunicationStrategy {
|
|
4
|
-
private readonly configService;
|
|
5
|
-
constructor(configService: ConfigService);
|
|
6
|
-
sendMessage(to: string, message: string, config: any): Promise<CommunicationResult>;
|
|
7
|
-
validateConfig(config: any): boolean;
|
|
8
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.GmailStrategy = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const config_1 = require("@nestjs/config");
|
|
15
|
-
const googleapis_1 = require("googleapis");
|
|
16
|
-
let GmailStrategy = class GmailStrategy {
|
|
17
|
-
constructor(configService) {
|
|
18
|
-
this.configService = configService;
|
|
19
|
-
}
|
|
20
|
-
async sendMessage(to, message, config) {
|
|
21
|
-
try {
|
|
22
|
-
const { clientId, clientSecret, refreshToken, accessToken, email } = config;
|
|
23
|
-
if (!refreshToken || !email) {
|
|
24
|
-
throw new Error('Missing required Gmail credentials: refreshToken and email are required');
|
|
25
|
-
}
|
|
26
|
-
const systemClientId = this.configService.get('CLIENT_ID');
|
|
27
|
-
const systemClientSecret = this.configService.get('CLIENT_SECRET');
|
|
28
|
-
if (!systemClientId || !systemClientSecret) {
|
|
29
|
-
throw new Error('Gmail OAuth system credentials not configured');
|
|
30
|
-
}
|
|
31
|
-
const oauth2Client = new googleapis_1.google.auth.OAuth2(systemClientId, systemClientSecret);
|
|
32
|
-
oauth2Client.setCredentials({
|
|
33
|
-
refresh_token: refreshToken,
|
|
34
|
-
access_token: accessToken,
|
|
35
|
-
});
|
|
36
|
-
try {
|
|
37
|
-
const { token } = await oauth2Client.getAccessToken();
|
|
38
|
-
if (token && token !== accessToken) {
|
|
39
|
-
config.accessToken = token;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (tokenError) {
|
|
43
|
-
console.log('Token refresh error:', tokenError.message);
|
|
44
|
-
}
|
|
45
|
-
const gmail = googleapis_1.google.gmail({ version: 'v1', auth: oauth2Client });
|
|
46
|
-
const subject = config.subject || 'Notification';
|
|
47
|
-
const emailContent = [
|
|
48
|
-
`From: ${email}`,
|
|
49
|
-
`To: ${to}`,
|
|
50
|
-
`Subject: ${subject}`,
|
|
51
|
-
'Content-Type: text/html; charset=utf-8',
|
|
52
|
-
'',
|
|
53
|
-
message || config.html,
|
|
54
|
-
].join('\n');
|
|
55
|
-
const encodedMessage = Buffer.from(emailContent)
|
|
56
|
-
.toString('base64')
|
|
57
|
-
.replace(/\+/g, '-')
|
|
58
|
-
.replace(/\//g, '_')
|
|
59
|
-
.replace(/=+$/, '');
|
|
60
|
-
const result = await gmail.users.messages.send({
|
|
61
|
-
userId: 'me',
|
|
62
|
-
requestBody: {
|
|
63
|
-
raw: encodedMessage,
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
return {
|
|
67
|
-
success: true,
|
|
68
|
-
provider: 'gmail',
|
|
69
|
-
service: 'API',
|
|
70
|
-
messageId: result.data.id || undefined,
|
|
71
|
-
timestamp: new Date(),
|
|
72
|
-
refreshedToken: config.accessToken !== accessToken ? config.accessToken : undefined,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
catch (error) {
|
|
76
|
-
console.log('Gmail strategy error:', error);
|
|
77
|
-
console.log('Config validation:', JSON.stringify({
|
|
78
|
-
hasRefreshToken: !!config.refreshToken,
|
|
79
|
-
hasAccessToken: !!config.accessToken,
|
|
80
|
-
hasEmail: !!config.email,
|
|
81
|
-
}));
|
|
82
|
-
return {
|
|
83
|
-
success: false,
|
|
84
|
-
provider: 'gmail',
|
|
85
|
-
service: 'API',
|
|
86
|
-
error: error.message,
|
|
87
|
-
timestamp: new Date(),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
validateConfig(config) {
|
|
92
|
-
return !!(config.refreshToken && config.email);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
exports.GmailStrategy = GmailStrategy;
|
|
96
|
-
exports.GmailStrategy = GmailStrategy = __decorate([
|
|
97
|
-
(0, common_1.Injectable)(),
|
|
98
|
-
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
99
|
-
], GmailStrategy);
|
|
100
|
-
//# sourceMappingURL=gmail.strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gmail.strategy.js","sourceRoot":"","sources":["../../../../src/module/communication/strategies/gmail.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAA+C;AAC/C,2CAAoC;AAO7B,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAC7D,KAAK,CAAC,WAAW,CACf,EAAU,EACV,OAAe,EACf,MAAW;QAEX,IAAI,CAAC;YACH,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,GAChE,MAAM,CAAC;YAGT,IAAI,CAAC,YAAY,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,C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,CAAC;IACH,CAAC;IAED,cAAc,CAAC,MAAW;QAExB,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF,CAAA;AA7GY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAEiC,sBAAa;GAD9C,aAAa,CA6GzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knowlarity.strategy.js","sourceRoot":"","sources":["../../../../src/module/communication/strategies/knowlarity.strategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,iCAA0B;AAOnB,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC7B,KAAK,CAAC,WAAW,CACf,EAAU,EACV,OAAe,EACf,MAAW;QAEX,IAAI,CAAC;YACH,MAAM,EACJ,MAAM,EACN,SAAS,EACT,YAAY,EACZ,OAAO,GAAG,kCAAkC,EAC5C,QAAQ,GAAG,OAAO,EAClB,QAAQ,GAAG,IAAI,GAChB,GAAG,MAAM,CAAC;YAEX,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;gBACzB,MAAM,QAAQ,GAAG;oBACf,QAAQ,EAAE,YAAY;oBACtB,YAAY,EAAE,EAAE;oBAChB,SAAS,EAAE,YAAY;oBACvB,aAAa,EAAE,MAAM,CAAC,YAAY,IAAI,OAAO;oBAC7C,QAAQ,EAAE,QAAQ;oBAClB,OAAO,EAAE,MAAM;oBACf,UAAU,EAAE,SAAS;oBACrB,MAAM,EAAE,MAAM;iBACf,CAAC;gBAEF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,GAAG,OAAO,iBAAiB,EAC3B,QAAQ,EACR;oBACE,OAAO,EAAE;wBACP,cAAc,EAAE,mCAAmC;qBACpD;oBACD,gBAAgB,EAAE;wBAChB,CAAC,IAAI,EAAE,EAAE;4BACP,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;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C,GAAG,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAChE;yBACA,IAAI,CAAC,GAAG,CAAC,CAAC;gBACf,CAAC;aACF;SACF,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF,CAAA;AArJY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAqJ9B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outlook-smtp.strategy.js","sourceRoot":"","sources":["../../../../src/module/communication/strategies/outlook-smtp.strategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,yCAAyC;AAOlC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC9B,KAAK,CAAC,WAAW,CACf,EAAU,EACV,OAAe,EACf,MAAW;QAEX,IAAI,CAAC;YACH,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,cAAc,EACxB,IAAI,EACJ,WAAW,EACX,EAAE,EACF,GAAG,GACJ,GAAG,MAAM,CAAC;YAEX,MAAM,WAAW,GAAG,UAAU,CAAC,eAAe,CAAC;gBAC7C,IAAI,EAAE,uBAAuB;gBAC7B,IAAI,EAAE,GAAG;gBACT,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE;oBACJ,IAAI,EAAE,KAAK;oBACX,IAAI,EAAE,QAAQ;iBACf;gBACD,GAAG,EAAE;oBACH,OAAO,EAAE,OAAO;iBACjB;aACF,CAAC,CAAC;YAEH,MAAM,WAAW,GAAG;gBAClB,IAAI,EAAE,KAAK;gBACX,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;gBACzC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EA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B,OAAO,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC;IAC9B,CAAC;CACF,CAAA;AAvDY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;GACA,eAAe,CAuD3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sms.strategy.js","sourceRoot":"","sources":["../../../../src/module/communication/strategies/sms.strategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,mCAAgC;AAOzB,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB,KAAK,CAAC,WAAW,CACf,EAAU,EACV,OAAe,EACf,MAAW;QAEX,IAAI,CAAC;YACH,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;YAErD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;YAEjD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAC1C,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,UAAU;gBAChB,EAAE,EAAE,EAAE;aACP,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,QAAQ;gBAClB,OAAO,EAAE,aAAa;gBACtB,SAAS,EAAE,MAAM,CAAC,GAAG;gBACrB,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,QAAQ;gBAClB,OAAO,EAAE,aAAa;gBACtB,KAAK,EAAE,KAAK,CAAC,OAAO;gBACpB,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,cAAc,CAAC,MAAW;QACxB,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;IACxE,CAAC;CACF,CAAA;AAtCY,kCAAW;sBAAX,WAAW;IADvB,IAAA,mBAAU,GAAE;GACA,WAAW,CAsCvB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp.strategy.js","sourceRoot":"","sources":["../../../../src/module/communication/strategies/whatsapp.strategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,iCAA0B;AAOnB,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAC3B,KAAK,CAAC,WAAW,CACf,EAAU,EACV,OAAe,EACf,MAAW;QAEX,IAAI,CAAC;YACH,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC;YAEpE,MAAM,GAAG,GAAG,8BAA8B,UAAU,IAAI,aAAa,WAAW,CAAC;YAEjF,MAAM,OAAO,GAAG;gBACd,iBAAiB,EAAE,UAAU;gBAC7B,EAAE,EAAE,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE;oBACJ,IAAI,EAAE,OAAO;iBACd;aACF,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,EAAE;gBAC9C,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,WAAW,EAAE;oBACtC,cAAc,EAAE,kBAAkB;iBACnC;aACF,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,QAAQ,EAAE,UAAU;gBACpB,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE;gBACvC,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,UAAU;gBACpB,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,CAAC,OAAO;gBACpB,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,cAAc,CAAC,MAAW;QACxB,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC;IACxD,CAAC;CACF,CAAA;AAhDY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;GACA,gBAAgB,CAgD5B"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@nestjs/common';
|
|
2
|
-
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
import { google } from 'googleapis';
|
|
4
|
-
import {
|
|
5
|
-
CommunicationStrategy,
|
|
6
|
-
CommunicationResult,
|
|
7
|
-
} from './communication.strategy';
|
|
8
|
-
|
|
9
|
-
@Injectable()
|
|
10
|
-
export class GmailStrategy implements CommunicationStrategy {
|
|
11
|
-
constructor(private readonly configService: ConfigService) {}
|
|
12
|
-
async sendMessage(
|
|
13
|
-
to: string,
|
|
14
|
-
message: string,
|
|
15
|
-
config: any,
|
|
16
|
-
): Promise<CommunicationResult> {
|
|
17
|
-
try {
|
|
18
|
-
const { clientId, clientSecret, refreshToken, accessToken, email } =
|
|
19
|
-
config;
|
|
20
|
-
|
|
21
|
-
// For backward compatibility, only validate essential fields for sending
|
|
22
|
-
if (!refreshToken || !email) {
|
|
23
|
-
throw new Error(
|
|
24
|
-
'Missing required Gmail credentials: refreshToken and email are required',
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Get system OAuth credentials
|
|
29
|
-
const systemClientId = this.configService.get<string>('CLIENT_ID');
|
|
30
|
-
const systemClientSecret =
|
|
31
|
-
this.configService.get<string>('CLIENT_SECRET');
|
|
32
|
-
|
|
33
|
-
if (!systemClientId || !systemClientSecret) {
|
|
34
|
-
throw new Error('Gmail OAuth system credentials not configured');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Create OAuth2 client with system credentials
|
|
38
|
-
const oauth2Client = new google.auth.OAuth2(
|
|
39
|
-
systemClientId,
|
|
40
|
-
systemClientSecret,
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
oauth2Client.setCredentials({
|
|
44
|
-
refresh_token: refreshToken,
|
|
45
|
-
access_token: accessToken,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Try to get a valid access token (will auto-refresh if needed)
|
|
49
|
-
try {
|
|
50
|
-
const { token } = await oauth2Client.getAccessToken();
|
|
51
|
-
// If we got a new token, update the config
|
|
52
|
-
if (token && token !== accessToken) {
|
|
53
|
-
config.accessToken = token;
|
|
54
|
-
}
|
|
55
|
-
} catch (tokenError) {
|
|
56
|
-
console.log('Token refresh error:', tokenError.message);
|
|
57
|
-
// If refresh fails, continue with existing token and let Gmail API handle it
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const gmail = google.gmail({ version: 'v1', auth: oauth2Client });
|
|
61
|
-
|
|
62
|
-
const subject = config.subject || 'Notification';
|
|
63
|
-
const emailContent = [
|
|
64
|
-
`From: ${email}`,
|
|
65
|
-
`To: ${to}`,
|
|
66
|
-
`Subject: ${subject}`,
|
|
67
|
-
'Content-Type: text/html; charset=utf-8',
|
|
68
|
-
'',
|
|
69
|
-
message || config.html,
|
|
70
|
-
].join('\n');
|
|
71
|
-
|
|
72
|
-
const encodedMessage = Buffer.from(emailContent)
|
|
73
|
-
.toString('base64')
|
|
74
|
-
.replace(/\+/g, '-')
|
|
75
|
-
.replace(/\//g, '_')
|
|
76
|
-
.replace(/=+$/, '');
|
|
77
|
-
|
|
78
|
-
const result = await gmail.users.messages.send({
|
|
79
|
-
userId: 'me',
|
|
80
|
-
requestBody: {
|
|
81
|
-
raw: encodedMessage,
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
success: true,
|
|
87
|
-
provider: 'gmail',
|
|
88
|
-
service: 'API',
|
|
89
|
-
messageId: result.data.id || undefined,
|
|
90
|
-
timestamp: new Date(),
|
|
91
|
-
refreshedToken:
|
|
92
|
-
config.accessToken !== accessToken ? config.accessToken : undefined,
|
|
93
|
-
};
|
|
94
|
-
} catch (error) {
|
|
95
|
-
console.log('Gmail strategy error:', error);
|
|
96
|
-
console.log(
|
|
97
|
-
'Config validation:',
|
|
98
|
-
JSON.stringify({
|
|
99
|
-
hasRefreshToken: !!config.refreshToken,
|
|
100
|
-
hasAccessToken: !!config.accessToken,
|
|
101
|
-
hasEmail: !!config.email,
|
|
102
|
-
}),
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
return {
|
|
106
|
-
success: false,
|
|
107
|
-
provider: 'gmail',
|
|
108
|
-
service: 'API',
|
|
109
|
-
error: error.message,
|
|
110
|
-
timestamp: new Date(),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
validateConfig(config: any): boolean {
|
|
116
|
-
// Since we use system credentials, we only need refreshToken and email from config
|
|
117
|
-
return !!(config.refreshToken && config.email);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
File without changes
|
/package/dist/module/communication/strategies/{outlook.strategy.js → email/outlook.strategy.js}
RENAMED
|
File without changes
|
/package/dist/module/communication/strategies/{whatsapp.strategy.js → whatsapp/whatsapp.strategy.js}
RENAMED
|
File without changes
|