emailengine-app 2.78.0 → 2.79.1
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/.ncurc.js +23 -13
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +68 -0
- package/config/e2e.toml +2 -1
- package/config/test.toml +2 -1
- package/data/google-crawlers.json +1 -1
- package/lib/account.js +112 -36
- package/lib/api-reference/format.js +91 -4
- package/lib/api-reference/model.js +144 -19
- package/lib/api-reference/schema-tree.js +282 -28
- package/lib/api-routes/account-routes.js +80 -34
- package/lib/api-routes/blocklist-routes.js +21 -47
- package/lib/api-routes/chat-routes.js +10 -12
- package/lib/api-routes/delivery-test-routes.js +6 -26
- package/lib/api-routes/export-routes.js +2 -0
- package/lib/api-routes/gateway-routes.js +52 -11
- package/lib/api-routes/license-routes.js +2 -0
- package/lib/api-routes/mailbox-routes.js +29 -26
- package/lib/api-routes/message-routes.js +27 -21
- package/lib/api-routes/oauth2-app-routes.js +11 -29
- package/lib/api-routes/operation-impact.js +80 -0
- package/lib/api-routes/outbox-routes.js +15 -5
- package/lib/api-routes/permission-map.js +401 -0
- package/lib/api-routes/route-helpers.js +294 -9
- package/lib/api-routes/route-metadata.js +28 -0
- package/lib/api-routes/settings-routes.js +66 -38
- package/lib/api-routes/stats-routes.js +2 -2
- package/lib/api-routes/submit-routes.js +53 -31
- package/lib/api-routes/template-routes.js +3 -0
- package/lib/api-routes/token-routes.js +526 -72
- package/lib/api-routes/webhook-route-routes.js +14 -4
- package/lib/arf-detect.js +17 -4
- package/lib/auth-token.js +80 -8
- package/lib/bounce-detect.js +28 -17
- package/lib/consts.js +16 -0
- package/lib/db.js +26 -2
- package/lib/delivery-error.js +30 -1
- package/lib/email-client/base-client.js +27 -41
- package/lib/email-client/gmail-client.js +23 -17
- package/lib/email-client/imap/mailbox.js +58 -59
- package/lib/email-client/imap/subconnection.js +10 -7
- package/lib/email-client/imap/sync-operations.js +46 -46
- package/lib/email-client/imap-client.js +85 -28
- package/lib/email-client/message-builder.js +3 -3
- package/lib/email-client/notification-handler.js +1 -1
- package/lib/email-client/outlook/graph-api.js +10 -4
- package/lib/email-client/outlook-client.js +56 -64
- package/lib/email-client/smtp-pool-manager.js +1 -1
- package/lib/enum-descriptions.js +92 -2
- package/lib/export.js +1 -1
- package/lib/field-usage.js +133 -0
- package/lib/gateway.js +1 -1
- package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +3 -3
- package/lib/imapproxy/imap-core/lib/commands/id.js +2 -13
- package/lib/imapproxy/imap-core/lib/commands/starttls.js +1 -1
- package/lib/imapproxy/imap-core/lib/imap-command.js +21 -5
- package/lib/imapproxy/imap-core/lib/imap-connection.js +15 -5
- package/lib/imapproxy/imap-server.js +27 -7
- package/lib/license-beacon.js +4 -9
- package/lib/lists.js +49 -1
- package/lib/llm-pre-process.js +5 -5
- package/lib/logger.js +5 -1
- package/lib/lua/h-set-new-mark.lua +36 -0
- package/lib/message-port-stream.js +84 -1
- package/lib/metrics-collector.js +2 -2
- package/lib/oauth/gmail.js +9 -12
- package/lib/oauth/mail-ru.js +5 -7
- package/lib/oauth/outlook.js +9 -9
- package/lib/oauth/pubsub/google.js +25 -10
- package/lib/oauth/scope-checker.js +1 -1
- package/lib/oauth2-apps.js +290 -292
- package/lib/openapi/build-document.js +20 -8
- package/lib/openapi/joi-schema.js +20 -0
- package/lib/outbox.js +85 -17
- package/lib/pre-process.js +8 -8
- package/lib/queue-stats.js +49 -0
- package/lib/read-env-value.js +1 -1
- package/lib/reconnection-manager.js +2 -2
- package/lib/rewrite-text-nodes.js +4 -3
- package/lib/routes-ui.js +4 -0
- package/lib/schemas.js +218 -162
- package/lib/settings.js +98 -5
- package/lib/sub-script.js +2 -1
- package/lib/swagger-options.js +2 -1
- package/lib/templates.js +4 -4
- package/lib/threads.js +2 -2
- package/lib/token-audit-log.js +231 -0
- package/lib/token-permission-view.js +219 -0
- package/lib/token-permissions.js +172 -0
- package/lib/tokens.js +247 -66
- package/lib/tools.js +142 -37
- package/lib/ui-routes/account-routes.js +42 -15
- package/lib/ui-routes/admin-config-routes.js +18 -10
- package/lib/ui-routes/admin-entities-routes.js +117 -38
- package/lib/ui-routes/auth-routes.js +30 -24
- package/lib/ui-routes/export-routes.js +10 -4
- package/lib/ui-routes/oauth-config-routes.js +12 -12
- package/lib/ui-routes/reference-routes.js +3 -3
- package/lib/ui-routes/route-helpers.js +78 -2
- package/lib/ui-routes/settings-page.js +1 -1
- package/lib/ui-routes/smtp-test-routes.js +1 -1
- package/lib/ui-routes/suppression-list-routes.js +299 -0
- package/lib/ui-routes/unsubscribe-routes.js +19 -29
- package/lib/utils/decode-headers.js +42 -0
- package/lib/utils/header-map.js +48 -0
- package/lib/utils/network.js +2 -2
- package/lib/utils/unsafe-key.js +59 -0
- package/lib/web-safe-html.js +1 -1
- package/lib/webhook-routing.js +84 -0
- package/lib/webhooks.js +48 -14
- package/package.json +11 -10
- package/sbom.json +1 -1
- package/server.js +116 -55
- package/static/css/flyonui.css +1 -1
- package/static/css/src/app.tailwind.css +136 -9
- package/static/js/reference.js +456 -10
- package/static/js/ui.js +43 -0
- package/static/licenses.html +51 -41
- package/translations/messages.pot +59 -59
- package/views/accounts/account.hbs +75 -13
- package/views/accounts/browse.hbs +19 -36
- package/views/accounts/edit.hbs +2 -2
- package/views/config/logging.hbs +6 -0
- package/views/config/oauth/app.hbs +0 -2
- package/views/config/security.hbs +13 -0
- package/views/gateways/edit.hbs +1 -1
- package/views/gateways/gateway.hbs +2 -2
- package/views/gateways/index.hbs +7 -7
- package/views/partials/accounts_table.hbs +7 -7
- package/views/partials/oauth_form.hbs +0 -15
- package/views/partials/reference/disclosure.hbs +8 -2
- package/views/partials/reference/operation.hbs +47 -13
- package/views/partials/reference/params.hbs +17 -1
- package/views/partials/reference/schema-node.hbs +110 -52
- package/views/partials/reference/schema-tools.hbs +25 -0
- package/views/partials/reference/try-it.hbs +84 -11
- package/views/partials/side_menu.hbs +1 -0
- package/views/partials/ui/checkbox.hbs +2 -2
- package/views/partials/ui/tabs.hbs +7 -1
- package/views/reference/token.hbs +4 -0
- package/views/suppression-lists/index.hbs +85 -0
- package/views/suppression-lists/list.hbs +87 -0
- package/views/templates/index.hbs +10 -4
- package/views/templates/template.hbs +1 -1
- package/views/tokens/index.hbs +53 -6
- package/views/tokens/new.hbs +334 -5
- package/workers/api.js +185 -102
- package/workers/documents.js +46 -26
- package/workers/export.js +20 -8
- package/workers/imap-proxy.js +2 -2
- package/workers/imap.js +77 -78
- package/workers/smtp.js +13 -7
- package/workers/submit.js +40 -30
- package/workers/webhooks.js +80 -26
- package/lib/feature-flags.js +0 -48
|
@@ -17,6 +17,7 @@ const { detectMimeType, detectExtension } = require('nodemailer/lib/mime-funcs/m
|
|
|
17
17
|
// Import Graph API module for MS Graph API handling
|
|
18
18
|
const graphApi = require('./outlook/graph-api');
|
|
19
19
|
const { buildRawSendMailRequest, buildStructuredSendMailRequest, buildDraftSendRequest } = require('./outlook/send-request');
|
|
20
|
+
const { pushHeaderValue } = require('../utils/header-map');
|
|
20
21
|
|
|
21
22
|
const {
|
|
22
23
|
REDIS_PREFIX,
|
|
@@ -333,7 +334,7 @@ class OutlookClient extends BaseClient {
|
|
|
333
334
|
let prevConnectedCount = await this.redis.hget(this.getAccountKey(), `state:count:connected`);
|
|
334
335
|
let isFirstSuccessfulConnection = prevConnectedCount === '0'; // string zero means the account has been initialized but not yet connected
|
|
335
336
|
|
|
336
|
-
let
|
|
337
|
+
let isInitial = !!isFirstSuccessfulConnection;
|
|
337
338
|
|
|
338
339
|
if (!isFirstSuccessfulConnection) {
|
|
339
340
|
// check if the connection was previously in an errored state
|
|
@@ -353,12 +354,12 @@ class OutlookClient extends BaseClient {
|
|
|
353
354
|
}
|
|
354
355
|
|
|
355
356
|
if (isFirstSuccessfulConnection) {
|
|
356
|
-
this.logger.info({ msg: 'Successful login without a previous active session', account: this.account,
|
|
357
|
+
this.logger.info({ msg: 'Successful login without a previous active session', account: this.account, isInitial, prevActive: false });
|
|
357
358
|
await this.notify(false, AUTH_SUCCESS_NOTIFY, {
|
|
358
359
|
user: accountData.oauth2?.auth?.user
|
|
359
360
|
});
|
|
360
361
|
} else {
|
|
361
|
-
this.logger.info({ msg: 'Successful login with a previous active session', account: this.account,
|
|
362
|
+
this.logger.info({ msg: 'Successful login with a previous active session', account: this.account, isInitial, prevActive: true });
|
|
362
363
|
}
|
|
363
364
|
|
|
364
365
|
// Clear any previous error states
|
|
@@ -385,7 +386,7 @@ class OutlookClient extends BaseClient {
|
|
|
385
386
|
try {
|
|
386
387
|
await this.listMailboxes();
|
|
387
388
|
} catch (err) {
|
|
388
|
-
this.logger.
|
|
389
|
+
this.logger.warn({ msg: 'Failed to renew mailbox folder cache', err });
|
|
389
390
|
}
|
|
390
391
|
|
|
391
392
|
// Start processing any pending webhook notifications
|
|
@@ -424,7 +425,7 @@ class OutlookClient extends BaseClient {
|
|
|
424
425
|
try {
|
|
425
426
|
await this.renewMailboxFolderCache();
|
|
426
427
|
} catch (err) {
|
|
427
|
-
this.logger.
|
|
428
|
+
this.logger.warn({ msg: 'Failed to refresh folder cache for manual sync', account: this.account, err });
|
|
428
429
|
}
|
|
429
430
|
|
|
430
431
|
await this.syncMissedMessages({ force: true });
|
|
@@ -454,7 +455,7 @@ class OutlookClient extends BaseClient {
|
|
|
454
455
|
await this.request(`/subscriptions/${outlookSubscription.id}`, 'DELETE');
|
|
455
456
|
}
|
|
456
457
|
} catch (err) {
|
|
457
|
-
this.logger.
|
|
458
|
+
this.logger.warn({ msg: 'Failed to delete MS Graph subscription', account: this.account, err });
|
|
458
459
|
}
|
|
459
460
|
|
|
460
461
|
if (['init', 'connecting', 'syncing', 'connected'].includes(this.state)) {
|
|
@@ -862,12 +863,6 @@ class OutlookClient extends BaseClient {
|
|
|
862
863
|
try {
|
|
863
864
|
await this.request(`/${this.oauth2UserPath}/messages/${emailId}`, 'delete', Buffer.alloc(0), { returnText: true });
|
|
864
865
|
} catch (err) {
|
|
865
|
-
this.logger.error({
|
|
866
|
-
msg: 'Failed to delete message',
|
|
867
|
-
emailId,
|
|
868
|
-
err
|
|
869
|
-
});
|
|
870
|
-
|
|
871
866
|
switch (err?.oauthRequest?.response?.error?.code) {
|
|
872
867
|
case 'ErrorCannotDeleteObject':
|
|
873
868
|
// does not exist
|
|
@@ -876,6 +871,11 @@ class OutlookClient extends BaseClient {
|
|
|
876
871
|
};
|
|
877
872
|
|
|
878
873
|
default:
|
|
874
|
+
this.logger.error({
|
|
875
|
+
msg: 'Failed to delete message',
|
|
876
|
+
emailId,
|
|
877
|
+
err
|
|
878
|
+
});
|
|
879
879
|
throw err;
|
|
880
880
|
}
|
|
881
881
|
}
|
|
@@ -908,7 +908,7 @@ class OutlookClient extends BaseClient {
|
|
|
908
908
|
try {
|
|
909
909
|
folder = await this.resolveFolder(messageData.parentFolderId, { byId: true });
|
|
910
910
|
} catch (err) {
|
|
911
|
-
this.logger.
|
|
911
|
+
this.logger.warn({
|
|
912
912
|
msg: 'Failed to resolve folder for message',
|
|
913
913
|
emailId,
|
|
914
914
|
err
|
|
@@ -941,7 +941,7 @@ class OutlookClient extends BaseClient {
|
|
|
941
941
|
try {
|
|
942
942
|
sourceFolder = await this.resolveFolder(path, { mailboxListing });
|
|
943
943
|
} catch (err) {
|
|
944
|
-
this.logger.
|
|
944
|
+
this.logger.warn({
|
|
945
945
|
msg: 'Failed to resolve source folder',
|
|
946
946
|
path,
|
|
947
947
|
err
|
|
@@ -1158,13 +1158,6 @@ class OutlookClient extends BaseClient {
|
|
|
1158
1158
|
try {
|
|
1159
1159
|
modifyResult = await this.request(`/${this.oauth2UserPath}/messages/${emailId}`, 'patch', flagUpdates);
|
|
1160
1160
|
} catch (err) {
|
|
1161
|
-
this.logger.error({
|
|
1162
|
-
msg: 'Failed to update message',
|
|
1163
|
-
emailId,
|
|
1164
|
-
flagUpdates,
|
|
1165
|
-
err
|
|
1166
|
-
});
|
|
1167
|
-
|
|
1168
1161
|
switch (err.oauthRequest?.status) {
|
|
1169
1162
|
case 400: {
|
|
1170
1163
|
let error = new Error('Invalid request');
|
|
@@ -1177,6 +1170,12 @@ class OutlookClient extends BaseClient {
|
|
|
1177
1170
|
}
|
|
1178
1171
|
|
|
1179
1172
|
default:
|
|
1173
|
+
this.logger.error({
|
|
1174
|
+
msg: 'Failed to update message',
|
|
1175
|
+
emailId,
|
|
1176
|
+
flagUpdates,
|
|
1177
|
+
err
|
|
1178
|
+
});
|
|
1180
1179
|
throw err;
|
|
1181
1180
|
}
|
|
1182
1181
|
}
|
|
@@ -1421,13 +1420,6 @@ class OutlookClient extends BaseClient {
|
|
|
1421
1420
|
throw new Error('Failed to move message');
|
|
1422
1421
|
}
|
|
1423
1422
|
} catch (err) {
|
|
1424
|
-
this.logger.error({
|
|
1425
|
-
msg: 'Failed to move message',
|
|
1426
|
-
emailId,
|
|
1427
|
-
target: targetFolder.pathName,
|
|
1428
|
-
err
|
|
1429
|
-
});
|
|
1430
|
-
|
|
1431
1423
|
switch (err?.oauthRequest?.response?.error?.code) {
|
|
1432
1424
|
case 'ErrorItemNotFound': {
|
|
1433
1425
|
let error = new Error('Move failed');
|
|
@@ -1440,11 +1432,17 @@ class OutlookClient extends BaseClient {
|
|
|
1440
1432
|
}
|
|
1441
1433
|
|
|
1442
1434
|
default: {
|
|
1435
|
+
this.logger.error({
|
|
1436
|
+
msg: 'Failed to move message',
|
|
1437
|
+
emailId,
|
|
1438
|
+
target: targetFolder.pathName,
|
|
1439
|
+
err
|
|
1440
|
+
});
|
|
1443
1441
|
let error = new Error('Move failed');
|
|
1444
1442
|
error.info = {
|
|
1445
|
-
response: err?.oauthRequest?.response?.error?.message
|
|
1443
|
+
response: err?.oauthRequest?.response?.error?.message || err?.message
|
|
1446
1444
|
};
|
|
1447
|
-
error.code = err?.oauthRequest?.response?.error?.code;
|
|
1445
|
+
error.code = err?.oauthRequest?.response?.error?.code || err?.code;
|
|
1448
1446
|
error.statusCode = 400;
|
|
1449
1447
|
throw error;
|
|
1450
1448
|
}
|
|
@@ -1719,13 +1717,9 @@ class OutlookClient extends BaseClient {
|
|
|
1719
1717
|
name = (name || '').toString().trim().toLowerCase();
|
|
1720
1718
|
|
|
1721
1719
|
value = (value || '').toString().trim();
|
|
1722
|
-
if (!(name
|
|
1723
|
-
headers[name] = [];
|
|
1724
|
-
}
|
|
1725
|
-
if (!Array.isArray(headers[name])) {
|
|
1720
|
+
if (!pushHeaderValue(headers, name, value)) {
|
|
1726
1721
|
continue;
|
|
1727
1722
|
}
|
|
1728
|
-
headers[name].push(value);
|
|
1729
1723
|
|
|
1730
1724
|
// Extract specific headers for easier access
|
|
1731
1725
|
switch (name) {
|
|
@@ -1957,13 +1951,9 @@ class OutlookClient extends BaseClient {
|
|
|
1957
1951
|
let { name, value } = header;
|
|
1958
1952
|
name = (name || '').toString().trim().toLowerCase();
|
|
1959
1953
|
value = (value || '').toString().trim();
|
|
1960
|
-
if (!(name
|
|
1961
|
-
headers[name] = [];
|
|
1962
|
-
}
|
|
1963
|
-
if (!Array.isArray(headers[name])) {
|
|
1954
|
+
if (!pushHeaderValue(headers, name, value)) {
|
|
1964
1955
|
continue;
|
|
1965
1956
|
}
|
|
1966
|
-
headers[name].push(value);
|
|
1967
1957
|
if (name === 'in-reply-to') {
|
|
1968
1958
|
messageData.inReplyTo = value;
|
|
1969
1959
|
}
|
|
@@ -2450,7 +2440,7 @@ class OutlookClient extends BaseClient {
|
|
|
2450
2440
|
try {
|
|
2451
2441
|
gatewayData = await gatewayObject.loadGatewayData();
|
|
2452
2442
|
} catch (err) {
|
|
2453
|
-
this.logger.
|
|
2443
|
+
this.logger.warn({ msg: 'Failed to load gateway data', messageId: data.messageId, gateway: data.gateway, err });
|
|
2454
2444
|
}
|
|
2455
2445
|
}
|
|
2456
2446
|
|
|
@@ -2690,7 +2680,7 @@ class OutlookClient extends BaseClient {
|
|
|
2690
2680
|
setImmediate(() => {
|
|
2691
2681
|
// refresh mailbox listing cache after changes
|
|
2692
2682
|
this.listMailboxes().catch(err => {
|
|
2693
|
-
this.logger.error({ msg: 'Failed to
|
|
2683
|
+
this.logger.error({ msg: 'Failed to refresh mailbox listing cache', err });
|
|
2694
2684
|
});
|
|
2695
2685
|
});
|
|
2696
2686
|
|
|
@@ -2811,7 +2801,7 @@ class OutlookClient extends BaseClient {
|
|
|
2811
2801
|
setImmediate(() => {
|
|
2812
2802
|
// refresh mailbox listing cache after changes
|
|
2813
2803
|
this.listMailboxes().catch(err => {
|
|
2814
|
-
this.logger.error({ msg: 'Failed to
|
|
2804
|
+
this.logger.error({ msg: 'Failed to refresh mailbox listing cache', err });
|
|
2815
2805
|
});
|
|
2816
2806
|
});
|
|
2817
2807
|
|
|
@@ -2858,7 +2848,7 @@ class OutlookClient extends BaseClient {
|
|
|
2858
2848
|
setImmediate(() => {
|
|
2859
2849
|
// refresh mailbox listing cache after changes
|
|
2860
2850
|
this.listMailboxes().catch(err => {
|
|
2861
|
-
this.logger.error({ msg: 'Failed to
|
|
2851
|
+
this.logger.error({ msg: 'Failed to refresh mailbox listing cache', err });
|
|
2862
2852
|
});
|
|
2863
2853
|
});
|
|
2864
2854
|
|
|
@@ -3091,7 +3081,7 @@ class OutlookClient extends BaseClient {
|
|
|
3091
3081
|
errorCode
|
|
3092
3082
|
});
|
|
3093
3083
|
} else {
|
|
3094
|
-
this.logger.
|
|
3084
|
+
this.logger.warn({
|
|
3095
3085
|
msg: 'Failed to check mailbox folder delta',
|
|
3096
3086
|
account: this.account,
|
|
3097
3087
|
err
|
|
@@ -3133,7 +3123,7 @@ class OutlookClient extends BaseClient {
|
|
|
3133
3123
|
try {
|
|
3134
3124
|
cachedListing = JSON.parse(cachedListingValue);
|
|
3135
3125
|
} catch (err) {
|
|
3136
|
-
this.logger.
|
|
3126
|
+
this.logger.warn({ msg: 'Failed to parse cached mailbox listing', err });
|
|
3137
3127
|
}
|
|
3138
3128
|
}
|
|
3139
3129
|
return cachedListing;
|
|
@@ -3445,7 +3435,7 @@ class OutlookClient extends BaseClient {
|
|
|
3445
3435
|
throw new Error('Empty server response');
|
|
3446
3436
|
}
|
|
3447
3437
|
} catch (err) {
|
|
3448
|
-
this.logger.
|
|
3438
|
+
this.logger.warn({
|
|
3449
3439
|
msg: 'Subscription renewal failed',
|
|
3450
3440
|
subscriptionId: outlookSubscription.id,
|
|
3451
3441
|
account: this.account,
|
|
@@ -3517,7 +3507,7 @@ class OutlookClient extends BaseClient {
|
|
|
3517
3507
|
let notificationBaseUrl = (await settings.get('notificationBaseUrl')) || serviceUrl || '';
|
|
3518
3508
|
|
|
3519
3509
|
if (!serviceUrl) {
|
|
3520
|
-
this.logger.
|
|
3510
|
+
this.logger.error({ msg: 'Cannot create MS Graph subscription, service URL is not set' });
|
|
3521
3511
|
return false;
|
|
3522
3512
|
}
|
|
3523
3513
|
|
|
@@ -3598,7 +3588,7 @@ class OutlookClient extends BaseClient {
|
|
|
3598
3588
|
}
|
|
3599
3589
|
} else {
|
|
3600
3590
|
// Subscription is valid, do nothing
|
|
3601
|
-
this.logger.
|
|
3591
|
+
this.logger.debug({
|
|
3602
3592
|
msg: 'Subscription renewal skipped',
|
|
3603
3593
|
reason: 'valid',
|
|
3604
3594
|
subscriptionId: outlookSubscription?.id,
|
|
@@ -3661,7 +3651,7 @@ class OutlookClient extends BaseClient {
|
|
|
3661
3651
|
}
|
|
3662
3652
|
} catch (err) {
|
|
3663
3653
|
const errorMessage = err.oauthRequest?.response?.error?.message || err.message;
|
|
3664
|
-
this.logger.
|
|
3654
|
+
this.logger.warn({
|
|
3665
3655
|
msg: 'Failed to create MS Graph subscription',
|
|
3666
3656
|
account: this.account,
|
|
3667
3657
|
error: errorMessage,
|
|
@@ -4032,7 +4022,7 @@ class OutlookClient extends BaseClient {
|
|
|
4032
4022
|
}
|
|
4033
4023
|
|
|
4034
4024
|
default:
|
|
4035
|
-
this.logger.debug({ msg: '
|
|
4025
|
+
this.logger.debug({ msg: 'Ignoring unknown history event type', type: 'history-event', event });
|
|
4036
4026
|
break;
|
|
4037
4027
|
}
|
|
4038
4028
|
}
|
|
@@ -4199,6 +4189,16 @@ class OutlookClient extends BaseClient {
|
|
|
4199
4189
|
* Process a deleted message event
|
|
4200
4190
|
* Verifies if actually deleted or just moved
|
|
4201
4191
|
*/
|
|
4192
|
+
// A message gone by the time a change notification is processed is a routine race: for every
|
|
4193
|
+
// genuine deletion the existence probe answers 404. Only unexpected failures deserve error.
|
|
4194
|
+
logMessageFetchFailure(emailId, err) {
|
|
4195
|
+
if (err.code === 'MessageNotFound' || err.statusCode === 404) {
|
|
4196
|
+
this.logger.debug({ msg: 'Failed to fetch message data', emailId, err });
|
|
4197
|
+
} else {
|
|
4198
|
+
this.logger.error({ msg: 'Failed to fetch message data', emailId, err });
|
|
4199
|
+
}
|
|
4200
|
+
}
|
|
4201
|
+
|
|
4202
4202
|
async processDeletedMessage(emailId) {
|
|
4203
4203
|
// Verify if the message was actually deleted.
|
|
4204
4204
|
// If the email was moved, we receive both a 'deleted' and a 'created' event with the same ID.
|
|
@@ -4208,11 +4208,7 @@ class OutlookClient extends BaseClient {
|
|
|
4208
4208
|
$select: ['id', 'parentFolderId'].join(',')
|
|
4209
4209
|
});
|
|
4210
4210
|
} catch (err) {
|
|
4211
|
-
this.
|
|
4212
|
-
msg: 'Failed to fetch message data',
|
|
4213
|
-
emailId,
|
|
4214
|
-
err
|
|
4215
|
-
});
|
|
4211
|
+
this.logMessageFetchFailure(emailId, err);
|
|
4216
4212
|
}
|
|
4217
4213
|
if (messageData) {
|
|
4218
4214
|
// The message still exists, so there's no need to notify about the deletion.
|
|
@@ -4241,11 +4237,7 @@ class OutlookClient extends BaseClient {
|
|
|
4241
4237
|
$select: ['id', 'isRead', 'isDraft', 'flag', 'conversationId', 'parentFolderId'].join(',')
|
|
4242
4238
|
});
|
|
4243
4239
|
} catch (err) {
|
|
4244
|
-
this.
|
|
4245
|
-
msg: 'Failed to fetch message data',
|
|
4246
|
-
emailId,
|
|
4247
|
-
err
|
|
4248
|
-
});
|
|
4240
|
+
this.logMessageFetchFailure(emailId, err);
|
|
4249
4241
|
}
|
|
4250
4242
|
if (!messageData) {
|
|
4251
4243
|
// do nothing, message not found
|
|
@@ -4256,7 +4248,7 @@ class OutlookClient extends BaseClient {
|
|
|
4256
4248
|
try {
|
|
4257
4249
|
folder = await this.resolveFolder(messageData.parentFolderId, { byId: true });
|
|
4258
4250
|
} catch (err) {
|
|
4259
|
-
this.logger.
|
|
4251
|
+
this.logger.warn({
|
|
4260
4252
|
msg: 'Failed to resolve folder for message',
|
|
4261
4253
|
emailId,
|
|
4262
4254
|
err
|
|
@@ -4303,7 +4295,7 @@ class OutlookClient extends BaseClient {
|
|
|
4303
4295
|
* Fetches full message details and checks if it's actually new
|
|
4304
4296
|
*/
|
|
4305
4297
|
async prepareNewMessage(emailId, options) {
|
|
4306
|
-
this.logger.debug({ msg: 'New message', id: emailId
|
|
4298
|
+
this.logger.debug({ msg: 'New message', id: emailId });
|
|
4307
4299
|
|
|
4308
4300
|
if (options.fetchHeaders) {
|
|
4309
4301
|
options.headers = options.fetchHeaders;
|
|
@@ -4645,7 +4637,7 @@ class OutlookClient extends BaseClient {
|
|
|
4645
4637
|
return { cursorPage, skipToken };
|
|
4646
4638
|
}
|
|
4647
4639
|
} catch (err) {
|
|
4648
|
-
this.logger.
|
|
4640
|
+
this.logger.warn({ msg: 'Failed to parse paging cursor', cursorStr, err });
|
|
4649
4641
|
|
|
4650
4642
|
let error = new Error('Invalid paging cursor');
|
|
4651
4643
|
error.code = 'InvalidCursorValue';
|
|
@@ -168,7 +168,7 @@ function cleanupIdlePools() {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
if (idleKeys.length > 0) {
|
|
171
|
-
logger.
|
|
171
|
+
logger.debug({ msg: 'SMTP pool cleanup completed', cleaned: idleKeys.length, remaining: SMTP_POOLS.size });
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
package/lib/enum-descriptions.js
CHANGED
|
@@ -7,8 +7,13 @@ const { ADDRESS_STRATEGIES } = require('./address-strategies');
|
|
|
7
7
|
// as `x-meta.enumDescriptions` alongside the `enum` array - so the meaning of each value
|
|
8
8
|
// reaches /swagger.json and every consumer of it, not just the admin API reference.
|
|
9
9
|
//
|
|
10
|
-
// Only enums whose values carry real semantics are listed.
|
|
11
|
-
//
|
|
10
|
+
// Only enums whose values carry real semantics are listed.
|
|
11
|
+
//
|
|
12
|
+
// That includes the ones that used to spell their values out in their own description
|
|
13
|
+
// instead. Doing it there meant the reference printed the explanation as a paragraph and
|
|
14
|
+
// then repeated every value underneath it as a chip - worst on the account `type` enum,
|
|
15
|
+
// where a three-line sentence was followed by all ten values again. Here the renderer has
|
|
16
|
+
// somewhere to put each value, and the description shrinks to what the field is for.
|
|
12
17
|
const ENUM_DESCRIPTIONS = {
|
|
13
18
|
// derived, so adding a strategy cannot leave the API reference behind
|
|
14
19
|
addressStrategy: Object.fromEntries(ADDRESS_STRATEGIES.map(entry => [entry.key, entry.description])),
|
|
@@ -90,6 +95,35 @@ const ENUM_DESCRIPTIONS = {
|
|
|
90
95
|
'imap-proxy': 'Authenticate against the built-in IMAP proxy'
|
|
91
96
|
},
|
|
92
97
|
|
|
98
|
+
// The verb axis of a narrowed token. Each operation requires exactly one of these, published
|
|
99
|
+
// per operation as `x-ee-action`.
|
|
100
|
+
tokenAction: {
|
|
101
|
+
read: 'Read data without changing anything',
|
|
102
|
+
write: 'Create or modify data',
|
|
103
|
+
send: 'Hand a message to a mail server, so it reaches real recipients',
|
|
104
|
+
destructive:
|
|
105
|
+
'Call the endpoints that remove data. Deleting a message is a move to Trash, which a write grant can perform directly, so withholding this narrows the endpoints rather than the outcome for mail'
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
// The resource axis of a narrowed token. Each operation belongs to exactly one group, published
|
|
109
|
+
// per operation as `x-ee-group`. The `admin` group is absent on purpose: it can never be
|
|
110
|
+
// granted, so it is not an option when issuing a token.
|
|
111
|
+
tokenGroup: {
|
|
112
|
+
account: 'Manage email accounts and their connection state',
|
|
113
|
+
mailbox: 'Create, rename, delete and list mailbox folders',
|
|
114
|
+
message: 'Read, modify, move and delete messages, including bulk actions and search',
|
|
115
|
+
submit: 'Send email, including scheduled sends and the delivery test. A send may reference a stored message to forward it, so this also reads the message it names',
|
|
116
|
+
outbox: 'Inspect and cancel queued outbound messages',
|
|
117
|
+
export: 'Bulk export an account. One call archives every folder, so this is separate from message access',
|
|
118
|
+
template: 'Manage stored email templates',
|
|
119
|
+
blocklist: 'Manage suppression lists',
|
|
120
|
+
webhook: 'Read webhook route definitions',
|
|
121
|
+
gateway: 'Manage SMTP gateways, which hold outbound SMTP credentials',
|
|
122
|
+
events: 'Subscribe to the instance-wide change stream, which covers every account',
|
|
123
|
+
diagnostics: 'Read statistics and service status',
|
|
124
|
+
logs: 'Read the per-account connection log. Entries are the raw protocol trace, so they include folder names and message subjects'
|
|
125
|
+
},
|
|
126
|
+
|
|
93
127
|
queueId: {
|
|
94
128
|
notify: 'Webhook delivery queue',
|
|
95
129
|
submit: 'Outbound email delivery queue',
|
|
@@ -124,6 +158,62 @@ const ENUM_DESCRIPTIONS = {
|
|
|
124
158
|
'\\Sent': 'Sent messages',
|
|
125
159
|
'\\Trash': 'Deleted messages awaiting purge',
|
|
126
160
|
'\\Inbox': 'The inbox'
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
accountType: {
|
|
164
|
+
imap: 'Plain IMAP and SMTP, authenticated with a username and password',
|
|
165
|
+
gmail: 'Gmail or Google Workspace, through a user-consented OAuth2 app',
|
|
166
|
+
gmailService: 'Google Workspace through a service account, with no per-user consent screen',
|
|
167
|
+
outlook: 'Outlook or Microsoft 365, through a user-consented OAuth2 app',
|
|
168
|
+
outlookService: 'Microsoft 365 through application permissions, with no per-user consent screen',
|
|
169
|
+
mailRu: 'Mail.ru, through an OAuth2 app',
|
|
170
|
+
oauth2: 'An OAuth2 account whose application is no longer configured in EmailEngine',
|
|
171
|
+
delegated: 'A shared or delegated mailbox accessed through another account credentials',
|
|
172
|
+
sending: 'Send-only. No IMAP access is configured, so nothing is synced',
|
|
173
|
+
invalid: 'Delegation could not be resolved, so the account cannot be used'
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
imapIndexer: {
|
|
177
|
+
full: 'Track every change, including deletions. Slower but complete',
|
|
178
|
+
fast: 'Detect new messages only. Cheaper, but deletions and flag changes are missed'
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
exportTextType: {
|
|
182
|
+
plain: 'Plain text bodies only',
|
|
183
|
+
html: 'HTML bodies only',
|
|
184
|
+
'*': 'Both the plain text and the HTML body'
|
|
185
|
+
},
|
|
186
|
+
|
|
187
|
+
specialUseSource: {
|
|
188
|
+
user: 'Set explicitly through the API',
|
|
189
|
+
extension: 'Reported by the mail server through the SPECIAL-USE extension',
|
|
190
|
+
name: 'Guessed from the folder name'
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
messageAction: {
|
|
194
|
+
reply: 'Reply to the sender',
|
|
195
|
+
'reply-all': 'Reply to the sender and every other recipient',
|
|
196
|
+
forward: 'Forward the message to new recipients'
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
renderFormat: {
|
|
200
|
+
html: 'The template is already HTML',
|
|
201
|
+
markdown: 'The template is Markdown and is converted to HTML'
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
entityState: {
|
|
205
|
+
new: 'The entry did not exist and was created',
|
|
206
|
+
existing: 'The entry already existed and was updated'
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
idempotencyStatus: {
|
|
210
|
+
MISS: 'The request ran now and this is its result',
|
|
211
|
+
HIT: 'An identical request ran earlier and its stored result was replayed'
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
gmailAuthMethod: {
|
|
215
|
+
serviceKey: 'Sign token requests with an uploaded service account key',
|
|
216
|
+
externalAccount: 'Sign token requests through Workload Identity Federation, with no key to store'
|
|
127
217
|
}
|
|
128
218
|
};
|
|
129
219
|
|
package/lib/export.js
CHANGED
|
@@ -579,7 +579,7 @@ class Export {
|
|
|
579
579
|
.srem(ACTIVE_EXPORTS_KEY, buildActiveEntry(account, exportId))
|
|
580
580
|
.exec();
|
|
581
581
|
|
|
582
|
-
logger.
|
|
582
|
+
logger.warn({ msg: 'Export failed', account, exportId, error });
|
|
583
583
|
}
|
|
584
584
|
|
|
585
585
|
static async deleteFully(account, exportId) {
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { COLLAPSE_CLASS } = require('./consts');
|
|
4
|
+
|
|
5
|
+
// Long-form guidance for the fields where knowing what a value IS does not tell you when to
|
|
6
|
+
// send it. Attached to the joi schemas with `.meta({ usage })`, which the OpenAPI generator
|
|
7
|
+
// publishes as `x-meta.usage` - so it reaches /swagger.json and every consumer of it, not
|
|
8
|
+
// only the admin API reference.
|
|
9
|
+
//
|
|
10
|
+
// This is the sibling of lib/enum-descriptions.js and exists for the same reason: prose
|
|
11
|
+
// belongs somewhere it can be read and edited as prose, not smeared across schema
|
|
12
|
+
// definitions a line at a time.
|
|
13
|
+
//
|
|
14
|
+
// A note is for a field whose CHOICE is not obvious, never for one whose meaning is not.
|
|
15
|
+
// `subject` does not get one. Two questions a description cannot answer are what earn a
|
|
16
|
+
// field an entry here:
|
|
17
|
+
//
|
|
18
|
+
// when would I reach for this
|
|
19
|
+
// what does sending it do to the other fields
|
|
20
|
+
//
|
|
21
|
+
// It is also where the long half of an overlong description goes. Seventeen fields used to
|
|
22
|
+
// put three or four lines of caveats inline, on a page where the median description is one
|
|
23
|
+
// short sentence - so the fields with the most to say were the ones that made the page
|
|
24
|
+
// hardest to scan. The description keeps the first sentence, the caveats move here, and the
|
|
25
|
+
// API reference renders them behind a closed "When to use this" disclosure. Net result is
|
|
26
|
+
// fewer lines on screen, not more.
|
|
27
|
+
//
|
|
28
|
+
// Format: plain paragraphs, backtick code spans, absolute links. lib/api-reference/format.js
|
|
29
|
+
// escapes first and only adds back a closed tag set, so a heading or a list renders as
|
|
30
|
+
// literal text - the same constraint the `info.description` in workers/api.js is written
|
|
31
|
+
// under. Blank lines separate paragraphs.
|
|
32
|
+
//
|
|
33
|
+
// Keep them short. Two to four sentences is the target; anything longer belongs in the
|
|
34
|
+
// documentation site with a link from here.
|
|
35
|
+
|
|
36
|
+
const AUTH_USAGE =
|
|
37
|
+
'Send this for ordinary password authentication. Omit it when `useAuthServer` is on, because EmailEngine then fetches credentials from your authentication server for every connection and a stored password would be dead configuration.\n\n' +
|
|
38
|
+
'On an update this replaces the whole credentials object unless `partial` is also set.';
|
|
39
|
+
|
|
40
|
+
const FIELD_USAGE = {
|
|
41
|
+
accountId:
|
|
42
|
+
'Set this when your own system already has an identifier for the mailbox, for example a user id, so you can address the account later without storing a second id. Leave it `null` and EmailEngine generates one, which comes back in the response.\n\n' +
|
|
43
|
+
'Reusing an existing id is an update, not an error: the registration endpoint applies the new settings to that account rather than creating a second one.',
|
|
44
|
+
|
|
45
|
+
expectedEmail:
|
|
46
|
+
'Set this when the account is created through a hosted authentication form and you already know which mailbox the user is supposed to connect, so a user cannot finish the form against a different account than the one you provisioned.\n\n' +
|
|
47
|
+
'For OAuth2 the address is compared against what the provider reports, never against anything the caller supplied, so for a shared or delegated mailbox this has to be the authenticating principal rather than the mailbox address. For IMAP it is compared against the address typed into the form, which the credentials do not prove ownership of.\n\n' +
|
|
48
|
+
'The constraint stays on the account and is enforced again on every later reauthentication.',
|
|
49
|
+
|
|
50
|
+
imapPath:
|
|
51
|
+
'Leave this at `"*"` unless the account is large and you only care about a few folders. Narrowing it reduces the number of folders EmailEngine keeps open and indexes, which is the main cost of syncing a big mailbox.\n\n' +
|
|
52
|
+
'Unmonitored folders stay fully reachable through the API. What you give up is webhooks: nothing is emitted for changes in a folder that is not on this list.',
|
|
53
|
+
|
|
54
|
+
// Same note either way: nothing in it is protocol specific, and the two keys stay
|
|
55
|
+
// separate so one can diverge later without touching the other's schema.
|
|
56
|
+
imapAuth: AUTH_USAGE,
|
|
57
|
+
smtpAuth: AUTH_USAGE,
|
|
58
|
+
|
|
59
|
+
useAuthServer:
|
|
60
|
+
'Turn this on when passwords must not be stored in EmailEngine, for instance when they are short-lived or held in your own vault. EmailEngine then calls your authentication server for credentials each time it needs to connect, and the `auth` block must be omitted.\n\n' +
|
|
61
|
+
'The authentication server URL itself is an instance-wide setting, not a per-account one.',
|
|
62
|
+
|
|
63
|
+
partialUpdate:
|
|
64
|
+
'Set this when you are changing one setting and do not want to resend the rest. Without it the configuration object you send replaces the stored one wholesale, so any key you leave out is cleared.\n\n' +
|
|
65
|
+
'It applies only to the block it sits in: a partial `imap` update alongside a full `smtp` object updates one and replaces the other.',
|
|
66
|
+
|
|
67
|
+
disableIMAP4rev2:
|
|
68
|
+
'Set this only after a server has actually misbehaved. A handful of IMAP servers advertise IMAP4rev2 support and then answer incorrectly, and this forces EmailEngine back to IMAP4rev1 for that account.\n\n' +
|
|
69
|
+
'It has no effect on accounts that authenticate with OAuth2.',
|
|
70
|
+
|
|
71
|
+
// No description of what `full` and `fast` do: the row lists both values with their own
|
|
72
|
+
// descriptions from lib/enum-descriptions.js a few lines under this note, and saying it
|
|
73
|
+
// twice on one row is what that split exists to avoid.
|
|
74
|
+
imapIndexer:
|
|
75
|
+
'Leave this unset to follow the instance-wide setting, and only override it for accounts whose mailboxes behave differently from the rest of your fleet. A very large mailbox that nothing else writes to is the usual reason.',
|
|
76
|
+
|
|
77
|
+
exportFolders:
|
|
78
|
+
'Name folders when you want a subset, by path or by special-use flag such as `\\Sent`. Leaving it empty is not "nothing", it is a documented default: Gmail and Outlook API accounts export All Mail, and every other account exports every folder except Junk and Trash.',
|
|
79
|
+
|
|
80
|
+
searchEmailIds:
|
|
81
|
+
'Use this when you already know which messages you want, typically from an earlier search or from a webhook. It is not a filter that narrows the other criteria - when it is present every other search field is ignored.',
|
|
82
|
+
|
|
83
|
+
mailboxSubscribed:
|
|
84
|
+
'Only IMAP accounts have a subscription list, so this is ignored for Gmail API and MS Graph accounts. It controls whether a folder shows up in clients that list subscribed folders only; it does not affect whether EmailEngine syncs it, which `path` on the account decides.',
|
|
85
|
+
|
|
86
|
+
messageRaw:
|
|
87
|
+
'Send `raw` when you have already built the MIME message yourself, for example when relaying something you fetched from another system, and it has to go out unchanged.\n\n' +
|
|
88
|
+
'Anything else you send alongside it overrides the matching header inside it, so a `subject` sent with a raw body replaces the subject in the message. If you are composing from parts, use `text` and `html` and let EmailEngine build the MIME structure.',
|
|
89
|
+
|
|
90
|
+
messageEnvelope:
|
|
91
|
+
'Send this only when the SMTP envelope has to differ from the message headers, which in practice means variable envelope return paths, a bounce address that is not the From address, or delivering to an address that does not appear in the headers.\n\n' +
|
|
92
|
+
'Left out, the envelope is derived from the headers, which is what you want for an ordinary message.',
|
|
93
|
+
|
|
94
|
+
mailMerge:
|
|
95
|
+
'Use this to send one personalised message per recipient in a single request, instead of one request each. Each entry gets its own queue id and its own delivery.\n\n' +
|
|
96
|
+
'It takes over addressing and rendering for the whole request: `messageId`, `envelope`, `to`, `cc`, `bcc` and `render` at the message root are rejected, because each entry supplies its own.',
|
|
97
|
+
|
|
98
|
+
messageCopy:
|
|
99
|
+
'Leave this unset to follow the account default. Set it explicitly when one message should be filed differently from the rest, for instance an automated notification you do not want in the user Sent folder.\n\n' +
|
|
100
|
+
'It only affects SMTP deliveries. Gmail and MS Graph file sent messages themselves, so the flag is a no-op there.',
|
|
101
|
+
|
|
102
|
+
attachmentReference:
|
|
103
|
+
'Use this to forward an attachment that is already on another message without downloading and re-uploading it. Take the id from the attachment list of the referenced message.\n\n' +
|
|
104
|
+
'It is exclusive with `content`: send one or the other, never both.',
|
|
105
|
+
|
|
106
|
+
referenceThreadId:
|
|
107
|
+
'Set this when you know the Gmail thread the outgoing message belongs to and do not want EmailEngine to work it out from the referenced message.\n\n' +
|
|
108
|
+
'Gmail API accounts only. IMAP and MS Graph derive threading from the `In-Reply-To` and `References` headers and ignore it. When both `message` and `threadId` are given, this one wins.',
|
|
109
|
+
|
|
110
|
+
openAiAPIUrl:
|
|
111
|
+
'Set this only for an OpenAI-compatible service that is not OpenAI itself, and include whatever path prefix that service mounts its API under. For Azure OpenAI that means `https://<your-resource>.openai.azure.com/openai/v1`, not the bare host.',
|
|
112
|
+
|
|
113
|
+
revokeGrant:
|
|
114
|
+
'Set this when deleting an account should also cut EmailEngine off at the provider, for example because a user asked for their data to be disconnected rather than just removed here.\n\n' +
|
|
115
|
+
'It currently works for individual Gmail OAuth2 grants. Gmail Workspace service-account integrations, Outlook and non-OAuth2 accounts ignore it. A failed revocation is logged and never blocks the deletion.',
|
|
116
|
+
|
|
117
|
+
webSafeHtml:
|
|
118
|
+
'Turn this on when you are rendering the message in your own UI and want EmailEngine to do the sanitising. It is a shorthand that overrides `textType`, `preProcessHtml` and `embedAttachedImages`.\n\n' +
|
|
119
|
+
`Quoted thread history is folded into one collapsed \`<details class="${COLLAPSE_CLASS}">\` element so you can hide it behind a single control. Its \`<summary>\` is deliberately empty, so supply your own label.`,
|
|
120
|
+
|
|
121
|
+
useOutlookSearch:
|
|
122
|
+
'Turn this on for MS Graph accounts when you need to search fields that the default `$filter` mode cannot reach: `to`, `cc`, `bcc`, `larger`, `smaller`, `body`, `before`, `sentBefore`, `since` and `sentSince`.\n\n' +
|
|
123
|
+
'What you give up is worth checking first. `$search` returns at most 1,000 results, reports neither a total nor a page count, and orders by relevance rather than by date. The `labels` filter is unavailable in this mode, so leave it off when you need to filter by category.',
|
|
124
|
+
|
|
125
|
+
useStructuredFormat:
|
|
126
|
+
'Turn this on for MS Graph accounts sending from a shared mailbox, because it is the only mode that respects the `from` address.\n\n' +
|
|
127
|
+
'The cost is fidelity: structured JSON breaks calendar invites and other special MIME types. The default, raw MIME, preserves them but ignores `from`.',
|
|
128
|
+
|
|
129
|
+
messagePage:
|
|
130
|
+
'Prefer the paging cursor. This exists for IMAP accounts and for callers written before cursors, and it is ignored entirely when a cursor is also supplied.'
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
module.exports = { FIELD_USAGE };
|
package/lib/gateway.js
CHANGED
|
@@ -224,7 +224,7 @@ class Gateway {
|
|
|
224
224
|
await this.redis.hincrby(this.getGatewayKey(), 'deliveries', Number(gatewayData.deliveries.inc));
|
|
225
225
|
} catch (err) {
|
|
226
226
|
if (this.logger) {
|
|
227
|
-
this.logger.error({ msg: 'Failed to increment counter', err });
|
|
227
|
+
this.logger.error({ msg: 'Failed to increment gateway delivery counter', gateway: this.gateway, err });
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
delete gatewayData.deliveries;
|
|
@@ -83,7 +83,7 @@ function authenticate(connection, token, requireClientToken, callback) {
|
|
|
83
83
|
action: 'fail',
|
|
84
84
|
cid: connection.id
|
|
85
85
|
},
|
|
86
|
-
'Authentication error for %s using %s
|
|
86
|
+
'Authentication error for %s using %s: %s',
|
|
87
87
|
username,
|
|
88
88
|
'PLAIN',
|
|
89
89
|
err.message
|
|
@@ -118,12 +118,12 @@ function authenticate(connection, token, requireClientToken, callback) {
|
|
|
118
118
|
method: 'PLAIN',
|
|
119
119
|
action: 'success',
|
|
120
120
|
cid: connection.id,
|
|
121
|
-
clientToken
|
|
121
|
+
clientToken: !!clientToken
|
|
122
122
|
},
|
|
123
123
|
'%s authenticated using %s%s',
|
|
124
124
|
username,
|
|
125
125
|
'PLAIN' + (requireClientToken ? '-CLIENTTOKEN' : ''),
|
|
126
|
-
clientToken ? ' with
|
|
126
|
+
clientToken ? ' with a client token' : ''
|
|
127
127
|
);
|
|
128
128
|
|
|
129
129
|
connection.setUser(response.user);
|