@app-connect/core 1.7.0 → 1.7.3

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.
@@ -89,18 +89,21 @@ class ConnectorRegistry {
89
89
  * @returns {Object} Composed connector with interface functions
90
90
  */
91
91
  getConnector(platform) {
92
- const connector = this.connectors.get(platform);
92
+ let connector = this.connectors.get(platform);
93
93
  const platformInterfaceMap = this.platformInterfaces.get(platform);
94
-
95
- // If no connector and no interfaces, throw error
94
+
96
95
  if (!connector && (!platformInterfaceMap || platformInterfaceMap.size === 0)) {
97
- throw new Error(`Connector not found for platform: ${platform}`);
96
+ connector = this.connectors.get('proxy');
97
+ if (connector) {
98
+ return connector;
99
+ }
100
+ throw new Error(`Connector not found for platform: ${platform}`);
98
101
  }
99
102
 
100
103
  // If no connector but interfaces exist, create a composed object with just interfaces
101
104
  if (!connector && platformInterfaceMap && platformInterfaceMap.size > 0) {
102
105
  const composedConnector = {};
103
-
106
+
104
107
  // Add interface functions to the composed connector
105
108
  for (const [interfaceName, interfaceFunction] of platformInterfaceMap) {
106
109
  composedConnector[interfaceName] = interfaceFunction;
@@ -117,7 +120,7 @@ class ConnectorRegistry {
117
120
 
118
121
  // If both connector and interfaces exist, create a composed object
119
122
  const composedConnector = Object.create(connector);
120
-
123
+
121
124
  // Add interface functions to the composed connector
122
125
  for (const [interfaceName, interfaceFunction] of platformInterfaceMap) {
123
126
  // Only add if the interface doesn't already exist in the connector
@@ -216,7 +219,7 @@ class ConnectorRegistry {
216
219
  * @param {string} platform - Platform identifier
217
220
  * @returns {Object} Connector capabilities
218
221
  */
219
- getConnectorCapabilities(platform) {
222
+ async getConnectorCapabilities(platform) {
220
223
  const originalConnector = this.getOriginalConnector(platform);
221
224
  const composedConnector = this.getConnector(platform);
222
225
  const platformInterfaceMap = this.getPlatformInterfaces(platform);
@@ -232,7 +235,7 @@ class ConnectorRegistry {
232
235
  // Get auth type if available
233
236
  if (typeof originalConnector.getAuthType === 'function') {
234
237
  try {
235
- capabilities.authType = originalConnector.getAuthType();
238
+ capabilities.authType = await originalConnector.getAuthType();
236
239
  } catch (error) {
237
240
  capabilities.authType = 'unknown';
238
241
  }
package/handlers/admin.js CHANGED
@@ -3,6 +3,7 @@ const { AdminConfigModel } = require('../models/adminConfigModel');
3
3
  const connectorRegistry = require('../connector/registry');
4
4
  const oauth = require('../lib/oauth');
5
5
  const { RingCentral } = require('../lib/ringcentral');
6
+ const { Connector } = require('../models/dynamo/connectorSchema');
6
7
 
7
8
  async function validateAdminRole({ rcAccessToken }) {
8
9
  const rcExtensionResponse = await axios.get(
@@ -202,11 +203,19 @@ async function getUserMapping({ user, hashedRcAccountId, rcExtensionList }) {
202
203
  const adminConfig = await getAdminSettings({ hashedRcAccountId });
203
204
  const platformModule = connectorRegistry.getConnector(user.platform);
204
205
  if (platformModule.getUserList) {
205
- const authType = platformModule.getAuthType();
206
+ const proxyId = user.platformAdditionalInfo?.proxyId;
207
+ let proxyConfig = null;
208
+ if (proxyId) {
209
+ proxyConfig = await Connector.getProxyConfig(proxyId);
210
+ if (!proxyConfig?.operations?.getUserList) {
211
+ return [];
212
+ }
213
+ }
214
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
206
215
  let authHeader = '';
207
216
  switch (authType) {
208
217
  case 'oauth':
209
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
218
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
210
219
  // eslint-disable-next-line no-param-reassign
211
220
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
212
221
  authHeader = `Bearer ${user.accessToken}`;
@@ -216,7 +225,7 @@ async function getUserMapping({ user, hashedRcAccountId, rcExtensionList }) {
216
225
  authHeader = `Basic ${basicAuth}`;
217
226
  break;
218
227
  }
219
- const crmUserList = await platformModule.getUserList({ user, authHeader });
228
+ const crmUserList = await platformModule.getUserList({ user, authHeader, proxyConfig });
220
229
  const userMappingResult = [];
221
230
  const newUserMappings = [];
222
231
  for (const crmUser of crmUserList) {
@@ -312,16 +321,21 @@ async function getUserMapping({ user, hashedRcAccountId, rcExtensionList }) {
312
321
  ...u,
313
322
  rcExtensionId: [u.rcExtensionId]
314
323
  }));
324
+ await upsertAdminSettings({
325
+ hashedRcAccountId,
326
+ adminSettings: {
327
+ userMappings: [...adminConfig.userMappings, ...newUserMappings]
328
+ }
329
+ });
315
330
  }
316
331
  else {
317
- adminConfig.userMappings = [];
332
+ await upsertAdminSettings({
333
+ hashedRcAccountId,
334
+ adminSettings: {
335
+ userMappings: [...newUserMappings]
336
+ }
337
+ });
318
338
  }
319
- await upsertAdminSettings({
320
- hashedRcAccountId,
321
- adminSettings: {
322
- userMappings: [...adminConfig.userMappings, ...newUserMappings]
323
- }
324
- });
325
339
  }
326
340
  return userMappingResult;
327
341
  }
package/handlers/auth.js CHANGED
@@ -4,10 +4,15 @@ const connectorRegistry = require('../connector/registry');
4
4
  const Op = require('sequelize').Op;
5
5
  const { RingCentral } = require('../lib/ringcentral');
6
6
  const adminCore = require('./admin');
7
+ const { Connector } = require('../models/dynamo/connectorSchema');
7
8
 
8
- async function onOAuthCallback({ platform, hostname, tokenUrl, callbackUri, apiUrl, username, query }) {
9
+ async function onOAuthCallback({ platform, hostname, tokenUrl, callbackUri, apiUrl, username, query, proxyId }) {
9
10
  const platformModule = connectorRegistry.getConnector(platform);
10
- const oauthInfo = await platformModule.getOauthInfo({ tokenUrl, hostname, rcAccountId: query.rcAccountId });
11
+ let proxyConfig = null;
12
+ if (proxyId) {
13
+ proxyConfig = await Connector.getProxyConfig(proxyId);
14
+ }
15
+ const oauthInfo = await platformModule.getOauthInfo({ tokenUrl, hostname, rcAccountId: query.rcAccountId, proxyId, proxyConfig });
11
16
 
12
17
  if (oauthInfo.failMessage) {
13
18
  return {
@@ -27,7 +32,8 @@ async function onOAuthCallback({ platform, hostname, tokenUrl, callbackUri, apiU
27
32
  const oauthApp = oauth.getOAuthApp(oauthInfo);
28
33
  const { accessToken, refreshToken, expires } = await oauthApp.code.getToken(callbackUri, overridingOAuthOption);
29
34
  const authHeader = `Bearer ${accessToken}`;
30
- const { successful, platformUserInfo, returnMessage } = await platformModule.getUserInfo({ authHeader, tokenUrl, apiUrl, hostname, username, callbackUri, query });
35
+ const { successful, platformUserInfo, returnMessage } = await platformModule.getUserInfo({ authHeader, tokenUrl, apiUrl, hostname, platform, username, callbackUri, query, proxyId, proxyConfig });
36
+
31
37
  if (successful) {
32
38
  let userInfo = await saveUserInfo({
33
39
  platformUserInfo,
@@ -39,7 +45,8 @@ async function onOAuthCallback({ platform, hostname, tokenUrl, callbackUri, apiU
39
45
  accessToken,
40
46
  refreshToken,
41
47
  tokenExpiry: expires,
42
- rcAccountId: query.rcAccountId
48
+ rcAccountId: query.rcAccountId,
49
+ proxyId
43
50
  });
44
51
  if (platformModule.postSaveUserInfo) {
45
52
  userInfo = await platformModule.postSaveUserInfo({ userInfo, oauthApp });
@@ -57,15 +64,16 @@ async function onOAuthCallback({ platform, hostname, tokenUrl, callbackUri, apiU
57
64
  }
58
65
  }
59
66
 
60
- async function onApiKeyLogin({ platform, hostname, apiKey, additionalInfo }) {
67
+ async function onApiKeyLogin({ platform, hostname, apiKey, proxyId, additionalInfo }) {
61
68
  const platformModule = connectorRegistry.getConnector(platform);
62
69
  const basicAuth = platformModule.getBasicAuth({ apiKey });
63
- const { successful, platformUserInfo, returnMessage } = await platformModule.getUserInfo({ authHeader: `Basic ${basicAuth}`, hostname, additionalInfo, apiKey });
70
+ const { successful, platformUserInfo, returnMessage } = await platformModule.getUserInfo({ authHeader: `Basic ${basicAuth}`, hostname, platform, additionalInfo, apiKey, proxyId });
64
71
  if (successful) {
65
72
  let userInfo = await saveUserInfo({
66
73
  platformUserInfo,
67
74
  platform,
68
75
  hostname,
76
+ proxyId,
69
77
  accessToken: platformUserInfo.overridingApiKey ?? apiKey
70
78
  });
71
79
  if (platformModule.postSaveUserInfo) {
@@ -84,13 +92,14 @@ async function onApiKeyLogin({ platform, hostname, apiKey, additionalInfo }) {
84
92
  }
85
93
  }
86
94
 
87
- async function saveUserInfo({ platformUserInfo, platform, hostname, accessToken, refreshToken, tokenExpiry, rcAccountId }) {
95
+ async function saveUserInfo({ platformUserInfo, platform, hostname, accessToken, refreshToken, tokenExpiry, rcAccountId, proxyId }) {
88
96
  const id = platformUserInfo.id;
89
97
  const name = platformUserInfo.name;
90
98
  const existingUser = await UserModel.findByPk(id);
91
99
  const timezoneName = platformUserInfo.timezoneName;
92
100
  const timezoneOffset = platformUserInfo.timezoneOffset;
93
- const platformAdditionalInfo = platformUserInfo.platformAdditionalInfo;
101
+ const platformAdditionalInfo = platformUserInfo.platformAdditionalInfo || {};
102
+ platformAdditionalInfo.proxyId = proxyId;
94
103
  if (existingUser) {
95
104
  await existingUser.update(
96
105
  {
@@ -170,7 +179,7 @@ async function saveUserInfo({ platformUserInfo, platform, hostname, accessToken,
170
179
 
171
180
  async function getLicenseStatus({ userId, platform }) {
172
181
  const platformModule = connectorRegistry.getConnector(platform);
173
- const licenseStatus = await platformModule.getLicenseStatus({ userId });
182
+ const licenseStatus = await platformModule.getLicenseStatus({ userId, platform });
174
183
  return licenseStatus;
175
184
  }
176
185
 
@@ -188,7 +197,8 @@ async function authValidation({ platform, userId }) {
188
197
  });
189
198
  if (existingUser) {
190
199
  const platformModule = connectorRegistry.getConnector(platform);
191
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: existingUser?.platformAdditionalInfo?.tokenUrl, hostname: existingUser?.hostname })));
200
+ const proxyId = existingUser?.platformAdditionalInfo?.proxyId;
201
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: existingUser?.platformAdditionalInfo?.tokenUrl, hostname: existingUser?.hostname, proxyId })));
192
202
  existingUser = await oauth.checkAndRefreshAccessToken(oauthApp, existingUser);
193
203
  const { successful, returnMessage, status } = await platformModule.authValidation({ user: existingUser });
194
204
  return {
@@ -2,6 +2,8 @@ const oauth = require('../lib/oauth');
2
2
  const { UserModel } = require('../models/userModel');
3
3
  const errorMessage = require('../lib/generalErrorMessage');
4
4
  const connectorRegistry = require('../connector/registry');
5
+ const { Connector } = require('../models/dynamo/connectorSchema');
6
+
5
7
  async function findContact({ platform, userId, phoneNumber, overridingFormat, isExtension }) {
6
8
  try {
7
9
  let user = await UserModel.findOne({
@@ -20,12 +22,17 @@ async function findContact({ platform, userId, phoneNumber, overridingFormat, is
20
22
  }
21
23
  };
22
24
  }
25
+ const proxyId = user.platformAdditionalInfo?.proxyId;
26
+ let proxyConfig = null;
27
+ if (proxyId) {
28
+ proxyConfig = await Connector.getProxyConfig(proxyId);
29
+ }
23
30
  const platformModule = connectorRegistry.getConnector(platform);
24
- const authType = platformModule.getAuthType();
31
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
25
32
  let authHeader = '';
26
33
  switch (authType) {
27
34
  case 'oauth':
28
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
35
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
29
36
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
30
37
  authHeader = `Bearer ${user.accessToken}`;
31
38
  break;
@@ -34,7 +41,7 @@ async function findContact({ platform, userId, phoneNumber, overridingFormat, is
34
41
  authHeader = `Basic ${basicAuth}`;
35
42
  break;
36
43
  }
37
- const { successful, matchedContactInfo, returnMessage, extraDataTracking } = await platformModule.findContact({ user, authHeader, phoneNumber, overridingFormat, isExtension });
44
+ const { successful, matchedContactInfo, returnMessage, extraDataTracking } = await platformModule.findContact({ user, authHeader, phoneNumber, overridingFormat, isExtension, proxyConfig });
38
45
  if (matchedContactInfo != null && matchedContactInfo?.filter(c => !c.isNewContact)?.length > 0) {
39
46
  return { successful, returnMessage, contact: matchedContactInfo, extraDataTracking };
40
47
  }
@@ -127,12 +134,17 @@ async function createContact({ platform, userId, phoneNumber, newContactName, ne
127
134
  if (!user || !user.accessToken) {
128
135
  return { successful: false, message: `Contact not found` };
129
136
  }
137
+ const proxyId = user.platformAdditionalInfo?.proxyId;
138
+ let proxyConfig = null;
139
+ if (proxyId) {
140
+ proxyConfig = await Connector.getProxyConfig(proxyId);
141
+ }
130
142
  const platformModule = connectorRegistry.getConnector(platform);
131
- const authType = platformModule.getAuthType();
143
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
132
144
  let authHeader = '';
133
145
  switch (authType) {
134
146
  case 'oauth':
135
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
147
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
136
148
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
137
149
  authHeader = `Bearer ${user.accessToken}`;
138
150
  break;
@@ -141,7 +153,7 @@ async function createContact({ platform, userId, phoneNumber, newContactName, ne
141
153
  authHeader = `Basic ${basicAuth}`;
142
154
  break;
143
155
  }
144
- const { contactInfo, returnMessage, extraDataTracking } = await platformModule.createContact({ user, authHeader, phoneNumber, newContactName, newContactType, additionalSubmission });
156
+ const { contactInfo, returnMessage, extraDataTracking } = await platformModule.createContact({ user, authHeader, phoneNumber, newContactName, newContactType, additionalSubmission, proxyConfig });
145
157
  if (contactInfo != null) {
146
158
  return { successful: true, returnMessage, contact: contactInfo, extraDataTracking };
147
159
  }
@@ -207,12 +219,17 @@ async function findContactWithName({ platform, userId, name }) {
207
219
  }
208
220
  };
209
221
  }
222
+ const proxyId = user.platformAdditionalInfo?.proxyId;
223
+ let proxyConfig = null;
224
+ if (proxyId) {
225
+ proxyConfig = await Connector.getProxyConfig(proxyId);
226
+ }
210
227
  const platformModule = connectorRegistry.getConnector(platform);
211
- const authType = platformModule.getAuthType();
228
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
212
229
  let authHeader = '';
213
230
  switch (authType) {
214
231
  case 'oauth':
215
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
232
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
216
233
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
217
234
  authHeader = `Bearer ${user.accessToken}`;
218
235
  break;
@@ -221,7 +238,7 @@ async function findContactWithName({ platform, userId, name }) {
221
238
  authHeader = `Basic ${basicAuth}`;
222
239
  break;
223
240
  }
224
- const { successful, matchedContactInfo, returnMessage } = await platformModule.findContactWithName({ user, authHeader, name });
241
+ const { successful, matchedContactInfo, returnMessage } = await platformModule.findContactWithName({ user, authHeader, name, proxyConfig });
225
242
  if (matchedContactInfo != null && matchedContactInfo?.filter(c => !c.isNewContact)?.length > 0) {
226
243
  return { successful, returnMessage, contact: matchedContactInfo };
227
244
  }
@@ -6,6 +6,7 @@ const oauth = require('../lib/oauth');
6
6
  // const userCore = require('../handlers/user');
7
7
  const errorMessage = require('../lib/generalErrorMessage');
8
8
  const connectorRegistry = require('../connector/registry');
9
+ const { Connector } = require('../models/dynamo/connectorSchema');
9
10
 
10
11
  async function upsertCallDisposition({ platform, userId, sessionId, dispositions, additionalSubmission, userSettings }) {
11
12
  try {
@@ -35,12 +36,17 @@ async function upsertCallDisposition({ platform, userId, sessionId, dispositions
35
36
  }
36
37
  }
37
38
  }
39
+ const proxyId = user.platformAdditionalInfo?.proxyId;
40
+ let proxyConfig = null;
41
+ if (proxyId) {
42
+ proxyConfig = await Connector.getProxyConfig(proxyId);
43
+ }
38
44
  const platformModule = connectorRegistry.getConnector(platform);
39
- const authType = platformModule.getAuthType();
45
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
40
46
  let authHeader = '';
41
47
  switch (authType) {
42
48
  case 'oauth':
43
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
49
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
44
50
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
45
51
  authHeader = `Bearer ${user.accessToken}`;
46
52
  break;
@@ -53,7 +59,8 @@ async function upsertCallDisposition({ platform, userId, sessionId, dispositions
53
59
  user,
54
60
  existingCallLog: log,
55
61
  authHeader,
56
- dispositions
62
+ dispositions,
63
+ proxyConfig
57
64
  });
58
65
  return { successful: !!logId, logId, returnMessage, extraDataTracking };
59
66
  }
@@ -126,12 +133,17 @@ async function upsertCallDisposition({ platform, userId, sessionId, dispositions
126
133
  // }
127
134
  // }
128
135
  // }
136
+ // const proxyId = user.platformAdditionalInfo?.proxyId;
137
+ // let proxyConfig = null;
138
+ // if (proxyId) {
139
+ // proxyConfig = await Connector.getProxyConfig(proxyId);
140
+ // }
129
141
  // const platformModule = connectorRegistry.getConnector(platform);
130
- // const authType = platformModule.getAuthType();
142
+ // const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
131
143
  // let authHeader = '';
132
144
  // switch (authType) {
133
145
  // case 'oauth':
134
- // const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
146
+ // const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
135
147
  // user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
136
148
  // authHeader = `Bearer ${user.accessToken}`;
137
149
  // break;
@@ -144,7 +156,8 @@ async function upsertCallDisposition({ platform, userId, sessionId, dispositions
144
156
  // user,
145
157
  // existingMessageLog: existingSameDateMessageLog,
146
158
  // authHeader,
147
- // dispositions
159
+ // dispositions,
160
+ // proxyConfig
148
161
  // });
149
162
  // return { successful: !!logId, logId, returnMessage, extraDataTracking };
150
163
  // }
package/handlers/log.js CHANGED
@@ -8,6 +8,7 @@ const { composeCallLog } = require('../lib/callLogComposer');
8
8
  const connectorRegistry = require('../connector/registry');
9
9
  const { LOG_DETAILS_FORMAT_TYPE } = require('../lib/constants');
10
10
  const { NoteCache } = require('../models/dynamo/noteCacheSchema');
11
+ const { Connector } = require('../models/dynamo/connectorSchema');
11
12
  const moment = require('moment');
12
13
  const { getMediaReaderLinkByPlatformMediaLink } = require('../lib/util');
13
14
 
@@ -51,11 +52,16 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
51
52
  }
52
53
  const aiNote = incomingData.aiNote;
53
54
  const transcript = incomingData.transcript;
54
- const authType = platformModule.getAuthType();
55
+ let proxyConfig;
56
+ const proxyId = user.platformAdditionalInfo?.proxyId;
57
+ if (proxyId) {
58
+ proxyConfig = await Connector.getProxyConfig(proxyId);
59
+ }
60
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
55
61
  let authHeader = '';
56
62
  switch (authType) {
57
63
  case 'oauth':
58
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
64
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
59
65
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
60
66
  authHeader = `Bearer ${user.accessToken}`;
61
67
  break;
@@ -82,9 +88,9 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
82
88
  type: incomingData.contactType ?? "",
83
89
  name: incomingData.contactName ?? ""
84
90
  };
85
-
91
+
86
92
  // Compose call log details centrally
87
- const logFormat = platformModule.platformModule ? platformModule.getLogFormatType(platform) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
93
+ const logFormat = platformModule.getLogFormatType ? platformModule.getLogFormatType(platform, proxyConfig) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
88
94
  let composedLogDetails = '';
89
95
  if (logFormat === LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT || logFormat === LOG_DETAILS_FORMAT_TYPE.HTML || logFormat === LOG_DETAILS_FORMAT_TYPE.MARKDOWN) {
90
96
  composedLogDetails = await composeCallLog({
@@ -100,7 +106,12 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
100
106
  startTime: callLog.startTime,
101
107
  duration: callLog.duration,
102
108
  result: callLog.result,
103
- platform
109
+ platform,
110
+ ringSenseTranscript: incomingData.ringSenseTranscript,
111
+ ringSenseSummary: incomingData.ringSenseSummary,
112
+ ringSenseAIScore: incomingData.ringSenseAIScore,
113
+ ringSenseBulletedSummary: incomingData.ringSenseBulletedSummary,
114
+ ringSenseLink: incomingData.ringSenseLink,
104
115
  });
105
116
  }
106
117
 
@@ -113,9 +124,15 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
113
124
  additionalSubmission,
114
125
  aiNote,
115
126
  transcript,
127
+ ringSenseTranscript: incomingData.ringSenseTranscript,
128
+ ringSenseSummary: incomingData.ringSenseSummary,
129
+ ringSenseAIScore: incomingData.ringSenseAIScore,
130
+ ringSenseBulletedSummary: incomingData.ringSenseBulletedSummary,
131
+ ringSenseLink: incomingData.ringSenseLink,
116
132
  composedLogDetails,
117
133
  hashedAccountId,
118
- isFromSSCL
134
+ isFromSSCL,
135
+ proxyConfig,
119
136
  });
120
137
  if (logId) {
121
138
  await CallLogModel.create({
@@ -189,12 +206,17 @@ async function getCallLog({ userId, sessionIds, platform, requireDetails }) {
189
206
  sessionIdsArray = sessionIdsArray.slice(0, 5);
190
207
  }
191
208
  if (requireDetails) {
209
+ const proxyId = user.platformAdditionalInfo?.proxyId;
210
+ let proxyConfig = null;
211
+ if (proxyId) {
212
+ proxyConfig = await Connector.getProxyConfig(proxyId);
213
+ }
192
214
  const platformModule = connectorRegistry.getConnector(platform);
193
- const authType = platformModule.getAuthType();
215
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
194
216
  let authHeader = '';
195
217
  switch (authType) {
196
218
  case 'oauth':
197
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
219
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
198
220
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
199
221
  authHeader = `Bearer ${user.accessToken}`;
200
222
  break;
@@ -221,7 +243,7 @@ async function getCallLog({ userId, sessionIds, platform, requireDetails }) {
221
243
  logs.push({ sessionId: sId, matched: false });
222
244
  }
223
245
  else {
224
- const getCallLogResult = await platformModule.getCallLog({ user, callLogId: callLog.thirdPartyLogId, contactId: callLog.contactId, authHeader });
246
+ const getCallLogResult = await platformModule.getCallLog({ user, callLogId: callLog.thirdPartyLogId, contactId: callLog.contactId, authHeader, proxyConfig });
225
247
  returnMessage = getCallLogResult.returnMessage;
226
248
  extraDataTracking = getCallLogResult.extraDataTracking;
227
249
  logs.push({ sessionId: callLog.sessionId, matched: true, logId: callLog.thirdPartyLogId, logData: getCallLogResult.callLogInfo });
@@ -308,11 +330,16 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
308
330
  if (!user || !user.accessToken) {
309
331
  return { successful: false, message: `Contact not found` };
310
332
  }
311
- const authType = platformModule.getAuthType();
333
+ const proxyId = user.platformAdditionalInfo?.proxyId;
334
+ let proxyConfig = null;
335
+ if (proxyId) {
336
+ proxyConfig = await Connector.getProxyConfig(proxyId);
337
+ }
338
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
312
339
  let authHeader = '';
313
340
  switch (authType) {
314
341
  case 'oauth':
315
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
342
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
316
343
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
317
344
  authHeader = `Bearer ${user.accessToken}`;
318
345
  break;
@@ -324,7 +351,7 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
324
351
 
325
352
  // Fetch existing call log details once to avoid duplicate API calls
326
353
  let existingCallLogDetails = null; // Compose updated call log details centrally
327
- const logFormat = platformModule.platformModule ? platformModule.getLogFormatType(platform) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
354
+ const logFormat = platformModule.getLogFormatType ? platformModule.getLogFormatType(platform, proxyConfig) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
328
355
  let composedLogDetails = '';
329
356
  if (logFormat === LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT || logFormat === LOG_DETAILS_FORMAT_TYPE.HTML || logFormat === LOG_DETAILS_FORMAT_TYPE.MARKDOWN) {
330
357
  let existingBody = '';
@@ -332,7 +359,8 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
332
359
  const getLogResult = await platformModule.getCallLog({
333
360
  user,
334
361
  callLogId: existingCallLog.thirdPartyLogId,
335
- authHeader
362
+ authHeader,
363
+ proxyConfig,
336
364
  });
337
365
  existingCallLogDetails = getLogResult?.callLogInfo?.fullLogResponse;
338
366
  // Extract existing body from the platform-specific response
@@ -367,6 +395,11 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
367
395
  startTime: incomingData.startTime,
368
396
  duration: incomingData.duration,
369
397
  result: incomingData.result,
398
+ ringSenseTranscript: incomingData.ringSenseTranscript,
399
+ ringSenseSummary: incomingData.ringSenseSummary,
400
+ ringSenseAIScore: incomingData.ringSenseAIScore,
401
+ ringSenseBulletedSummary: incomingData.ringSenseBulletedSummary,
402
+ ringSenseLink: incomingData.ringSenseLink,
370
403
  });
371
404
  }
372
405
 
@@ -384,11 +417,17 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
384
417
  aiNote: incomingData.aiNote,
385
418
  transcript: incomingData.transcript,
386
419
  legs: incomingData.legs || [],
420
+ ringSenseTranscript: incomingData.ringSenseTranscript,
421
+ ringSenseSummary: incomingData.ringSenseSummary,
422
+ ringSenseAIScore: incomingData.ringSenseAIScore,
423
+ ringSenseBulletedSummary: incomingData.ringSenseBulletedSummary,
424
+ ringSenseLink: incomingData.ringSenseLink,
387
425
  additionalSubmission: incomingData.additionalSubmission,
388
426
  composedLogDetails,
389
427
  existingCallLogDetails, // Pass the fetched details to avoid duplicate API calls
390
428
  hashedAccountId,
391
- isFromSSCL
429
+ isFromSSCL,
430
+ proxyConfig,
392
431
  });
393
432
  return { successful: true, logId: existingCallLog.thirdPartyLogId, updatedNote, returnMessage, extraDataTracking };
394
433
  }
@@ -470,11 +509,16 @@ async function createMessageLog({ platform, userId, incomingData }) {
470
509
  }
471
510
  };
472
511
  }
473
- const authType = platformModule.getAuthType();
512
+ const proxyId = user.platformAdditionalInfo?.proxyId;
513
+ let proxyConfig = null;
514
+ if (proxyId) {
515
+ proxyConfig = await Connector.getProxyConfig(proxyId);
516
+ }
517
+ const authType = await platformModule.getAuthType({ proxyId, proxyConfig });
474
518
  let authHeader = '';
475
519
  switch (authType) {
476
520
  case 'oauth':
477
- const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname })));
521
+ const oauthApp = oauth.getOAuthApp((await platformModule.getOauthInfo({ tokenUrl: user?.platformAdditionalInfo?.tokenUrl, hostname: user?.hostname, proxyId, proxyConfig })));
478
522
  user = await oauth.checkAndRefreshAccessToken(oauthApp, user);
479
523
  authHeader = `Bearer ${user.accessToken}`;
480
524
  break;
@@ -544,12 +588,12 @@ async function createMessageLog({ platform, userId, incomingData }) {
544
588
  });
545
589
  let crmLogId = ''
546
590
  if (existingSameDateMessageLog) {
547
- const updateMessageResult = await platformModule.updateMessageLog({ user, contactInfo, existingMessageLog: existingSameDateMessageLog, message, authHeader, additionalSubmission, imageLink, videoLink });
591
+ const updateMessageResult = await platformModule.updateMessageLog({ user, contactInfo, existingMessageLog: existingSameDateMessageLog, message, authHeader, additionalSubmission, imageLink, videoLink, proxyConfig });
548
592
  crmLogId = existingSameDateMessageLog.thirdPartyLogId;
549
593
  returnMessage = updateMessageResult?.returnMessage;
550
594
  }
551
595
  else {
552
- const createMessageLogResult = await platformModule.createMessageLog({ user, contactInfo, authHeader, message, additionalSubmission, recordingLink, faxDocLink, faxDownloadLink, imageLink, videoLink });
596
+ const createMessageLogResult = await platformModule.createMessageLog({ user, contactInfo, authHeader, message, additionalSubmission, recordingLink, faxDocLink, faxDownloadLink, imageLink, videoLink, proxyConfig });
553
597
  crmLogId = createMessageLogResult.logId;
554
598
  returnMessage = createMessageLogResult?.returnMessage;
555
599
  extraDataTracking = createMessageLogResult.extraDataTracking;