domma-cms 1.28.4 → 1.29.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/CHANGELOG.md +9 -0
- package/admin/js/lib/contacts-arrange.js +1 -1
- package/docs/DommaFeatures.md +15 -9
- package/docs/plugin-development.md +1 -1
- package/package.json +4 -1
- package/plugins/_lib/admin/mail/body-menu.js +2 -0
- package/plugins/_lib/admin/mail/cms-host.js +22 -0
- package/plugins/_lib/admin/mail/compose-window.js +1027 -1021
- package/plugins/_lib/admin/mail/contacts.js +10 -8
- package/plugins/_lib/admin/mail/diagnostics-section.js +2 -0
- package/plugins/_lib/admin/mail/drag-drop.js +46 -0
- package/plugins/_lib/admin/mail/folder-tree.js +2 -0
- package/plugins/_lib/admin/mail/font-controls.js +6 -4
- package/plugins/_lib/admin/mail/fonts.js +1 -1
- package/plugins/_lib/admin/mail/host-context.js +87 -0
- package/plugins/_lib/admin/mail/identity.js +2 -0
- package/plugins/_lib/admin/mail/image-senders-section.js +2 -0
- package/plugins/_lib/admin/mail/keyboard.js +2 -0
- package/plugins/_lib/admin/mail/mail.css +1 -1
- package/plugins/_lib/admin/mail/mail.html +4 -0
- package/plugins/_lib/admin/mail/message-actions.js +2 -0
- package/plugins/_lib/admin/mail/oauth-panel.js +2 -0
- package/plugins/_lib/admin/mail/panes.js +2 -0
- package/plugins/_lib/admin/mail/reader-kit.js +2 -0
- package/plugins/_lib/admin/mail/reader-runtime.js +6534 -0
- package/plugins/_lib/admin/mail/reader-view.js +9 -6380
- package/plugins/_lib/admin/mail/resizable.js +2 -0
- package/plugins/_lib/admin/mail/restore-spam.js +13 -0
- package/plugins/_lib/admin/mail/rules.js +14 -0
- package/plugins/_lib/admin/mail/scheduling.js +4 -1
- package/plugins/_lib/admin/mail/section-kit.js +4 -1
- package/plugins/_lib/admin/mail/security-note.js +2 -0
- package/plugins/_lib/admin/mail/settings-section.js +11 -10
- package/plugins/_lib/admin/mail/templates.js +5 -2
- package/plugins/_lib/admin/mail/threads.js +2 -0
- package/plugins/_lib/admin/mail/vacation.js +16 -2
- package/plugins/_lib/admin/mail/when-closed.js +24 -2
- package/plugins/_lib/admin/ui/dates.js +2 -0
- package/plugins/_lib/admin/ui/resizable.js +7 -5
- package/plugins/_lib/contacts/mailContact.js +69 -0
- package/plugins/_lib/contacts/model.js +199 -0
- package/plugins/_lib/domma-mail-contacts.lock.json +10 -0
- package/plugins/_lib/domma-mail.lock.json +85 -0
- package/plugins/_lib/mail/accountFileStore.js +66 -0
- package/plugins/_lib/mail/accountRepository.js +617 -0
- package/plugins/_lib/mail/accountRoutes.js +130 -0
- package/plugins/_lib/mail/accounts.js +66 -940
- package/plugins/_lib/mail/automationLock.js +10 -0
- package/plugins/_lib/mail/bodyTokenProvider.js +36 -0
- package/plugins/_lib/mail/bodyTokens.js +5 -99
- package/plugins/_lib/mail/compose.js +5 -3
- package/plugins/_lib/mail/defaults.js +2 -0
- package/plugins/_lib/mail/envelope.js +3 -1
- package/plugins/_lib/mail/folderActions.js +83 -0
- package/plugins/_lib/mail/folderRuntime.js +109 -0
- package/plugins/_lib/mail/folders.js +4 -9
- package/plugins/_lib/mail/imapPool.js +11 -389
- package/plugins/_lib/mail/imapPoolRuntime.js +396 -0
- package/plugins/_lib/mail/mbox.js +2 -0
- package/plugins/_lib/mail/message-action.js +2 -0
- package/plugins/_lib/mail/messageSecurity.js +4 -111
- package/plugins/_lib/mail/messageSecurityProvider.js +116 -0
- package/plugins/_lib/mail/networkAddresses.js +77 -0
- package/plugins/_lib/mail/networkPolicy.js +62 -0
- package/plugins/_lib/mail/oauth.js +3 -451
- package/plugins/_lib/mail/oauthAccounts.js +178 -0
- package/plugins/_lib/mail/oauthRouteRuntime.js +282 -0
- package/plugins/_lib/mail/oauthRoutes.js +7 -289
- package/plugins/_lib/mail/oauthRuntime.js +456 -0
- package/plugins/_lib/mail/pollSchedule.js +2 -0
- package/plugins/_lib/mail/poller.js +4 -136
- package/plugins/_lib/mail/pollerRuntime.js +150 -0
- package/plugins/_lib/mail/priority.js +2 -0
- package/plugins/_lib/mail/publicMailbox.js +27 -0
- package/plugins/_lib/mail/readRoutes.js +14 -827
- package/plugins/_lib/mail/readRuntime.js +701 -0
- package/plugins/_lib/mail/render.js +2 -0
- package/plugins/_lib/mail/ruleRunner.js +27 -10
- package/plugins/_lib/mail/scheduler.js +11 -279
- package/plugins/_lib/mail/schedulerRuntime.js +259 -0
- package/plugins/_lib/mail/secretProvider.js +112 -0
- package/plugins/_lib/mail/secretbox.js +12 -225
- package/plugins/_lib/mail/send.js +21 -537
- package/plugins/_lib/mail/sieve.js +211 -0
- package/plugins/_lib/mail/sieveHost.js +24 -0
- package/plugins/_lib/mail/smtpService.js +553 -0
- package/plugins/_lib/mail/snoozeRuntime.js +60 -0
- package/plugins/_lib/mail/store.js +122 -64
- package/plugins/_lib/mail/subscriptions.js +11 -0
- package/plugins/_lib/mail/sync.js +64 -290
- package/plugins/_lib/mail/syncPlan.js +2 -0
- package/plugins/_lib/mail/syncRuntime.js +255 -0
- package/plugins/_lib/mail/syncSelection.js +2 -0
- package/plugins/_lib/mail/unreadBadge.js +2 -0
- package/plugins/_lib/mail/unsubscribe.js +2 -0
- package/plugins/_lib/mail/vacationRunner.js +3 -116
- package/plugins/_lib/mail/vacationRuntime.js +70 -0
- package/plugins/_lib/mail/write.js +44 -13
- package/server/routes/api/contacts.js +2 -196
- package/server/routes/api/forms.js +8 -1
- package/server/services/viewerSession.js +1 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Source: @domma-mail/core 0.18.0, packages/core/src/mail/pollerRuntime.js.
|
|
2
|
+
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
|
+
/**
|
|
4
|
+
* The background poller.
|
|
5
|
+
*
|
|
6
|
+
* One ticker for the whole plugin rather than a timer per mailbox: mailboxes
|
|
7
|
+
* come and go while the process runs, and a per-mailbox timer means tracking
|
|
8
|
+
* and cancelling each one. A single tick asks `selectDuePolls()` who is due
|
|
9
|
+
* and works through them.
|
|
10
|
+
*
|
|
11
|
+
* The scheduling decision - including the backoff that stops a dead mail
|
|
12
|
+
* server being knocked every few minutes for a week - lives in
|
|
13
|
+
* `pollSchedule.js`, pure and tested there.
|
|
14
|
+
*
|
|
15
|
+
* @module _lib/mail/poller
|
|
16
|
+
*/
|
|
17
|
+
import {selectDuePolls} from './pollSchedule.js';
|
|
18
|
+
import {describeError} from './imapPoolRuntime.js';
|
|
19
|
+
|
|
20
|
+
/** How often the ticker looks for work. Finer than any poll interval. */
|
|
21
|
+
const TICK_MS = 30_000;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create a poller.
|
|
25
|
+
*
|
|
26
|
+
* @param {{listAccounts: Function, syncAccount: Function, defaultMinutes: number,
|
|
27
|
+
* logger: object, tickMs?: number}} deps
|
|
28
|
+
* @returns {{start: Function, stop: Function, state: Function, pollNow: Function}}
|
|
29
|
+
*/
|
|
30
|
+
export function createPoller({listAccounts, syncAccount, defaultMinutes, logger, tickMs = TICK_MS}) {
|
|
31
|
+
/** @type {Map<string, {lastAttemptAt?: number, failures?: number, running?: boolean, lastError?: string|null}>} */
|
|
32
|
+
const state = new Map();
|
|
33
|
+
let timer = null;
|
|
34
|
+
let stopped = false;
|
|
35
|
+
let active = null;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Sync one mailbox, recording whether it worked.
|
|
39
|
+
*
|
|
40
|
+
* @param {object} account
|
|
41
|
+
* @returns {Promise<void>}
|
|
42
|
+
*/
|
|
43
|
+
async function runOne(account) {
|
|
44
|
+
const entry = state.get(account.id) ?? {};
|
|
45
|
+
state.set(account.id, {...entry, running: true, lastAttemptAt: Date.now()});
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const result = await syncAccount(account);
|
|
49
|
+
state.set(account.id, {
|
|
50
|
+
lastAttemptAt: Date.now(), failures: 0, running: false, lastError: null,
|
|
51
|
+
lastResult: result
|
|
52
|
+
});
|
|
53
|
+
} catch (err) {
|
|
54
|
+
const failures = (entry.failures ?? 0) + 1;
|
|
55
|
+
state.set(account.id, {
|
|
56
|
+
lastAttemptAt: Date.now(), failures, running: false, lastError: describeError(err)
|
|
57
|
+
});
|
|
58
|
+
// Warn, not error: a mail server being unreachable is an ordinary
|
|
59
|
+
// condition, and the backoff already handles it.
|
|
60
|
+
logger.warn(
|
|
61
|
+
`[mail] poll failed for mailbox ${account.id} (${failures} in a row): ${err.message}`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* One pass: find who is due and sync them, one at a time.
|
|
68
|
+
*
|
|
69
|
+
* Sequential on purpose. Polling every mailbox at once means opening every
|
|
70
|
+
* connection at once, which is exactly the burst a mail server throttles.
|
|
71
|
+
*
|
|
72
|
+
* @returns {Promise<void>}
|
|
73
|
+
*/
|
|
74
|
+
async function pass() {
|
|
75
|
+
if (stopped) return;
|
|
76
|
+
|
|
77
|
+
let accounts;
|
|
78
|
+
try {
|
|
79
|
+
accounts = await listAccounts();
|
|
80
|
+
} catch (err) {
|
|
81
|
+
logger.warn(`[mail] could not list mailboxes to poll: ${err.message}`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Forget state for mailboxes that have been removed, so the map does
|
|
86
|
+
// not grow for the life of the process.
|
|
87
|
+
if (stopped) return;
|
|
88
|
+
const live = new Set(accounts.map(a => a.id));
|
|
89
|
+
for (const id of [...state.keys()]) {
|
|
90
|
+
if (!live.has(id)) state.delete(id);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const due = selectDuePolls(accounts, state, {now: Date.now(), defaultMinutes});
|
|
94
|
+
for (const {id} of due) {
|
|
95
|
+
if (stopped) return;
|
|
96
|
+
const account = accounts.find(a => a.id === id);
|
|
97
|
+
if (account) await runOne(account);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function tick() {
|
|
102
|
+
if (stopped) return Promise.resolve();
|
|
103
|
+
// A timer and a manual pass share the same promise, including the
|
|
104
|
+
// account-listing phase before per-account running flags exist.
|
|
105
|
+
if (active) return active;
|
|
106
|
+
active = pass().finally(() => { active = null; });
|
|
107
|
+
return active;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
/**
|
|
112
|
+
* @returns {void}
|
|
113
|
+
*/
|
|
114
|
+
start() {
|
|
115
|
+
if (timer) return;
|
|
116
|
+
stopped = false;
|
|
117
|
+
timer = setInterval(() => {
|
|
118
|
+
tick().catch(err => logger.warn(`[mail] poll tick failed: ${err.message}`));
|
|
119
|
+
}, tickMs);
|
|
120
|
+
// Never hold the process open for a poll.
|
|
121
|
+
timer.unref?.();
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* @returns {Promise<void>} resolves once the active pass has drained
|
|
126
|
+
*/
|
|
127
|
+
stop() {
|
|
128
|
+
stopped = true;
|
|
129
|
+
if (timer) clearInterval(timer);
|
|
130
|
+
timer = null;
|
|
131
|
+
return active ?? Promise.resolve();
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Run a pass immediately, for a manual "sync now".
|
|
136
|
+
*
|
|
137
|
+
* @returns {Promise<void>}
|
|
138
|
+
*/
|
|
139
|
+
pollNow: tick,
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* What the poller currently believes about each mailbox.
|
|
143
|
+
*
|
|
144
|
+
* @returns {object}
|
|
145
|
+
*/
|
|
146
|
+
state() {
|
|
147
|
+
return Object.fromEntries(state);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Source: @domma-mail/core 0.18.0, packages/core/src/mail/publicMailbox.js.
|
|
2
|
+
// Update with domma-mail/scripts/sync-cms.mjs; edit the shared source.
|
|
3
|
+
/** Standalone mailbox summary. Explicit fields keep credentials out of responses. */
|
|
4
|
+
export function publicMailbox(account) {
|
|
5
|
+
if (!account) return null;
|
|
6
|
+
return {
|
|
7
|
+
id: account.id,
|
|
8
|
+
label: account.label,
|
|
9
|
+
host: account.host,
|
|
10
|
+
port: account.port,
|
|
11
|
+
secure: account.secure,
|
|
12
|
+
username: account.username,
|
|
13
|
+
isDefault: account.isDefault === true,
|
|
14
|
+
auth: account.auth === 'oauth' ? 'oauth' : 'password',
|
|
15
|
+
...(account.oauth ? {oauth: {
|
|
16
|
+
provider: account.oauth.provider, clientId: account.oauth.clientId,
|
|
17
|
+
tenant: account.oauth.tenant ?? null, status: account.oauth.status,
|
|
18
|
+
error: account.oauth.error ?? null,
|
|
19
|
+
hasClientSecret: Boolean(account.oauth.clientSecretSealed)
|
|
20
|
+
}} : {}),
|
|
21
|
+
syncFolders: Array.isArray(account.syncFolders) ? account.syncFolders : null,
|
|
22
|
+
pollIntervalMinutes: account.pollIntervalMinutes ?? null,
|
|
23
|
+
hasPassword: Boolean(account.passwordSealed),
|
|
24
|
+
createdAt: account.createdAt,
|
|
25
|
+
updatedAt: account.updatedAt
|
|
26
|
+
};
|
|
27
|
+
}
|