@app-connect/core 1.7.36 → 1.7.38
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/README.md +17 -16
- package/dist/connector/developerPortal.d.ts +6 -0
- package/{connector → dist/connector}/developerPortal.js +29 -12
- package/dist/connector/mock.d.ts +1 -0
- package/{connector → dist/connector}/mock.js +33 -17
- package/dist/connector/proxy/engine.d.ts +10 -0
- package/dist/connector/proxy/engine.js +222 -0
- package/dist/connector/proxy/index.d.ts +5 -0
- package/dist/connector/proxy/index.js +511 -0
- package/dist/connector/registry.d.ts +1 -0
- package/dist/connector/registry.js +243 -0
- package/dist/handlers/admin.d.ts +1 -0
- package/{handlers → dist/handlers}/admin.js +137 -78
- package/dist/handlers/appointment.d.ts +9 -0
- package/{handlers → dist/handlers}/appointment.js +58 -29
- package/dist/handlers/auth.d.ts +9 -0
- package/{handlers → dist/handlers}/auth.js +68 -40
- package/dist/handlers/calldown.d.ts +10 -0
- package/dist/handlers/calldown.js +134 -0
- package/dist/handlers/contact.d.ts +1 -0
- package/{handlers → dist/handlers}/contact.js +61 -39
- package/dist/handlers/disposition.d.ts +1 -0
- package/{handlers → dist/handlers}/disposition.js +20 -10
- package/dist/handlers/log.d.ts +1 -0
- package/{handlers → dist/handlers}/log.js +91 -124
- package/dist/handlers/managedAuth.d.ts +1 -0
- package/{handlers → dist/handlers}/managedAuth.js +134 -61
- package/dist/handlers/managedOAuth.d.ts +13 -0
- package/{handlers → dist/handlers}/managedOAuth.js +102 -30
- package/dist/handlers/plugin.d.ts +1 -0
- package/{handlers → dist/handlers}/plugin.js +59 -27
- package/dist/handlers/user.d.ts +1 -0
- package/{handlers → dist/handlers}/user.js +45 -27
- package/dist/index.d.ts +1 -0
- package/{index.js → dist/index.js} +548 -450
- package/dist/jest.config.d.ts +1 -0
- package/dist/jest.config.js +65 -0
- package/dist/lib/analytics.d.ts +4 -0
- package/{lib → dist/lib}/analytics.js +8 -6
- package/dist/lib/authSession.d.ts +5 -0
- package/{lib → dist/lib}/authSession.js +15 -43
- package/dist/lib/cacheCleanup.d.ts +4 -0
- package/{lib → dist/lib}/cacheCleanup.js +5 -17
- package/dist/lib/callLogComposer.d.ts +109 -0
- package/{lib → dist/lib}/callLogComposer.js +157 -197
- package/dist/lib/callLogLookup.d.ts +6 -0
- package/{lib → dist/lib}/callLogLookup.js +12 -34
- package/dist/lib/constants.d.ts +6 -0
- package/dist/lib/constants.js +9 -0
- package/dist/lib/debugTracer.d.ts +17 -0
- package/{lib → dist/lib}/debugTracer.js +7 -83
- package/dist/lib/encode.d.ts +3 -0
- package/dist/lib/encode.js +50 -0
- package/dist/lib/errorHandler.d.ts +7 -0
- package/dist/lib/errorHandler.js +161 -0
- package/dist/lib/generalErrorMessage.d.ts +7 -0
- package/{lib → dist/lib}/generalErrorMessage.js +6 -6
- package/dist/lib/jwt.d.ts +4 -0
- package/dist/lib/jwt.js +18 -0
- package/dist/lib/logger.d.ts +24 -0
- package/dist/lib/logger.js +126 -0
- package/dist/lib/migrateCallLogsSchema.d.ts +32 -0
- package/dist/lib/migrateCallLogsSchema.js +339 -0
- package/dist/lib/oauth.d.ts +4 -0
- package/{lib → dist/lib}/oauth.js +157 -160
- package/dist/lib/ringcentral.d.ts +24 -0
- package/dist/lib/ringcentral.js +226 -0
- package/dist/lib/s3ErrorLogReport.d.ts +4 -0
- package/{lib → dist/lib}/s3ErrorLogReport.js +11 -23
- package/dist/lib/sharedSMSComposer.d.ts +7 -0
- package/{lib → dist/lib}/sharedSMSComposer.js +21 -107
- package/dist/lib/util.d.ts +7 -0
- package/{lib → dist/lib}/util.js +9 -20
- package/dist/mcp/lib/oauthError.d.ts +1 -0
- package/dist/mcp/lib/oauthError.js +25 -0
- package/dist/mcp/lib/validator.d.ts +1 -0
- package/{mcp → dist/mcp}/lib/validator.js +16 -20
- package/dist/mcp/lib/widgetSessionToken.d.ts +1 -0
- package/dist/mcp/lib/widgetSessionToken.js +46 -0
- package/dist/mcp/mcpHandler.d.ts +8 -0
- package/{mcp → dist/mcp}/mcpHandler.js +98 -88
- package/dist/mcp/tools/cancelAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/cancelAppointment.js +7 -16
- package/dist/mcp/tools/checkAuthStatus.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/checkAuthStatus.js +21 -14
- package/dist/mcp/tools/confirmAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/confirmAppointment.js +7 -16
- package/dist/mcp/tools/createAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createAppointment.js +7 -19
- package/dist/mcp/tools/createCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createCallLog.js +18 -29
- package/dist/mcp/tools/createContact.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createContact.js +8 -20
- package/dist/mcp/tools/createMessageLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/createMessageLog.js +14 -26
- package/dist/mcp/tools/doAuth.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/doAuth.js +17 -13
- package/dist/mcp/tools/findContactByName.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/findContactByName.js +9 -15
- package/dist/mcp/tools/findContactByPhone.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/findContactByPhone.js +8 -15
- package/dist/mcp/tools/getCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getCallLog.js +12 -21
- package/dist/mcp/tools/getGoogleFilePicker.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getGoogleFilePicker.js +9 -18
- package/dist/mcp/tools/getHelp.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getHelp.js +5 -6
- package/dist/mcp/tools/getPublicConnectors.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getPublicConnectors.js +19 -18
- package/dist/mcp/tools/getSessionInfo.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/getSessionInfo.js +10 -16
- package/dist/mcp/tools/index.d.ts +8 -0
- package/dist/mcp/tools/index.js +50 -0
- package/dist/mcp/tools/listAppointments.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/listAppointments.js +7 -19
- package/dist/mcp/tools/logout.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/logout.js +16 -14
- package/dist/mcp/tools/rcGetCallLogs.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/rcGetCallLogs.js +10 -8
- package/dist/mcp/tools/updateAppointment.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/updateAppointment.js +17 -22
- package/dist/mcp/tools/updateCallLog.d.ts +1 -0
- package/{mcp → dist/mcp}/tools/updateCallLog.js +16 -26
- package/dist/models/accountDataModel.d.ts +3 -0
- package/dist/models/accountDataModel.js +39 -0
- package/dist/models/adminConfigModel.d.ts +2 -0
- package/dist/models/adminConfigModel.js +39 -0
- package/dist/models/cacheModel.d.ts +2 -0
- package/{models → dist/models}/cacheModel.js +7 -3
- package/dist/models/callDownListModel.d.ts +2 -0
- package/{models → dist/models}/callDownListModel.js +8 -4
- package/dist/models/callLogModel.d.ts +2 -0
- package/dist/models/callLogModel.js +43 -0
- package/dist/models/dynamo/connectorSchema.d.ts +2 -0
- package/dist/models/dynamo/connectorSchema.js +141 -0
- package/dist/models/dynamo/lockSchema.d.ts +2 -0
- package/{models → dist/models}/dynamo/lockSchema.js +5 -7
- package/dist/models/dynamo/noteCacheSchema.d.ts +2 -0
- package/{models → dist/models}/dynamo/noteCacheSchema.js +4 -6
- package/dist/models/llmSessionModel.d.ts +2 -0
- package/dist/models/llmSessionModel.js +21 -0
- package/dist/models/messageLogModel.d.ts +2 -0
- package/{models → dist/models}/messageLogModel.js +8 -4
- package/dist/models/sequelize.d.ts +2 -0
- package/dist/models/sequelize.js +68 -0
- package/dist/models/userModel.d.ts +2 -0
- package/dist/models/userModel.js +49 -0
- package/dist/package.json +100 -0
- package/dist/releaseNotes.json +1222 -0
- package/dist/tsconfig.json +14 -0
- package/dist/types/admin.d.ts +141 -0
- package/dist/types/analytics.d.ts +14 -0
- package/dist/types/appointment.d.ts +50 -0
- package/dist/types/auth.d.ts +137 -0
- package/dist/types/authSession.d.ts +35 -0
- package/dist/types/cacheCleanup.d.ts +12 -0
- package/dist/types/calldown.d.ts +54 -0
- package/dist/types/common.d.ts +46 -0
- package/dist/types/connector.d.ts +165 -0
- package/dist/types/contact.d.ts +125 -0
- package/dist/types/errorHandler.d.ts +60 -0
- package/dist/types/index.d.ts +76 -0
- package/dist/types/json.d.ts +9 -0
- package/dist/types/jwt.d.ts +8 -0
- package/dist/types/logging.d.ts +224 -0
- package/dist/types/managedAuth.d.ts +114 -0
- package/dist/types/managedOAuth.d.ts +59 -0
- package/dist/types/manifest.d.ts +120 -0
- package/dist/types/migration.d.ts +15 -0
- package/dist/types/plugin.d.ts +74 -0
- package/dist/types/ringcentral.d.ts +61 -0
- package/dist/types/s3ErrorLogReport.d.ts +16 -0
- package/dist/types/sharedSMSComposer.d.ts +105 -0
- package/dist/types/user.d.ts +46 -0
- package/dist/types/util.d.ts +7 -0
- package/package.json +34 -6
- package/releaseNotes.json +13 -1
- package/.env.test +0 -5
- package/connector/proxy/engine.js +0 -165
- package/connector/proxy/index.js +0 -500
- package/connector/registry.js +0 -252
- package/docs/README.md +0 -50
- package/docs/architecture.md +0 -94
- package/docs/connectors.md +0 -116
- package/docs/handlers.md +0 -128
- package/docs/libraries.md +0 -98
- package/docs/models.md +0 -146
- package/docs/routes.md +0 -119
- package/docs/tests.md +0 -73
- package/handlers/calldown.js +0 -99
- package/jest.config.js +0 -57
- package/lib/constants.js +0 -9
- package/lib/encode.js +0 -30
- package/lib/errorHandler.js +0 -218
- package/lib/jwt.js +0 -18
- package/lib/logger.js +0 -190
- package/lib/migrateCallLogsSchema.js +0 -237
- package/lib/ringcentral.js +0 -267
- package/mcp/README.md +0 -420
- package/mcp/tools/index.js +0 -51
- package/mcp/ui/App/App.tsx +0 -358
- package/mcp/ui/App/components/AuthInfoForm.tsx +0 -113
- package/mcp/ui/App/components/AuthSuccess.tsx +0 -22
- package/mcp/ui/App/components/ConnectorList.tsx +0 -82
- package/mcp/ui/App/components/DebugPanel.tsx +0 -43
- package/mcp/ui/App/components/OAuthConnect.tsx +0 -270
- package/mcp/ui/App/lib/callTool.ts +0 -130
- package/mcp/ui/App/lib/debugLog.ts +0 -41
- package/mcp/ui/App/lib/developerPortal.ts +0 -111
- package/mcp/ui/App/main.css +0 -6
- package/mcp/ui/App/root.tsx +0 -13
- package/mcp/ui/dist/index.html +0 -53
- package/mcp/ui/vite.config.ts +0 -16
- package/models/accountDataModel.js +0 -34
- package/models/adminConfigModel.js +0 -35
- package/models/callLogModel.js +0 -39
- package/models/dynamo/connectorSchema.js +0 -146
- package/models/llmSessionModel.js +0 -17
- package/models/sequelize.js +0 -17
- package/models/userModel.js +0 -45
- package/test/connector/developerPortal.test.js +0 -166
- package/test/connector/mock.test.js +0 -131
- package/test/connector/proxy/engine.test.js +0 -211
- package/test/connector/proxy/index.test.js +0 -525
- package/test/connector/proxy/sample.json +0 -162
- package/test/connector/registry.test.js +0 -416
- package/test/handlers/admin.test.js +0 -960
- package/test/handlers/appointment.test.js +0 -260
- package/test/handlers/auth.test.js +0 -1096
- package/test/handlers/calldown.test.js +0 -310
- package/test/handlers/contact.test.js +0 -1014
- package/test/handlers/disposition.test.js +0 -396
- package/test/handlers/log.test.js +0 -1847
- package/test/handlers/managedAuth.test.js +0 -458
- package/test/handlers/managedOAuth.test.js +0 -262
- package/test/handlers/plugin.test.js +0 -429
- package/test/handlers/user.test.js +0 -381
- package/test/index.test.js +0 -301
- package/test/lib/analytics.test.js +0 -146
- package/test/lib/authSession.test.js +0 -173
- package/test/lib/cacheCleanup.test.js +0 -127
- package/test/lib/callLogComposer.test.js +0 -1231
- package/test/lib/debugTracer.test.js +0 -328
- package/test/lib/encode.test.js +0 -59
- package/test/lib/errorHandler.test.js +0 -246
- package/test/lib/generalErrorMessage.test.js +0 -82
- package/test/lib/jwt.test.js +0 -176
- package/test/lib/logger.test.js +0 -206
- package/test/lib/oauth.test.js +0 -359
- package/test/lib/ringcentral.test.js +0 -467
- package/test/lib/s3ErrorLogReport.test.js +0 -187
- package/test/lib/sharedSMSComposer.test.js +0 -1084
- package/test/lib/util.test.js +0 -329
- package/test/mcp/mcpHandler.test.js +0 -73
- package/test/mcp/mcpHandlerMore.test.js +0 -384
- package/test/mcp/tools/appointmentTools.test.js +0 -362
- package/test/mcp/tools/checkAuthStatus.test.js +0 -83
- package/test/mcp/tools/createCallLog.test.js +0 -436
- package/test/mcp/tools/createContact.test.js +0 -58
- package/test/mcp/tools/createMessageLog.test.js +0 -595
- package/test/mcp/tools/doAuth.test.js +0 -113
- package/test/mcp/tools/findContactByName.test.js +0 -275
- package/test/mcp/tools/findContactByPhone.test.js +0 -296
- package/test/mcp/tools/getCallLog.test.js +0 -298
- package/test/mcp/tools/getGoogleFilePicker.test.js +0 -281
- package/test/mcp/tools/getPublicConnectors.test.js +0 -107
- package/test/mcp/tools/getSessionInfo.test.js +0 -127
- package/test/mcp/tools/logout.test.js +0 -233
- package/test/mcp/tools/rcGetCallLogs.test.js +0 -56
- package/test/mcp/tools/updateCallLog.test.js +0 -360
- package/test/models/accountDataModel.test.js +0 -98
- package/test/models/callDownListModel.test.js +0 -125
- package/test/models/dynamo/connectorSchema.test.js +0 -189
- package/test/models/dynamo/lockSchema.test.js +0 -37
- package/test/models/dynamo/noteCacheSchema.test.js +0 -45
- package/test/models/llmSessionModel.test.js +0 -91
- package/test/models/models.test.js +0 -660
- package/test/routes/calldownRoutes.test.js +0 -224
- package/test/routes/coreRouterBroadRoutes.test.js +0 -855
- package/test/routes/dispositionRoutes.test.js +0 -192
- package/test/routes/managedAuthRoutes.test.js +0 -386
- package/test/routes/pluginRoutes.test.js +0 -262
- package/test/setup.js +0 -178
- /package/{mcp → dist/mcp}/ui/index.html +0 -0
- /package/{mcp → dist/mcp}/ui/package-lock.json +0 -0
- /package/{mcp → dist/mcp}/ui/package.json +0 -0
- /package/{mcp → dist/mcp}/ui/tsconfig.json +0 -0
|
@@ -1,34 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const {
|
|
6
|
-
const
|
|
7
|
-
const {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-check
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const Op = /** @type {any} */ (require('sequelize')).Op;
|
|
5
|
+
const { CallLogModel: RawCallLogModel } = require('../models/callLogModel');
|
|
6
|
+
const CallLogModel = /** @type {any} */ (RawCallLogModel);
|
|
7
|
+
const { MessageLogModel: RawMessageLogModel } = require('../models/messageLogModel');
|
|
8
|
+
const MessageLogModel = /** @type {any} */ (RawMessageLogModel);
|
|
9
|
+
const { UserModel: RawUserModel } = require('../models/userModel');
|
|
10
|
+
const UserModel = /** @type {any} */ (RawUserModel);
|
|
11
|
+
const { CacheModel: RawCacheModel } = require('../models/cacheModel');
|
|
12
|
+
const CacheModel = /** @type {any} */ (RawCacheModel);
|
|
13
|
+
const oauth = /** @type {any} */ (require('../lib/oauth'));
|
|
14
|
+
const { composeCallLog: rawComposeCallLog } = require('../lib/callLogComposer');
|
|
15
|
+
const composeCallLog = /** @type {any} */ (rawComposeCallLog);
|
|
16
|
+
const { composeSharedSMSLog: rawComposeSharedSMSLog } = require('../lib/sharedSMSComposer');
|
|
17
|
+
const composeSharedSMSLog = /** @type {any} */ (rawComposeSharedSMSLog);
|
|
18
|
+
const connectorRegistry = /** @type {any} */ (require('../connector/registry'));
|
|
10
19
|
const { LOG_DETAILS_FORMAT_TYPE } = require('../lib/constants');
|
|
11
|
-
const { NoteCache } = require('../models/dynamo/noteCacheSchema');
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
20
|
+
const { NoteCache: RawNoteCache } = require('../models/dynamo/noteCacheSchema');
|
|
21
|
+
const NoteCache = /** @type {any} */ (RawNoteCache);
|
|
22
|
+
const { Connector: RawConnector } = require('../models/dynamo/connectorSchema');
|
|
23
|
+
const Connector = /** @type {any} */ (RawConnector);
|
|
24
|
+
const moment = /** @type {any} */ (require('moment'));
|
|
25
|
+
const { getMediaReaderLinkByPlatformMediaLink: rawGetMediaReaderLinkByPlatformMediaLink } = require('../lib/util');
|
|
26
|
+
const getMediaReaderLinkByPlatformMediaLink = /** @type {any} */ (rawGetMediaReaderLinkByPlatformMediaLink);
|
|
27
|
+
const axios = /** @type {any} */ (require('axios'));
|
|
28
|
+
const logger = /** @type {any} */ (require('../lib/logger'));
|
|
29
|
+
const { handleApiError: rawHandleApiError, handleDatabaseError: rawHandleDatabaseError } = require('../lib/errorHandler');
|
|
30
|
+
const handleApiError = /** @type {any} */ (rawHandleApiError);
|
|
31
|
+
const handleDatabaseError = /** @type {any} */ (rawHandleDatabaseError);
|
|
18
32
|
const { randomUUID } = require('crypto');
|
|
19
|
-
const { AccountDataModel } = require('../models/accountDataModel');
|
|
20
|
-
const
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
const { AccountDataModel: RawAccountDataModel } = require('../models/accountDataModel');
|
|
34
|
+
const AccountDataModel = /** @type {any} */ (RawAccountDataModel);
|
|
35
|
+
const pluginCore = /** @type {any} */ (require('./plugin'));
|
|
36
|
+
const { getCallLogExtensionNumber: rawGetCallLogExtensionNumber, getCallLogHashedExtensionId: rawGetCallLogHashedExtensionId, buildCallLogSessionWhere: rawBuildCallLogSessionWhere, findMatchingCallLog: rawFindMatchingCallLog, } = require('../lib/callLogLookup');
|
|
37
|
+
const getCallLogExtensionNumber = /** @type {any} */ (rawGetCallLogExtensionNumber);
|
|
38
|
+
const getCallLogHashedExtensionId = /** @type {any} */ (rawGetCallLogHashedExtensionId);
|
|
39
|
+
const buildCallLogSessionWhere = /** @type {any} */ (rawBuildCallLogSessionWhere);
|
|
40
|
+
const findMatchingCallLog = /** @type {any} */ (rawFindMatchingCallLog);
|
|
28
41
|
const ASYNC_PLUGIN_CACHE_KEY = 'asyncPluginTask';
|
|
29
42
|
const ASYNC_PLUGIN_CALLBACK_PATH = '/plugin/async-callback';
|
|
30
43
|
const ASYNC_PLUGIN_CACHE_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
31
|
-
|
|
32
44
|
function mergePluginWarnings({ returnMessage, warningMessages }) {
|
|
33
45
|
if (!warningMessages.length) {
|
|
34
46
|
return returnMessage;
|
|
@@ -47,19 +59,16 @@ function mergePluginWarnings({ returnMessage, warningMessages }) {
|
|
|
47
59
|
messageType: returnMessage.messageType === 'error' ? 'error' : 'warning',
|
|
48
60
|
};
|
|
49
61
|
}
|
|
50
|
-
|
|
51
62
|
function getAsyncPluginCallbackUrl(taskId) {
|
|
52
63
|
const appServer = (process.env.APP_SERVER || process.env.OVERRIDE_APP_SERVER || '').replace(/\/+$/, '');
|
|
53
64
|
return `${appServer}${ASYNC_PLUGIN_CALLBACK_PATH}/${taskId}`;
|
|
54
65
|
}
|
|
55
|
-
|
|
56
66
|
function getAsyncPluginRequestData({ operation, incomingData }) {
|
|
57
67
|
if (operation === 'updateCallLog') {
|
|
58
68
|
return { logInfo: incomingData };
|
|
59
69
|
}
|
|
60
70
|
return incomingData;
|
|
61
71
|
}
|
|
62
|
-
|
|
63
72
|
function buildAsyncPluginTaskData({ taskId, callbackUrl, pluginId, platform, operation, user, incomingData, existingCallLog, hashedAccountId, isFromSSCL }) {
|
|
64
73
|
const logInfo = incomingData?.logInfo ?? incomingData ?? {};
|
|
65
74
|
return {
|
|
@@ -83,14 +92,12 @@ function buildAsyncPluginTaskData({ taskId, callbackUrl, pluginId, platform, ope
|
|
|
83
92
|
isFromSSCL,
|
|
84
93
|
};
|
|
85
94
|
}
|
|
86
|
-
|
|
87
95
|
function splitCallPluginsByExecutionMode(callPlugins) {
|
|
88
96
|
return {
|
|
89
97
|
syncCallPlugins: callPlugins.filter(plugin => !plugin.data.isAsync),
|
|
90
98
|
asyncCallPlugins: callPlugins.filter(plugin => plugin.data.isAsync),
|
|
91
99
|
};
|
|
92
100
|
}
|
|
93
|
-
|
|
94
101
|
async function runSyncCallPlugins({ syncCallPlugins, incomingData, user, platform }) {
|
|
95
102
|
let processedIncomingData = incomingData;
|
|
96
103
|
for (const plugin of syncCallPlugins) {
|
|
@@ -123,7 +130,6 @@ async function runSyncCallPlugins({ syncCallPlugins, incomingData, user, platfor
|
|
|
123
130
|
}
|
|
124
131
|
return processedIncomingData;
|
|
125
132
|
}
|
|
126
|
-
|
|
127
133
|
async function markAsyncPluginTaskFailed(cache, message) {
|
|
128
134
|
if (!cache) {
|
|
129
135
|
return;
|
|
@@ -136,7 +142,6 @@ async function markAsyncPluginTaskFailed(cache, message) {
|
|
|
136
142
|
},
|
|
137
143
|
});
|
|
138
144
|
}
|
|
139
|
-
|
|
140
145
|
async function dispatchAsyncCallPlugin({ plugin, incomingData, user, platform, operation, existingCallLog, hashedAccountId, isFromSSCL }) {
|
|
141
146
|
const pluginId = plugin.id;
|
|
142
147
|
const taskId = randomUUID();
|
|
@@ -163,7 +168,6 @@ async function dispatchAsyncCallPlugin({ plugin, incomingData, user, platform, o
|
|
|
163
168
|
data: taskData,
|
|
164
169
|
expiry: new Date(Date.now() + ASYNC_PLUGIN_CACHE_TTL_MS),
|
|
165
170
|
});
|
|
166
|
-
|
|
167
171
|
const pluginJwtToken = plugin.data.jwtToken;
|
|
168
172
|
const pluginEndpointUrl = plugin.data.endpointUrl;
|
|
169
173
|
if (!pluginEndpointUrl) {
|
|
@@ -172,13 +176,11 @@ async function dispatchAsyncCallPlugin({ plugin, incomingData, user, platform, o
|
|
|
172
176
|
if (!plugin.data.tokenSyncUrl) {
|
|
173
177
|
throw new Error('Plugin token sync URL is not set');
|
|
174
178
|
}
|
|
175
|
-
const syncPluginTokenResponse = await axios.post(plugin.data.tokenSyncUrl, {},
|
|
176
|
-
{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
);
|
|
179
|
+
const syncPluginTokenResponse = await axios.post(plugin.data.tokenSyncUrl, {}, {
|
|
180
|
+
headers: {
|
|
181
|
+
Authorization: `Bearer ${pluginJwtToken}`,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
182
184
|
const syncedPluginJwtToken = pluginCore.getRefreshedJwtTokenFromHeaders({ headers: syncPluginTokenResponse.headers });
|
|
183
185
|
await axios.post(pluginEndpointUrl, {
|
|
184
186
|
data: getAsyncPluginRequestData({ operation, incomingData }),
|
|
@@ -217,7 +219,6 @@ async function dispatchAsyncCallPlugin({ plugin, incomingData, user, platform, o
|
|
|
217
219
|
}
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
|
-
|
|
221
222
|
async function dispatchAsyncCallPlugins({ asyncCallPlugins, incomingData, user, platform, operation, existingCallLog, hashedAccountId, isFromSSCL }) {
|
|
222
223
|
for (const plugin of asyncCallPlugins) {
|
|
223
224
|
await dispatchAsyncCallPlugin({
|
|
@@ -232,7 +233,6 @@ async function dispatchAsyncCallPlugins({ asyncCallPlugins, incomingData, user,
|
|
|
232
233
|
});
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
|
-
|
|
236
236
|
async function getAuthenticatedCallLogContext({ platform, userId }) {
|
|
237
237
|
let user = await UserModel.findByPk(userId);
|
|
238
238
|
if (!user || !user.accessToken) {
|
|
@@ -264,11 +264,9 @@ async function getAuthenticatedCallLogContext({ platform, userId }) {
|
|
|
264
264
|
}
|
|
265
265
|
return { user, platformModule, authHeader, proxyConfig };
|
|
266
266
|
}
|
|
267
|
-
|
|
268
267
|
function appendCallbackNote(existingNote, callbackNote) {
|
|
269
268
|
return [existingNote, callbackNote].filter(note => !!note).join('\n\n');
|
|
270
269
|
}
|
|
271
|
-
|
|
272
270
|
function getCallbackUpdateData({ incomingData, existingCallLog, appendedNote }) {
|
|
273
271
|
const logInfo = incomingData?.logInfo ?? incomingData ?? {};
|
|
274
272
|
return {
|
|
@@ -302,7 +300,6 @@ function getCallbackUpdateData({ incomingData, existingCallLog, appendedNote })
|
|
|
302
300
|
},
|
|
303
301
|
};
|
|
304
302
|
}
|
|
305
|
-
|
|
306
303
|
async function appendAsyncPluginNoteToCallLog({ taskCache, note }) {
|
|
307
304
|
const taskData = taskCache.data || {};
|
|
308
305
|
const where = {
|
|
@@ -318,17 +315,10 @@ async function appendAsyncPluginNoteToCallLog({ taskCache, note }) {
|
|
|
318
315
|
if (!existingCallLog) {
|
|
319
316
|
throw new Error('Call log not found for async plugin task');
|
|
320
317
|
}
|
|
321
|
-
|
|
322
|
-
const {
|
|
323
|
-
user,
|
|
324
|
-
platformModule,
|
|
325
|
-
authHeader,
|
|
326
|
-
proxyConfig,
|
|
327
|
-
} = await getAuthenticatedCallLogContext({
|
|
318
|
+
const { user, platformModule, authHeader, proxyConfig, } = await getAuthenticatedCallLogContext({
|
|
328
319
|
platform: taskData.platform,
|
|
329
320
|
userId: taskData.userId,
|
|
330
321
|
});
|
|
331
|
-
|
|
332
322
|
const logFormat = platformModule.getLogFormatType ? platformModule.getLogFormatType(taskData.platform, proxyConfig) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
|
|
333
323
|
const getLogResult = await platformModule.getCallLog({
|
|
334
324
|
user,
|
|
@@ -366,7 +356,6 @@ async function appendAsyncPluginNoteToCallLog({ taskCache, note }) {
|
|
|
366
356
|
ringSenseBulletedSummary: updateData.ringSenseBulletedSummary,
|
|
367
357
|
ringSenseLink: updateData.ringSenseLink,
|
|
368
358
|
});
|
|
369
|
-
|
|
370
359
|
await platformModule.updateCallLog({
|
|
371
360
|
user,
|
|
372
361
|
existingCallLog,
|
|
@@ -393,7 +382,6 @@ async function appendAsyncPluginNoteToCallLog({ taskCache, note }) {
|
|
|
393
382
|
proxyConfig,
|
|
394
383
|
});
|
|
395
384
|
}
|
|
396
|
-
|
|
397
385
|
async function handleAsyncPluginCallback({ taskId, body }) {
|
|
398
386
|
if (typeof body?.successful !== 'boolean') {
|
|
399
387
|
return {
|
|
@@ -415,7 +403,6 @@ async function handleAsyncPluginCallback({ taskId, body }) {
|
|
|
415
403
|
body: { successful: false, message: 'Async task not found' },
|
|
416
404
|
};
|
|
417
405
|
}
|
|
418
|
-
|
|
419
406
|
if (!body.successful) {
|
|
420
407
|
await markAsyncPluginTaskFailed(taskCache, body.message || 'Async plugin callback failed');
|
|
421
408
|
return {
|
|
@@ -423,7 +410,6 @@ async function handleAsyncPluginCallback({ taskId, body }) {
|
|
|
423
410
|
body: { successful: true },
|
|
424
411
|
};
|
|
425
412
|
}
|
|
426
|
-
|
|
427
413
|
try {
|
|
428
414
|
await appendAsyncPluginNoteToCallLog({
|
|
429
415
|
taskCache,
|
|
@@ -447,7 +433,6 @@ async function handleAsyncPluginCallback({ taskId, body }) {
|
|
|
447
433
|
};
|
|
448
434
|
}
|
|
449
435
|
}
|
|
450
|
-
|
|
451
436
|
async function createCallLog({ platform, userId, incomingData, hashedAccountId, isFromSSCL }) {
|
|
452
437
|
try {
|
|
453
438
|
const extensionNumber = getCallLogExtensionNumber(incomingData);
|
|
@@ -473,7 +458,7 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
473
458
|
messageType: 'warning',
|
|
474
459
|
ttl: 3000
|
|
475
460
|
}
|
|
476
|
-
}
|
|
461
|
+
};
|
|
477
462
|
}
|
|
478
463
|
let user = null;
|
|
479
464
|
try {
|
|
@@ -492,7 +477,6 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
492
477
|
}
|
|
493
478
|
};
|
|
494
479
|
}
|
|
495
|
-
|
|
496
480
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
497
481
|
const callLog = incomingData.logInfo;
|
|
498
482
|
const additionalSubmission = incomingData.additionalSubmission;
|
|
@@ -525,7 +509,7 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
525
509
|
ttl: 5000
|
|
526
510
|
},
|
|
527
511
|
isRevokeUserSession: true
|
|
528
|
-
}
|
|
512
|
+
};
|
|
529
513
|
}
|
|
530
514
|
authHeader = `Bearer ${user.accessToken}`;
|
|
531
515
|
break;
|
|
@@ -552,7 +536,6 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
552
536
|
type: incomingData.contactType ?? "",
|
|
553
537
|
name: incomingData.contactName ?? ""
|
|
554
538
|
};
|
|
555
|
-
|
|
556
539
|
const pluginWarnings = [];
|
|
557
540
|
// Plugins
|
|
558
541
|
const accountPlugins = await pluginCore.getPluginsFromRcAccountId({ rcAccountId: user.rcAccountId });
|
|
@@ -560,7 +543,6 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
560
543
|
const { syncCallPlugins, asyncCallPlugins } = splitCallPluginsByExecutionMode(callPlugins);
|
|
561
544
|
incomingData = await runSyncCallPlugins({ syncCallPlugins, incomingData, user, platform });
|
|
562
545
|
note = incomingData.note;
|
|
563
|
-
|
|
564
546
|
// Compose call log details centrally
|
|
565
547
|
const logFormat = platformModule.getLogFormatType ? platformModule.getLogFormatType(platform, proxyConfig) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
|
|
566
548
|
let composedLogDetails = '';
|
|
@@ -586,7 +568,6 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
586
568
|
ringSenseLink: incomingData.ringSenseLink,
|
|
587
569
|
});
|
|
588
570
|
}
|
|
589
|
-
|
|
590
571
|
let { logId, returnMessage, extraDataTracking } = await platformModule.createCallLog({
|
|
591
572
|
user,
|
|
592
573
|
contactInfo,
|
|
@@ -652,11 +633,11 @@ async function createCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
652
633
|
returnMessage
|
|
653
634
|
};
|
|
654
635
|
}
|
|
655
|
-
}
|
|
636
|
+
}
|
|
637
|
+
catch (e) {
|
|
656
638
|
return handleApiError(e, platform, 'createCallLog', { userId });
|
|
657
639
|
}
|
|
658
640
|
}
|
|
659
|
-
|
|
660
641
|
async function getCallLog({ userId, sessionIds, extensionNumber, hashedExtensionId, platform, requireDetails }) {
|
|
661
642
|
try {
|
|
662
643
|
let user = await UserModel.findByPk(userId);
|
|
@@ -666,17 +647,14 @@ async function getCallLog({ userId, sessionIds, extensionNumber, hashedExtension
|
|
|
666
647
|
let logs = [];
|
|
667
648
|
let returnMessage = null;
|
|
668
649
|
let extraDataTracking = {};
|
|
669
|
-
|
|
670
650
|
// Handle undefined or null sessionIds
|
|
671
651
|
if (!sessionIds) {
|
|
672
652
|
return { successful: false, message: `No session IDs provided` };
|
|
673
653
|
}
|
|
674
|
-
|
|
675
654
|
let sessionIdsArray = sessionIds.split(',');
|
|
676
655
|
if (sessionIdsArray.length > 5) {
|
|
677
656
|
sessionIdsArray = sessionIdsArray.slice(0, 5);
|
|
678
657
|
}
|
|
679
|
-
|
|
680
658
|
if (requireDetails) {
|
|
681
659
|
const proxyId = user.platformAdditionalInfo?.proxyId;
|
|
682
660
|
let proxyConfig = null;
|
|
@@ -699,7 +677,7 @@ async function getCallLog({ userId, sessionIds, extensionNumber, hashedExtension
|
|
|
699
677
|
ttl: 5000
|
|
700
678
|
},
|
|
701
679
|
isRevokeUserSession: true
|
|
702
|
-
}
|
|
680
|
+
};
|
|
703
681
|
}
|
|
704
682
|
authHeader = `Bearer ${user.accessToken}`;
|
|
705
683
|
break;
|
|
@@ -758,7 +736,6 @@ async function getCallLog({ userId, sessionIds, extensionNumber, hashedExtension
|
|
|
758
736
|
return handleApiError(e, platform, 'getCallLog', { userId, sessionIds, requireDetails, extensionNumber, hashedExtensionId });
|
|
759
737
|
}
|
|
760
738
|
}
|
|
761
|
-
|
|
762
739
|
async function updateCallLog({ platform, userId, incomingData, hashedAccountId, isFromSSCL }) {
|
|
763
740
|
try {
|
|
764
741
|
const extensionNumber = getCallLogExtensionNumber(incomingData);
|
|
@@ -802,7 +779,7 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
802
779
|
ttl: 5000
|
|
803
780
|
},
|
|
804
781
|
isRevokeUserSession: true
|
|
805
|
-
}
|
|
782
|
+
};
|
|
806
783
|
}
|
|
807
784
|
authHeader = `Bearer ${user.accessToken}`;
|
|
808
785
|
break;
|
|
@@ -811,16 +788,14 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
811
788
|
authHeader = `Basic ${basicAuth}`;
|
|
812
789
|
break;
|
|
813
790
|
}
|
|
814
|
-
|
|
815
791
|
const pluginWarnings = [];
|
|
816
792
|
// Plugins
|
|
817
793
|
const accountPlugins = await pluginCore.getPluginsFromRcAccountId({ rcAccountId: user.rcAccountId });
|
|
818
794
|
const callPlugins = accountPlugins.filter(plugin => plugin.data.supportedLogTypes.includes('call'));
|
|
819
795
|
const { syncCallPlugins, asyncCallPlugins } = splitCallPluginsByExecutionMode(callPlugins);
|
|
820
796
|
incomingData = await runSyncCallPlugins({ syncCallPlugins, incomingData, user, platform });
|
|
821
|
-
|
|
822
797
|
// Fetch existing call log details once to avoid duplicate API calls
|
|
823
|
-
let existingCallLogDetails = null;
|
|
798
|
+
let existingCallLogDetails = null; // Compose updated call log details centrally
|
|
824
799
|
const logFormat = platformModule.getLogFormatType ? platformModule.getLogFormatType(platform, proxyConfig) : LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT;
|
|
825
800
|
let composedLogDetails = '';
|
|
826
801
|
if (logFormat === LOG_DETAILS_FORMAT_TYPE.PLAIN_TEXT || logFormat === LOG_DETAILS_FORMAT_TYPE.HTML || logFormat === LOG_DETAILS_FORMAT_TYPE.MARKDOWN) {
|
|
@@ -838,10 +813,12 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
838
813
|
// Extract existing body from the platform-specific response
|
|
839
814
|
if (getLogResult.callLogInfo?.fullBody) {
|
|
840
815
|
existingBody = getLogResult.callLogInfo.fullBody;
|
|
841
|
-
}
|
|
816
|
+
}
|
|
817
|
+
else if (getLogResult.callLogInfo?.note) {
|
|
842
818
|
existingBody = getLogResult.callLogInfo.note;
|
|
843
819
|
}
|
|
844
|
-
}
|
|
820
|
+
}
|
|
821
|
+
catch (error) {
|
|
845
822
|
logger.error('Error getting existing log details, proceeding with empty body', { stack: error.stack });
|
|
846
823
|
}
|
|
847
824
|
composedLogDetails = composeCallLog({
|
|
@@ -874,7 +851,6 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
874
851
|
ringSenseLink: incomingData.ringSenseLink,
|
|
875
852
|
});
|
|
876
853
|
}
|
|
877
|
-
|
|
878
854
|
let { updatedNote, returnMessage, extraDataTracking } = await platformModule.updateCallLog({
|
|
879
855
|
user,
|
|
880
856
|
existingCallLog,
|
|
@@ -896,7 +872,7 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
896
872
|
ringSenseLink: incomingData.ringSenseLink,
|
|
897
873
|
additionalSubmission: incomingData.additionalSubmission,
|
|
898
874
|
composedLogDetails,
|
|
899
|
-
existingCallLogDetails,
|
|
875
|
+
existingCallLogDetails, // Pass the fetched details to avoid duplicate API calls
|
|
900
876
|
hashedAccountId,
|
|
901
877
|
isFromSSCL,
|
|
902
878
|
proxyConfig,
|
|
@@ -922,11 +898,11 @@ async function updateCallLog({ platform, userId, incomingData, hashedAccountId,
|
|
|
922
898
|
};
|
|
923
899
|
}
|
|
924
900
|
return { successful: false };
|
|
925
|
-
}
|
|
901
|
+
}
|
|
902
|
+
catch (e) {
|
|
926
903
|
return handleApiError(e, platform, 'updateCallLog', { userId });
|
|
927
904
|
}
|
|
928
905
|
}
|
|
929
|
-
|
|
930
906
|
async function createMessageLog({ platform, userId, incomingData }) {
|
|
931
907
|
try {
|
|
932
908
|
let returnMessage = null;
|
|
@@ -934,13 +910,12 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
934
910
|
if (incomingData.logInfo.messages.length === 0) {
|
|
935
911
|
return {
|
|
936
912
|
successful: false,
|
|
937
|
-
returnMessage:
|
|
938
|
-
{
|
|
913
|
+
returnMessage: {
|
|
939
914
|
message: 'No message to log.',
|
|
940
915
|
messageType: 'warning',
|
|
941
916
|
ttl: 3000
|
|
942
917
|
}
|
|
943
|
-
}
|
|
918
|
+
};
|
|
944
919
|
}
|
|
945
920
|
const platformModule = connectorRegistry.getConnector(platform);
|
|
946
921
|
const contactNumber = incomingData.logInfo.correspondents[0].phoneNumber;
|
|
@@ -955,8 +930,7 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
955
930
|
if (!user || !user.accessToken) {
|
|
956
931
|
return {
|
|
957
932
|
successful: false,
|
|
958
|
-
returnMessage:
|
|
959
|
-
{
|
|
933
|
+
returnMessage: {
|
|
960
934
|
message: `Contact not found`,
|
|
961
935
|
messageType: 'warning',
|
|
962
936
|
ttl: 5000
|
|
@@ -983,7 +957,7 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
983
957
|
ttl: 5000
|
|
984
958
|
},
|
|
985
959
|
isRevokeUserSession: true
|
|
986
|
-
}
|
|
960
|
+
};
|
|
987
961
|
}
|
|
988
962
|
authHeader = `Bearer ${user.accessToken}`;
|
|
989
963
|
break;
|
|
@@ -996,8 +970,7 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
996
970
|
if (!contactId) {
|
|
997
971
|
return {
|
|
998
972
|
successful: false,
|
|
999
|
-
returnMessage:
|
|
1000
|
-
{
|
|
973
|
+
returnMessage: {
|
|
1001
974
|
message: `Contact not found for number ${contactNumber}`,
|
|
1002
975
|
messageType: 'warning',
|
|
1003
976
|
ttl: 5000
|
|
@@ -1015,7 +988,6 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1015
988
|
const assigneeName = incomingData.logInfo.assignee?.name;
|
|
1016
989
|
const ownerName = incomingData.logInfo.owner?.name;
|
|
1017
990
|
const isSharedSMS = !!ownerName;
|
|
1018
|
-
|
|
1019
991
|
const pluginWarnings = [];
|
|
1020
992
|
// Plugins
|
|
1021
993
|
const isSMS = incomingData.logInfo.messages.some(m => m.type === 'SMS');
|
|
@@ -1035,13 +1007,11 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1035
1007
|
const userConfig = pluginCore.getPluginConfigFromUserSettings({ userSettings: user.userSettings, pluginId });
|
|
1036
1008
|
if (plugin.data.isAsync) {
|
|
1037
1009
|
try {
|
|
1038
|
-
const syncPluginTokenResponse = await axios.post(plugin.data.tokenSyncUrl, {},
|
|
1039
|
-
{
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}
|
|
1044
|
-
);
|
|
1010
|
+
const syncPluginTokenResponse = await axios.post(plugin.data.tokenSyncUrl, {}, {
|
|
1011
|
+
headers: {
|
|
1012
|
+
Authorization: `Bearer ${pluginJwtToken}`,
|
|
1013
|
+
},
|
|
1014
|
+
});
|
|
1045
1015
|
const syncedPluginJwtToken = pluginCore.getRefreshedJwtTokenFromHeaders({ headers: syncPluginTokenResponse.headers });
|
|
1046
1016
|
axios.post(pluginEndpointUrl, {
|
|
1047
1017
|
data: { logInfo: incomingData },
|
|
@@ -1086,7 +1056,6 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1086
1056
|
incomingData = processedResultResponse.data;
|
|
1087
1057
|
}
|
|
1088
1058
|
}
|
|
1089
|
-
|
|
1090
1059
|
let messageIds = [];
|
|
1091
1060
|
const correspondents = [];
|
|
1092
1061
|
if (isGroupSMS) {
|
|
@@ -1099,7 +1068,7 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1099
1068
|
platformName: platform,
|
|
1100
1069
|
dataKey: `contact-${incomingData.logInfo.correspondents[i].phoneNumber}`
|
|
1101
1070
|
}
|
|
1102
|
-
})
|
|
1071
|
+
});
|
|
1103
1072
|
if (correspondentContactInfo && correspondentContactInfo.data[0]?.name != incomingData.contactName) {
|
|
1104
1073
|
correspondents.push(correspondentContactInfo.data);
|
|
1105
1074
|
}
|
|
@@ -1138,15 +1107,14 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1138
1107
|
returnMessage = createMessageLogResult?.returnMessage;
|
|
1139
1108
|
extraDataTracking = createMessageLogResult.extraDataTracking;
|
|
1140
1109
|
if (createMessageLogResult.logId) {
|
|
1141
|
-
const createdMessageLog =
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
});
|
|
1110
|
+
const createdMessageLog = await MessageLogModel.create({
|
|
1111
|
+
id: incomingData.logInfo.conversationLogId,
|
|
1112
|
+
platform,
|
|
1113
|
+
conversationId: incomingData.logInfo.conversationId,
|
|
1114
|
+
thirdPartyLogId: createMessageLogResult.logId,
|
|
1115
|
+
userId,
|
|
1116
|
+
conversationLogId: incomingData.logInfo.conversationLogId
|
|
1117
|
+
});
|
|
1150
1118
|
logIds.push(createdMessageLog.id);
|
|
1151
1119
|
}
|
|
1152
1120
|
}
|
|
@@ -1176,7 +1144,7 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1176
1144
|
let faxDownloadLink = null;
|
|
1177
1145
|
if (message.attachments && message.attachments.some(a => a.type === 'RenderedDocument') && incomingData.logInfo.rcAccessToken) {
|
|
1178
1146
|
faxDocLink = message.attachments.find(a => a.type === 'RenderedDocument').link;
|
|
1179
|
-
faxDownloadLink = message.attachments.find(a => a.type === 'RenderedDocument').uri + `?access_token=${incomingData.logInfo.rcAccessToken}
|
|
1147
|
+
faxDownloadLink = message.attachments.find(a => a.type === 'RenderedDocument').uri + `?access_token=${incomingData.logInfo.rcAccessToken}`;
|
|
1180
1148
|
}
|
|
1181
1149
|
let imageLink = null;
|
|
1182
1150
|
let imageDownloadLink = null;
|
|
@@ -1205,7 +1173,7 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1205
1173
|
conversationLogId: incomingData.logInfo.conversationLogId
|
|
1206
1174
|
}
|
|
1207
1175
|
});
|
|
1208
|
-
let crmLogId = ''
|
|
1176
|
+
let crmLogId = '';
|
|
1209
1177
|
if (existingSameDateMessageLog) {
|
|
1210
1178
|
const updateMessageResult = await platformModule.updateMessageLog({ user, contactInfo, assigneeName, ownerName, existingMessageLog: existingSameDateMessageLog, message, authHeader, additionalSubmission, imageLink, imageDownloadLink, imageContentType, videoLink, proxyConfig });
|
|
1211
1179
|
crmLogId = existingSameDateMessageLog.thirdPartyLogId;
|
|
@@ -1220,17 +1188,17 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1220
1188
|
}
|
|
1221
1189
|
if (crmLogId) {
|
|
1222
1190
|
try {
|
|
1223
|
-
const createdMessageLog =
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
});
|
|
1191
|
+
const createdMessageLog = await MessageLogModel.create({
|
|
1192
|
+
id: message.id.toString(),
|
|
1193
|
+
platform,
|
|
1194
|
+
conversationId: incomingData.logInfo.conversationId,
|
|
1195
|
+
thirdPartyLogId: crmLogId,
|
|
1196
|
+
userId,
|
|
1197
|
+
conversationLogId: incomingData.logInfo.conversationLogId
|
|
1198
|
+
});
|
|
1232
1199
|
logIds.push(createdMessageLog.id);
|
|
1233
|
-
}
|
|
1200
|
+
}
|
|
1201
|
+
catch (error) {
|
|
1234
1202
|
return handleDatabaseError(error, 'Error creating message log');
|
|
1235
1203
|
}
|
|
1236
1204
|
}
|
|
@@ -1247,17 +1215,16 @@ async function createMessageLog({ platform, userId, incomingData }) {
|
|
|
1247
1215
|
return handleApiError(e, platform, 'createMessageLog', { userId });
|
|
1248
1216
|
}
|
|
1249
1217
|
}
|
|
1250
|
-
|
|
1251
1218
|
async function saveNoteCache({ platform, userId, sessionId, note }) {
|
|
1252
1219
|
try {
|
|
1253
1220
|
const now = moment();
|
|
1254
1221
|
await NoteCache.create({ sessionId, note, ttl: now.unix() + 3600 });
|
|
1255
1222
|
return { successful: true, returnMessage: 'Note cache saved' };
|
|
1256
|
-
}
|
|
1223
|
+
}
|
|
1224
|
+
catch (e) {
|
|
1257
1225
|
return handleApiError(e, platform, 'saveNoteCache', { userId, sessionId, note });
|
|
1258
1226
|
}
|
|
1259
1227
|
}
|
|
1260
|
-
|
|
1261
1228
|
exports.createCallLog = createCallLog;
|
|
1262
1229
|
exports.updateCallLog = updateCallLog;
|
|
1263
1230
|
exports.createMessageLog = createMessageLog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|