domma-cms 1.61.1 → 1.61.2
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 +5 -0
- package/package.json +1 -1
- package/plugins/_lib/admin/mail/body-menu.js +1 -1
- package/plugins/_lib/admin/mail/cms-host.js +1 -1
- package/plugins/_lib/admin/mail/compose-window.js +1 -1
- package/plugins/_lib/admin/mail/contacts.js +1 -1
- package/plugins/_lib/admin/mail/diagnostics-section.js +1 -1
- package/plugins/_lib/admin/mail/drag-drop.js +1 -1
- package/plugins/_lib/admin/mail/folder-tree.js +1 -1
- package/plugins/_lib/admin/mail/font-controls.js +1 -1
- package/plugins/_lib/admin/mail/fonts.js +1 -1
- package/plugins/_lib/admin/mail/host-context.js +1 -1
- package/plugins/_lib/admin/mail/identity.js +1 -1
- package/plugins/_lib/admin/mail/image-senders-section.js +1 -1
- package/plugins/_lib/admin/mail/keyboard.js +1 -1
- package/plugins/_lib/admin/mail/mail.html +1 -1
- package/plugins/_lib/admin/mail/message-actions.js +1 -1
- package/plugins/_lib/admin/mail/oauth-panel.js +1 -1
- package/plugins/_lib/admin/mail/panes.js +1 -1
- package/plugins/_lib/admin/mail/reader-kit.js +1 -1
- package/plugins/_lib/admin/mail/reader-runtime.js +27 -1
- package/plugins/_lib/admin/mail/reader-view.js +1 -1
- package/plugins/_lib/admin/mail/resizable.js +1 -1
- package/plugins/_lib/admin/mail/restore-spam.js +1 -1
- package/plugins/_lib/admin/mail/rules.js +1 -1
- package/plugins/_lib/admin/mail/scheduling.js +1 -1
- package/plugins/_lib/admin/mail/section-kit.js +1 -1
- package/plugins/_lib/admin/mail/security-note.js +1 -1
- package/plugins/_lib/admin/mail/settings-section.js +1 -1
- package/plugins/_lib/admin/mail/templates.js +1 -1
- package/plugins/_lib/admin/mail/threads.js +1 -1
- package/plugins/_lib/admin/mail/vacation.js +1 -1
- package/plugins/_lib/admin/mail/when-closed.js +1 -1
- package/plugins/_lib/admin/ui/dates.js +1 -1
- package/plugins/_lib/admin/ui/resizable.js +1 -1
- package/plugins/_lib/domma-mail.lock.json +80 -80
- package/plugins/_lib/mail/accountFileStore.js +1 -1
- package/plugins/_lib/mail/accountRepository.js +1 -1
- package/plugins/_lib/mail/accountRoutes.js +1 -1
- package/plugins/_lib/mail/bodyTokenProvider.js +1 -1
- package/plugins/_lib/mail/bodyTokens.js +1 -1
- package/plugins/_lib/mail/compose.js +1 -1
- package/plugins/_lib/mail/defaults.js +1 -1
- package/plugins/_lib/mail/envelope.js +1 -1
- package/plugins/_lib/mail/folderActions.js +1 -1
- package/plugins/_lib/mail/folderRuntime.js +1 -1
- package/plugins/_lib/mail/folders.js +1 -1
- package/plugins/_lib/mail/imapPoolRuntime.js +1 -1
- package/plugins/_lib/mail/mbox.js +1 -1
- package/plugins/_lib/mail/message-action.js +1 -1
- package/plugins/_lib/mail/messageSecurity.js +1 -1
- package/plugins/_lib/mail/messageSecurityProvider.js +1 -1
- package/plugins/_lib/mail/networkAddresses.js +1 -1
- package/plugins/_lib/mail/networkPolicy.js +1 -1
- package/plugins/_lib/mail/oauthAccounts.js +1 -1
- package/plugins/_lib/mail/oauthRouteRuntime.js +1 -1
- package/plugins/_lib/mail/oauthRuntime.js +1 -1
- package/plugins/_lib/mail/pollSchedule.js +1 -1
- package/plugins/_lib/mail/poller.js +1 -1
- package/plugins/_lib/mail/pollerRuntime.js +1 -1
- package/plugins/_lib/mail/priority.js +1 -1
- package/plugins/_lib/mail/publicMailbox.js +1 -1
- package/plugins/_lib/mail/readRuntime.js +1 -1
- package/plugins/_lib/mail/render.js +1 -1
- package/plugins/_lib/mail/ruleRunner.js +1 -1
- package/plugins/_lib/mail/schedulerRuntime.js +1 -1
- package/plugins/_lib/mail/secretProvider.js +1 -1
- package/plugins/_lib/mail/secretbox.js +1 -1
- package/plugins/_lib/mail/senderAuth.js +1 -1
- package/plugins/_lib/mail/sieve.js +1 -1
- package/plugins/_lib/mail/smtpService.js +1 -1
- package/plugins/_lib/mail/snoozeRuntime.js +1 -1
- package/plugins/_lib/mail/store.js +1 -1
- package/plugins/_lib/mail/subscriptions.js +1 -1
- package/plugins/_lib/mail/syncPlan.js +1 -1
- package/plugins/_lib/mail/syncRuntime.js +1 -1
- package/plugins/_lib/mail/syncSelection.js +1 -1
- package/plugins/_lib/mail/unreadBadge.js +1 -1
- package/plugins/_lib/mail/unsubscribe.js +1 -1
- package/plugins/_lib/mail/vacationRuntime.js +1 -1
- package/plugins/_lib/mail/write.js +1 -1
- package/plugins/docs/CHANGELOG.md +5 -0
- package/plugins/docs/CLAUDE.md +30 -0
- package/plugins/docs/admin/views/docs.js +2 -1
- package/plugins/docs/admin/views/editor.js +5 -3
- package/plugins/docs/docs/guide.md +11 -0
- package/plugins/docs/lib/store.js +46 -2
- package/plugins/docs/plugin.js +70 -28
- package/plugins/docs/plugin.json +14 -1
- package/plugins/docs/tests/restricted.test.js +240 -0
- package/plugins/free-tier.lock.json +15 -13
- package/plugins/mail-reader/CLAUDE.md +6 -0
- package/plugins/mail-reader/plugin.js +9 -0
- package/plugins/mail-reader/plugin.json +1 -1
package/plugins/docs/plugin.js
CHANGED
|
@@ -11,7 +11,7 @@ import {createStore} from '../_lib/dataStore.js';
|
|
|
11
11
|
import {savePluginState} from '../../server/services/plugins.js';
|
|
12
12
|
import {getEffectiveLevel, getEffectiveRoles} from '../../server/services/userRoles.js';
|
|
13
13
|
import {listUsers} from '../../server/services/users.js';
|
|
14
|
-
import {getPermissionsFor, getRoleLevel} from '../../server/services/roles.js';
|
|
14
|
+
import {getPermissionsFor, getPermissionsForRole, getRoleLevel} from '../../server/services/roles.js';
|
|
15
15
|
import {getConfig} from '../../server/config.js';
|
|
16
16
|
import {originOf, trustedOrigin} from '../../server/services/passwordReset.js';
|
|
17
17
|
import {createTransport, sendEmail} from '../../server/services/email.js';
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
runtime, sanitizeDoc, withoutSuggestions, allowMarkup, readDoc, writeDoc, mutateDoc, removeDoc, listDocs, newDoc, cleanTitle, shouldSnapshot,
|
|
25
25
|
snapshotVersion, listVersions, readVersion, accessOf, canEdit, stateFor, setStar, touchRecent, forgetDoc,
|
|
26
26
|
lockOf, acquireLock, releaseLock, publicLock, newLinkToken, selectRows, placeCounts, purgeTrash, validId, DATA_DIR,
|
|
27
|
-
outwardRefusal, onlyThroughExtension, frozenFor,
|
|
27
|
+
outwardRefusal, onlyThroughExtension, frozenFor, isRestricted, setRestrictedCheck, restrictedByRoles, holdsRestriction,
|
|
28
28
|
kindOf, readFileBytes, writeFileBytes, copyFileBytes, restoreVersionFile, readVersionFile, fileRecord
|
|
29
29
|
} from './lib/store.js';
|
|
30
30
|
import {importFile, kindOf as importKind} from './lib/importer.js';
|
|
@@ -138,7 +138,19 @@ export default async function docsPlugin(fastify, options) {
|
|
|
138
138
|
const make = [authenticate, need('create')];
|
|
139
139
|
const edit = [authenticate, need('update')];
|
|
140
140
|
const drop = [authenticate, need('delete')];
|
|
141
|
-
|
|
141
|
+
// 2.15: restricted people (lib/store.js) - own and shared documents only, whatever the site's settings.
|
|
142
|
+
// Tests pass `options.isRestricted`; the CMS's role data decides otherwise.
|
|
143
|
+
setRestrictedCheck(typeof options.isRestricted === 'function' ? options.isRestricted : (user) => restrictedByRoles(getEffectiveRoles(user), {
|
|
144
|
+
isRoot: (r) => getRoleLevel(r) === 0,
|
|
145
|
+
marked: (r) => holdsRestriction(getPermissionsForRole(r)),
|
|
146
|
+
givesDocs: (r) => (getPermissionsFor('docs', 'read') || []).includes(r)
|
|
147
|
+
}));
|
|
148
|
+
/** An administrator for Docs: level 0 or 1, and not restricted (a restricted person is never one). */
|
|
149
|
+
const adminUser = (user) => { try { return !isRestricted(user) && getEffectiveLevel(user) <= 1; } catch { return false; } };
|
|
150
|
+
const isAdmin = (req) => adminUser(req.user);
|
|
151
|
+
const NO_SHARING = 'Your role keeps documents to you and the people already sharing them - it cannot share with anyone new.';
|
|
152
|
+
const NO_LINKS = 'Your role cannot make public links.';
|
|
153
|
+
const NO_SEND = 'Your role cannot email documents from Docs.';
|
|
142
154
|
|
|
143
155
|
/** Names by user id, for owners and share lists. Cached briefly - listUsers reads every user file. */
|
|
144
156
|
let names = null;
|
|
@@ -180,7 +192,7 @@ export default async function docsPlugin(fastify, options) {
|
|
|
180
192
|
async function usableFolder(req, folderId) {
|
|
181
193
|
if (!folderId) return true;
|
|
182
194
|
const f = (await foldersStore.readArray()).find(x => x.id === folderId);
|
|
183
|
-
return Boolean(f && (f.userId === req.user.id || config.scope === 'all'));
|
|
195
|
+
return Boolean(f && (f.userId === req.user.id || (config.scope === 'all' && !isRestricted(req.user))));
|
|
184
196
|
}
|
|
185
197
|
|
|
186
198
|
/** The whole document as the editor sees it: body, access, lock, star, people. */
|
|
@@ -207,7 +219,9 @@ export default async function docsPlugin(fastify, options) {
|
|
|
207
219
|
// 2.12: why this person may not change it now (a protected wiki page) - the editor opens read only.
|
|
208
220
|
frozen: frozenFor(doc, req.user),
|
|
209
221
|
// 2.13: a PDF's viewer address for this person, good for twenty minutes (refreshed with every poll).
|
|
210
|
-
...(kindOf(doc) === 'pdf' ? {fileTicket: viewTicket(doc, req)} : {})
|
|
222
|
+
...(kindOf(doc) === 'pdf' ? {fileTicket: viewTicket(doc, req)} : {}),
|
|
223
|
+
// 2.15: a restricted person makes and passes on no public link - not even the owner's.
|
|
224
|
+
...(isRestricted(req.user) ? {restrictedUser: true, publicLink: null, publicLinksAllowed: false} : {})
|
|
211
225
|
};
|
|
212
226
|
}
|
|
213
227
|
|
|
@@ -215,7 +229,10 @@ export default async function docsPlugin(fastify, options) {
|
|
|
215
229
|
registry.services = {
|
|
216
230
|
// 2.12: why this person may not share, link, send - or publish - this document ('' = they may).
|
|
217
231
|
outwardRefusal: (doc, user) => outwardRefusal(doc, user),
|
|
218
|
-
readDoc, writeDoc, listDocs, accessOf: (doc, user) => accessOf(doc, user, (
|
|
232
|
+
readDoc, writeDoc, listDocs, accessOf: (doc, user) => accessOf(doc, user, adminUser(user)),
|
|
233
|
+
// 2.15: is this person restricted (own and shared documents only; nothing published, linked or sent)?
|
|
234
|
+
// Docs Pro refuses them Spaces, cloud copies, its signing screens and link settings.
|
|
235
|
+
restrictedUser: (user) => isRestricted(user),
|
|
219
236
|
sanitizeDoc, allowMarkup, siteBase, linkBase, people, config: () => ({...config}), htmlToText,
|
|
220
237
|
// Folders (2.1) - Docs Pro's Spaces are folders.
|
|
221
238
|
listFolders: () => foldersStore.readArray(),
|
|
@@ -234,7 +251,7 @@ export default async function docsPlugin(fastify, options) {
|
|
|
234
251
|
await touchRecent(user.id, doc.id);
|
|
235
252
|
return doc;
|
|
236
253
|
},
|
|
237
|
-
isAdmin: (user) =>
|
|
254
|
+
isAdmin: (user) => adminUser(user),
|
|
238
255
|
// 2.11 (the Wiki): change a document inside its write chain, as every Docs route does; a body as the
|
|
239
256
|
// public sees it (sanitised, pending suggestions not made, add-ons' filters); who is editing it now.
|
|
240
257
|
mutateDoc: (id, fn) => mutateDoc(id, fn),
|
|
@@ -368,21 +385,26 @@ export default async function docsPlugin(fastify, options) {
|
|
|
368
385
|
* whitelisted, never spread, so a secret added to the settings object is
|
|
369
386
|
* not handed to the browser.
|
|
370
387
|
*/
|
|
371
|
-
fastify.get('/settings', {preHandler: read}, async (req) =>
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
388
|
+
fastify.get('/settings', {preHandler: read}, async (req) => {
|
|
389
|
+
// 2.15: a restricted person's screens offer no public links, no email and no sharing, and see only their own.
|
|
390
|
+
const restricted = isRestricted(req.user);
|
|
391
|
+
return {
|
|
392
|
+
autoSaveInterval: Number(config.autoSaveInterval) || 0,
|
|
393
|
+
maxVersions: Number(config.maxVersions) || 50,
|
|
394
|
+
publicLinks: config.publicLinks !== false && !restricted,
|
|
395
|
+
allowSend: config.allowSend !== false && !restricted,
|
|
396
|
+
trashDays: Number(config.trashDays) || 30,
|
|
397
|
+
// Shown, never edited here: flipping 'user' to 'all' would hand every
|
|
398
|
+
// user everybody else's documents - a decision for config.
|
|
399
|
+
scope: config.scope === 'all' && !restricted ? 'all' : 'user',
|
|
400
|
+
canEdit: isAdmin(req),
|
|
401
|
+
extensions: registry.adminModules(),
|
|
402
|
+
suggestions: registry.hasSuggest(),
|
|
403
|
+
// 2.13: PDF documents - uploads always; the text inside them is searchable when pdfjs-dist is on this server.
|
|
404
|
+
pdf: {maxBytes: MAX_PDF_BYTES, search: extractCapability().available, reason: extractCapability().reason},
|
|
405
|
+
...(restricted ? {restrictedUser: true} : {})
|
|
406
|
+
};
|
|
407
|
+
});
|
|
386
408
|
|
|
387
409
|
fastify.put('/settings', {preHandler: [authenticate, requireAdmin]}, async (req, reply) => {
|
|
388
410
|
const body = req.body || {};
|
|
@@ -420,6 +442,8 @@ export default async function docsPlugin(fastify, options) {
|
|
|
420
442
|
* name; an admin also sees the email, to tell two Sams apart.
|
|
421
443
|
*/
|
|
422
444
|
fastify.get('/people', {preHandler: read}, async (req) => {
|
|
445
|
+
// 2.15: no directory for a restricted person - they share with nobody new (PUT .../shares).
|
|
446
|
+
if (isRestricted(req.user)) return [];
|
|
423
447
|
const {users} = await people();
|
|
424
448
|
let roles = null;
|
|
425
449
|
try { roles = new Set(getPermissionsFor('docs', 'read')); } catch { roles = null; }
|
|
@@ -430,6 +454,9 @@ export default async function docsPlugin(fastify, options) {
|
|
|
430
454
|
return users
|
|
431
455
|
.filter(u => u.id !== req.user.id && u.disabled !== true && u.isActive !== false && u.active !== false)
|
|
432
456
|
.filter(u => !roles || !roles.size || getEffectiveRoles(u).some(r => roles.has(r)))
|
|
457
|
+
// 2.15: restricted people (a Job Board's companies) are listed to Docs administrators only - nobody else
|
|
458
|
+
// may find them here or share with them (PUT .../shares).
|
|
459
|
+
.filter(u => admin || !isRestricted(u))
|
|
433
460
|
.map(u => ({id: u.id, name: String(u.name || '').trim() || 'Unnamed', ...(admin ? {email: u.email || ''} : {})}));
|
|
434
461
|
});
|
|
435
462
|
|
|
@@ -570,7 +597,8 @@ export default async function docsPlugin(fastify, options) {
|
|
|
570
597
|
if (Array.isArray(allowed) && allowed.length && !getEffectiveRoles(viewer).some(r => allowed.includes(r) || (() => { try { return getRoleLevel(r) === 0; } catch { return false; } })())) return reply.code(403).send({error: 'This viewer link no longer works.'});
|
|
571
598
|
} catch { /* an older core without the permission: the ticket stands */ }
|
|
572
599
|
const doc = await readDoc(req.params.id);
|
|
573
|
-
|
|
600
|
+
// The person as they are now (2.15: their roles decide whether they are restricted).
|
|
601
|
+
const access = accessOf(doc, {...viewer, id: claims.userId}, claims.admin && adminUser(viewer));
|
|
574
602
|
if (!doc || !access || (doc.trashedAt && doc.userId !== claims.userId) || kindOf(doc) !== 'pdf') return reply.code(404).send({error: 'Document not found'});
|
|
575
603
|
const buf = await readFileBytes(doc.id);
|
|
576
604
|
if (!buf) return reply.code(404).send({error: 'The file is missing.'});
|
|
@@ -805,9 +833,19 @@ export default async function docsPlugin(fastify, options) {
|
|
|
805
833
|
if (doc.trashedAt) return reply.code(409).send({error: 'This document is in Trash.'});
|
|
806
834
|
// Only add-on access (2.11): editing, not passing it on. A restricted document takes nobody new (below).
|
|
807
835
|
if (onlyThroughExtension(doc, req.user)) return reply.code(403).send({error: outwardRefusal(doc, req.user)});
|
|
808
|
-
const {users} = await people();
|
|
809
|
-
const known = new Map(users.map(u => [u.id, u]));
|
|
810
836
|
const incoming = Array.isArray(req.body?.shares) ? req.body.shares : [];
|
|
837
|
+
const had = new Set((doc.shares || []).map(x => x.userId));
|
|
838
|
+
// 2.15: a restricted person names nobody new at all - refused before any id is looked up, so the answer
|
|
839
|
+
// never says whether an id is an account.
|
|
840
|
+
const closed = isRestricted(req.user);
|
|
841
|
+
if (closed && incoming.slice(0, 200).some(x => { const u = String(x?.userId || ''); return u && u !== doc.userId && !had.has(u); })) {
|
|
842
|
+
return reply.code(403).send({error: NO_SHARING});
|
|
843
|
+
}
|
|
844
|
+
const {users} = await people();
|
|
845
|
+
const admin = isAdmin(req);
|
|
846
|
+
// 2.15: only a Docs administrator gives a restricted person a new share (as /people lists them to admins only);
|
|
847
|
+
// for anyone else they are as unknown as an id that is no account.
|
|
848
|
+
const known = new Map(users.filter(u => admin || had.has(u.id) || !isRestricted(u)).map(u => [u.id, u]));
|
|
811
849
|
const seen = new Set();
|
|
812
850
|
const shares = [];
|
|
813
851
|
for (const s of incoming.slice(0, 200)) {
|
|
@@ -830,14 +868,16 @@ export default async function docsPlugin(fastify, options) {
|
|
|
830
868
|
}
|
|
831
869
|
// A restricted document (a members-only wiki page, 2.11) takes nobody new - owner included.
|
|
832
870
|
const restricted = registry.restrictionOf?.(doc) || '';
|
|
871
|
+
// 2.15: a restricted person shares with nobody new either (checked again against the list as it is now).
|
|
833
872
|
let added = [];
|
|
834
873
|
const updated = await mutateDoc(doc.id, (cur) => {
|
|
835
874
|
// Against the list as it is now, not as it was read above.
|
|
836
875
|
added = shares.filter(s => !(cur.shares || []).some(p => p.userId === s.userId));
|
|
837
|
-
if (restricted && added.length) return null;
|
|
876
|
+
if ((restricted || closed) && added.length) return null;
|
|
838
877
|
return {...cur, shares};
|
|
839
878
|
});
|
|
840
879
|
if (restricted && added.length) return reply.code(403).send({error: `${restricted} No one new can be given access.`});
|
|
880
|
+
if (closed && added.length) return reply.code(403).send({error: NO_SHARING});
|
|
841
881
|
|
|
842
882
|
let notified = 0;
|
|
843
883
|
if (req.body?.notify && added.length) {
|
|
@@ -875,6 +915,7 @@ export default async function docsPlugin(fastify, options) {
|
|
|
875
915
|
/** POST /documents/:id/link - turn the public link on (idempotent). */
|
|
876
916
|
fastify.post('/documents/:id/link', {preHandler: edit}, async (req, reply) => {
|
|
877
917
|
if (config.publicLinks === false) return reply.code(403).send({error: 'Public links are switched off on this site.'});
|
|
918
|
+
if (isRestricted(req.user)) return reply.code(403).send({error: NO_LINKS});
|
|
878
919
|
const hit = await load(req, reply, 'edit');
|
|
879
920
|
if (!hit) return;
|
|
880
921
|
const {doc, access} = hit;
|
|
@@ -903,6 +944,7 @@ export default async function docsPlugin(fastify, options) {
|
|
|
903
944
|
*/
|
|
904
945
|
fastify.post('/documents/:id/send', {preHandler: edit, config: {rateLimit: {max: 10, timeWindow: '10 minutes'}}}, async (req, reply) => {
|
|
905
946
|
if (config.allowSend === false) return reply.code(403).send({error: 'Sending documents by email is switched off on this site.'});
|
|
947
|
+
if (isRestricted(req.user)) return reply.code(403).send({error: NO_SEND});
|
|
906
948
|
const hit = await load(req, reply, 'edit');
|
|
907
949
|
if (!hit) return;
|
|
908
950
|
let {doc} = hit;
|
|
@@ -1039,7 +1081,7 @@ export default async function docsPlugin(fastify, options) {
|
|
|
1039
1081
|
|
|
1040
1082
|
fastify.get('/folders', {preHandler: read}, async (req) => {
|
|
1041
1083
|
const folders = await foldersStore.readArray();
|
|
1042
|
-
return config.scope === 'user' ? folders.filter(f => f.userId === req.user.id) : folders;
|
|
1084
|
+
return config.scope === 'user' || isRestricted(req.user) ? folders.filter(f => f.userId === req.user.id) : folders;
|
|
1043
1085
|
});
|
|
1044
1086
|
|
|
1045
1087
|
fastify.post('/folders', {preHandler: make}, async (req, reply) => {
|
|
@@ -1080,7 +1122,7 @@ export default async function docsPlugin(fastify, options) {
|
|
|
1080
1122
|
|
|
1081
1123
|
fastify.get('/templates', {preHandler: read}, async (req) => {
|
|
1082
1124
|
const templates = await templatesStore.readArray();
|
|
1083
|
-
const own = config.scope === 'user' ? templates.filter(t => t.userId === req.user.id) : templates;
|
|
1125
|
+
const own = config.scope === 'user' || isRestricted(req.user) ? templates.filter(t => t.userId === req.user.id) : templates;
|
|
1084
1126
|
// Add-ons' ready-made templates (2.6), after the user's own: read only, sanitised like any body.
|
|
1085
1127
|
const builtIn = registry.builtInTemplates().map(t => ({
|
|
1086
1128
|
id: `x-${t.owner}-${t.id}`, name: String(t.name || 'Template').slice(0, 120), description: String(t.description || '').slice(0, 300),
|
package/plugins/docs/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docs",
|
|
3
3
|
"displayName": "Docs",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.15.0",
|
|
5
5
|
"tier": "free",
|
|
6
6
|
"description": "A document editor: sharing, public links, import and export, send to a page, blog or email, version history and templates. PDF documents: add a PDF and it is kept as it is - filed, shared, linked, emailed and versioned like any document, shown in the browser's own viewer.",
|
|
7
7
|
"author": "Darryl Waterhouse",
|
|
@@ -81,6 +81,19 @@
|
|
|
81
81
|
"admin",
|
|
82
82
|
"user"
|
|
83
83
|
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"key": "docs-restricted",
|
|
87
|
+
"label": "Docs: own documents only",
|
|
88
|
+
"group": "Plugins",
|
|
89
|
+
"description": "A role with this uses Docs for its own documents and the ones shared with it, and nothing more: no list of people, no sharing with anyone new, no public links, no emailing documents, nothing published (Domma Spaces, cloud copies) - whatever the site's Docs settings say. It changes nothing for a person who also holds a role that gives Docs without it, and nothing for the top (level-0) role.",
|
|
90
|
+
"actions": [
|
|
91
|
+
{
|
|
92
|
+
"key": "on",
|
|
93
|
+
"label": "Restricted",
|
|
94
|
+
"description": "Own and shared documents only"
|
|
95
|
+
}
|
|
96
|
+
]
|
|
84
97
|
}
|
|
85
98
|
],
|
|
86
99
|
"uses": {
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import {DATA} from './_env.js';
|
|
2
|
+
import {after, before, test} from 'node:test';
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import Fastify from 'fastify';
|
|
5
|
+
import fs from 'fs/promises';
|
|
6
|
+
import docsPlugin from '../plugin.js';
|
|
7
|
+
import {restrictedByRoles, holdsRestriction, RESTRICTED_PERMISSION, runtime} from '../lib/store.js';
|
|
8
|
+
import {docsRegistry} from '../lib/extensions.js';
|
|
9
|
+
import {load as loadRoles} from '../../../cms/server/services/roles.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Docs 2.15 - restricted people: their own documents and the ones shared with them, and nothing else -
|
|
13
|
+
* under BOTH site scopes ('user' and 'all'). No people list, no sharing with anyone new, no public links,
|
|
14
|
+
* no email. Everything else is as it was for everyone else (the last test runs the real role check with
|
|
15
|
+
* no restricted role on the site).
|
|
16
|
+
*
|
|
17
|
+
* Who is restricted is injected here (`isRestricted`); the rule itself (`restrictedByRoles`) is tested pure,
|
|
18
|
+
* and the real role data path is driven by the Job Board's tests (plugins/job-board/tests/docs-access.test.js).
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
before(async () => { await loadRoles(); }); // super-admin is level 0 (a Docs administrator)
|
|
22
|
+
after(async () => { await fs.rm(DATA, {recursive: true, force: true}); });
|
|
23
|
+
|
|
24
|
+
const PEOPLE = [
|
|
25
|
+
{id: 'r-alice', name: 'Alice Staff', email: 'alice@site.test', role: 'user'},
|
|
26
|
+
{id: 'r-ada', name: 'Ada Admin', email: 'ada@site.test', role: 'super-admin'},
|
|
27
|
+
{id: 'r-rita', name: 'Rita Company', email: 'rita@acme.test', role: 'jb-company'},
|
|
28
|
+
{id: 'r-rex', name: 'Rex Other', email: 'rex@bolt.test', role: 'jb-company'},
|
|
29
|
+
// A level-1 account that a role also restricts: never an administrator to Docs.
|
|
30
|
+
{id: 'r-root', name: 'Rhoda Restricted Admin', email: 'rhoda@site.test', role: 'admin', restricted: true}
|
|
31
|
+
];
|
|
32
|
+
const RESTRICTED = new Set(['r-rita', 'r-rex', 'r-root']);
|
|
33
|
+
const isRestricted = (user) => RESTRICTED.has(user?.id);
|
|
34
|
+
|
|
35
|
+
const outbox = [];
|
|
36
|
+
/** Every document Rita owns or had shared with her, across both scopes' runs. */
|
|
37
|
+
const ritaMay = new Set();
|
|
38
|
+
const mailer = {createTransport: async () => ({}), sendEmail: async (t, m) => { outbox.push(m); return {ok: true}; }};
|
|
39
|
+
|
|
40
|
+
async function appFor(id, settings) {
|
|
41
|
+
const person = PEOPLE.find(p => p.id === id);
|
|
42
|
+
const app = Fastify();
|
|
43
|
+
const authenticate = async (req) => { req.user = {id: person.id, name: person.name, email: person.email, role: person.role}; };
|
|
44
|
+
await app.register(docsPlugin, {prefix: '/api/plugins/docs', settings: {...settings},
|
|
45
|
+
auth: {authenticate, requireAdmin: async () => {}, requirePermission: () => async () => {}},
|
|
46
|
+
listUsers: async () => PEOPLE, mailer, isRestricted});
|
|
47
|
+
await app.ready();
|
|
48
|
+
return app;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function call(app, method, url, payload) {
|
|
52
|
+
const res = await app.inject({method, url: `/api/plugins/docs${url}`, payload});
|
|
53
|
+
let body = null;
|
|
54
|
+
try { body = JSON.parse(res.body); } catch { body = res.body; }
|
|
55
|
+
return {status: res.statusCode, body};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
test('the rule: restricted when a role holds it and no Docs-giving role lacks it; never level 0', () => {
|
|
59
|
+
const perms = {
|
|
60
|
+
'jb-company': ['job-board.read', 'docs.read', 'docs.create', RESTRICTED_PERMISSION],
|
|
61
|
+
'jb-agent': ['docs', `${RESTRICTED_PERMISSION}.on`],
|
|
62
|
+
'jb-candidate': ['job-board.read'],
|
|
63
|
+
user: ['docs'],
|
|
64
|
+
'super-admin': [RESTRICTED_PERMISSION]
|
|
65
|
+
};
|
|
66
|
+
const look = {
|
|
67
|
+
isRoot: (r) => r === 'super-admin',
|
|
68
|
+
marked: (r) => holdsRestriction(perms[r]),
|
|
69
|
+
givesDocs: (r) => (perms[r] || []).some(p => p === 'docs' || p.startsWith('docs.'))
|
|
70
|
+
};
|
|
71
|
+
assert.equal(restrictedByRoles(['jb-company'], look), true);
|
|
72
|
+
assert.equal(restrictedByRoles(['jb-agent'], look), true, 'an action of the resource counts');
|
|
73
|
+
assert.equal(restrictedByRoles(['jb-candidate'], look), false, 'no mark, no restriction (and no Docs)');
|
|
74
|
+
assert.equal(restrictedByRoles(['user'], look), false);
|
|
75
|
+
assert.equal(restrictedByRoles(['jb-company', 'user'], look), false, 'a role that opens Docs fully opens it');
|
|
76
|
+
assert.equal(restrictedByRoles(['jb-company', 'jb-candidate'], look), true, 'a role without Docs changes nothing');
|
|
77
|
+
assert.equal(restrictedByRoles(['super-admin'], look), false, 'level 0 is never restricted');
|
|
78
|
+
assert.equal(restrictedByRoles(['jb-company', 'super-admin'], look), false);
|
|
79
|
+
assert.equal(restrictedByRoles([], look), false);
|
|
80
|
+
assert.equal(holdsRestriction(['docs-restrictedish']), false, 'a lookalike resource is not it');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
for (const scope of ['user', 'all']) {
|
|
84
|
+
test(`scope '${scope}': a restricted person sees their own and shared documents only, and passes nothing on`, async () => {
|
|
85
|
+
outbox.length = 0;
|
|
86
|
+
const s = {scope};
|
|
87
|
+
const alice = await appFor('r-alice', s);
|
|
88
|
+
const ada = await appFor('r-ada', s);
|
|
89
|
+
const rita = await appFor('r-rita', s);
|
|
90
|
+
const rex = await appFor('r-rex', s);
|
|
91
|
+
const rhoda = await appFor('r-root', s);
|
|
92
|
+
assert.equal(runtime.config.scope, scope);
|
|
93
|
+
|
|
94
|
+
const mk = async (app, title) => { const r = await call(app, 'POST', '/documents', {title, content: `<p>${title} body</p>`}); assert.equal(r.status, 201); return r.body; };
|
|
95
|
+
const staffDoc = await mk(alice, `Staff notes ${scope}`);
|
|
96
|
+
const adminDoc = await mk(ada, `Admin plans ${scope}`);
|
|
97
|
+
// A Docs administrator shares with a restricted person; anyone else cannot (as if the id were no account).
|
|
98
|
+
const shared = await mk(ada, `Shared draft ${scope}`);
|
|
99
|
+
assert.equal((await call(ada, 'PUT', `/documents/${shared.id}/shares`, {shares: [{userId: 'r-rita', role: 'editor'}]})).status, 200);
|
|
100
|
+
assert.equal((await call(ada, 'POST', `/documents/${shared.id}/link`)).status, 200);
|
|
101
|
+
const aliceTries = await call(alice, 'PUT', `/documents/${staffDoc.id}/shares`, {shares: [{userId: 'r-rita', role: 'viewer'}]});
|
|
102
|
+
assert.equal(aliceTries.status, 200);
|
|
103
|
+
assert.deepEqual(aliceTries.body.shares, [], 'not added');
|
|
104
|
+
const letter = await mk(rita, `Offer letter ${scope}`);
|
|
105
|
+
const folder = (await call(alice, 'POST', '/folders', {name: `Staff folder ${scope}`})).body;
|
|
106
|
+
const template = (await call(alice, 'POST', '/templates', {name: `Staff template ${scope}`, content: '<p>t</p>'})).body;
|
|
107
|
+
|
|
108
|
+
// Other people's documents: 404, under either scope - the restricted admin included.
|
|
109
|
+
for (const app of [rita, rhoda]) {
|
|
110
|
+
for (const d of [staffDoc, adminDoc]) {
|
|
111
|
+
assert.equal((await call(app, 'GET', `/documents/${d.id}`)).status, 404, `${d.title} is not theirs`);
|
|
112
|
+
assert.equal((await call(app, 'PUT', `/documents/${d.id}`, {content: '<p>x</p>'})).status, 404);
|
|
113
|
+
assert.equal((await call(app, 'GET', `/documents/${d.id}/versions`)).status, 404);
|
|
114
|
+
assert.equal((await call(app, 'POST', `/documents/${d.id}/duplicate`)).status, 404);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
assert.equal((await call(rex, 'GET', `/documents/${letter.id}`)).status, 404, "another company's letter");
|
|
118
|
+
assert.equal((await call(rex, 'GET', `/documents/${shared.id}`)).status, 404);
|
|
119
|
+
|
|
120
|
+
// Lists and counts hold only their own and what was shared with them.
|
|
121
|
+
for (const view of ['all', 'recent', 'mine', 'shared']) {
|
|
122
|
+
const ids = (await call(rita, 'GET', `/documents?view=${view}`)).body.map(r => r.id);
|
|
123
|
+
assert.ok(!ids.includes(staffDoc.id) && !ids.includes(adminDoc.id), `${view}: no one else's documents`);
|
|
124
|
+
}
|
|
125
|
+
ritaMay.add(letter.id).add(shared.id);
|
|
126
|
+
const all = (await call(rita, 'GET', '/documents?view=all')).body.map(r => r.id);
|
|
127
|
+
assert.ok(all.includes(letter.id) && all.includes(shared.id));
|
|
128
|
+
assert.ok(all.every(id => ritaMay.has(id)), 'nothing but hers and what was shared with her');
|
|
129
|
+
assert.deepEqual((await call(rex, 'GET', '/documents?view=all')).body, []);
|
|
130
|
+
assert.equal((await call(rex, 'GET', '/count')).body.places.shared, 0);
|
|
131
|
+
|
|
132
|
+
// Their own and the shared one work as before.
|
|
133
|
+
assert.equal((await call(rita, 'PUT', `/documents/${letter.id}`, {content: '<p>Dear candidate</p>'})).status, 200);
|
|
134
|
+
const sharedSeen = await call(rita, 'GET', `/documents/${shared.id}`);
|
|
135
|
+
assert.equal(sharedSeen.status, 200);
|
|
136
|
+
assert.equal(sharedSeen.body.access, 'editor');
|
|
137
|
+
// ...but the owner's public link is not handed to them.
|
|
138
|
+
assert.equal(sharedSeen.body.publicLink, null);
|
|
139
|
+
assert.equal(sharedSeen.body.restrictedUser, true);
|
|
140
|
+
assert.equal((await call(rita, 'PUT', `/documents/${shared.id}`, {content: '<p>edited by Rita</p>'})).status, 200);
|
|
141
|
+
|
|
142
|
+
// No directory.
|
|
143
|
+
assert.deepEqual((await call(rita, 'GET', '/people')).body, []);
|
|
144
|
+
assert.ok(!(await call(alice, 'GET', '/people')).body.some(p => p.id === 'r-rita'), 'not listed to other users');
|
|
145
|
+
assert.ok((await call(ada, 'GET', '/people')).body.some(p => p.id === 'r-rita'), 'listed to Docs administrators');
|
|
146
|
+
// No oracle: an id that is no account is refused exactly as a real one.
|
|
147
|
+
const ghost = await call(rita, 'PUT', `/documents/${letter.id}/shares`, {shares: [{userId: 'no-such-person', role: 'viewer'}]});
|
|
148
|
+
assert.equal(ghost.status, 403);
|
|
149
|
+
|
|
150
|
+
// No one new: not by id, not on their own document, not on the shared one.
|
|
151
|
+
const share = await call(rita, 'PUT', `/documents/${letter.id}/shares`, {shares: [{userId: 'r-alice', role: 'viewer'}]});
|
|
152
|
+
assert.equal(share.status, 403);
|
|
153
|
+
assert.deepEqual((await call(rita, 'GET', `/documents/${letter.id}`)).body.shares, []);
|
|
154
|
+
const reshare = await call(rita, 'PUT', `/documents/${shared.id}/shares`, {shares: [{userId: 'r-rita', role: 'editor'}, {userId: 'r-rex', role: 'viewer'}]});
|
|
155
|
+
assert.equal(reshare.status, 403);
|
|
156
|
+
// Keeping the list as it is is not adding anyone.
|
|
157
|
+
assert.equal((await call(rita, 'PUT', `/documents/${shared.id}/shares`, {shares: [{userId: 'r-rita', role: 'editor'}]})).status, 200);
|
|
158
|
+
|
|
159
|
+
// No public links, no email - their own document either.
|
|
160
|
+
assert.equal((await call(rita, 'POST', `/documents/${letter.id}/link`)).status, 403);
|
|
161
|
+
assert.equal((await call(rita, 'GET', `/documents/${letter.id}`)).body.publicLink, null);
|
|
162
|
+
for (const mode of ['inline', 'link']) {
|
|
163
|
+
assert.equal((await call(rita, 'POST', `/documents/${letter.id}/send`, {to: 'someone@else.test', mode})).status, 403);
|
|
164
|
+
}
|
|
165
|
+
assert.equal(outbox.length, 0, 'nothing was emailed');
|
|
166
|
+
|
|
167
|
+
// Settings say so; folders and templates are their own.
|
|
168
|
+
const set = (await call(rita, 'GET', '/settings')).body;
|
|
169
|
+
assert.equal(set.restrictedUser, true);
|
|
170
|
+
assert.equal(set.publicLinks, false);
|
|
171
|
+
assert.equal(set.allowSend, false);
|
|
172
|
+
assert.equal(set.scope, 'user');
|
|
173
|
+
assert.equal(set.canEdit, false);
|
|
174
|
+
assert.equal((await call(rhoda, 'GET', '/settings')).body.canEdit, false, 'a restricted admin is no Docs admin');
|
|
175
|
+
assert.ok(!(await call(rita, 'GET', '/folders')).body.some(f => f.id === folder.id));
|
|
176
|
+
assert.equal((await call(rita, 'POST', '/documents', {title: 'In their folder', folderId: folder.id})).status, 400);
|
|
177
|
+
assert.ok(!(await call(rita, 'GET', '/templates')).body.some(t => t.id === template.id));
|
|
178
|
+
assert.equal((await call(rhoda, 'DELETE', `/templates/${template.id}`)).status, 404);
|
|
179
|
+
assert.equal((await call(rhoda, 'PUT', `/folders/${folder.id}`, {name: 'Mine now'})).status, 404);
|
|
180
|
+
|
|
181
|
+
// An add-on that gives everyone edit access (a Wiki) gives them nothing.
|
|
182
|
+
docsRegistry().register('restrict-test', {access: () => 'editor'});
|
|
183
|
+
try {
|
|
184
|
+
assert.equal((await call(rita, 'GET', `/documents/${staffDoc.id}`)).status, 404);
|
|
185
|
+
assert.equal((await call(alice, 'GET', `/documents/${adminDoc.id}`)).status, 200, 'everyone else still gets it');
|
|
186
|
+
} finally { docsRegistry().unregister('restrict-test'); }
|
|
187
|
+
|
|
188
|
+
// Services (Docs Pro, the Job Board) answer the same.
|
|
189
|
+
const svc = docsRegistry().services;
|
|
190
|
+
assert.equal(svc.restrictedUser({id: 'r-rita', role: 'jb-company'}), true);
|
|
191
|
+
assert.equal(svc.accessOf(staffDoc, {id: 'r-rita', role: 'jb-company'}), null);
|
|
192
|
+
assert.equal(svc.accessOf(letter, {id: 'r-rita', role: 'jb-company'}), 'owner');
|
|
193
|
+
assert.equal(svc.isAdmin({id: 'r-root', role: 'admin'}), false);
|
|
194
|
+
|
|
195
|
+
// Everyone else, unchanged.
|
|
196
|
+
assert.equal((await call(alice, 'GET', `/documents/${adminDoc.id}`)).status, scope === 'all' ? 200 : 404);
|
|
197
|
+
assert.equal((await call(ada, 'GET', `/documents/${letter.id}`)).status, scope === 'all' ? 200 : 404);
|
|
198
|
+
|
|
199
|
+
for (const a of [alice, ada, rita, rex, rhoda]) await a.close();
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
test('with no restricted role on the site (the real role check), every route answers as before', async () => {
|
|
204
|
+
await loadRoles();
|
|
205
|
+
outbox.length = 0;
|
|
206
|
+
const build = async (id) => {
|
|
207
|
+
const person = PEOPLE.find(p => p.id === id);
|
|
208
|
+
const app = Fastify();
|
|
209
|
+
const authenticate = async (req) => { req.user = {id: person.id, name: person.name, email: person.email, role: person.role}; };
|
|
210
|
+
// No isRestricted: the CMS's role data decides - and no role there holds docs-restricted.
|
|
211
|
+
await app.register(docsPlugin, {prefix: '/api/plugins/docs', settings: {scope: 'all'},
|
|
212
|
+
auth: {authenticate, requireAdmin: async () => {}, requirePermission: () => async () => {}}, listUsers: async () => PEOPLE, mailer});
|
|
213
|
+
await app.ready();
|
|
214
|
+
return app;
|
|
215
|
+
};
|
|
216
|
+
const alice = await build('r-alice');
|
|
217
|
+
const ada = await build('r-ada');
|
|
218
|
+
const set = (await call(alice, 'GET', '/settings')).body;
|
|
219
|
+
assert.equal(set.restrictedUser, undefined);
|
|
220
|
+
assert.equal(set.publicLinks, true);
|
|
221
|
+
assert.equal(set.allowSend, true);
|
|
222
|
+
assert.equal(set.scope, 'all');
|
|
223
|
+
assert.equal((await call(ada, 'GET', '/settings')).body.canEdit, true);
|
|
224
|
+
const doc = (await call(alice, 'POST', '/documents', {title: 'Plain', content: '<p>plain</p>'})).body;
|
|
225
|
+
const people = (await call(alice, 'GET', '/people')).body;
|
|
226
|
+
assert.ok(people.length >= 3, 'the share list as before');
|
|
227
|
+
assert.equal((await call(alice, 'PUT', `/documents/${doc.id}/shares`, {shares: [{userId: 'r-ada', role: 'viewer'}]})).status, 200);
|
|
228
|
+
const link = await call(alice, 'POST', `/documents/${doc.id}/link`);
|
|
229
|
+
assert.equal(link.status, 200);
|
|
230
|
+
assert.ok(link.body.publicLink.token);
|
|
231
|
+
assert.equal((await call(alice, 'POST', `/documents/${doc.id}/send`, {to: 'x@y.test'})).status, 200);
|
|
232
|
+
assert.equal(outbox.length, 1);
|
|
233
|
+
const seen = (await call(alice, 'GET', `/documents/${doc.id}`)).body;
|
|
234
|
+
assert.equal(seen.restrictedUser, undefined);
|
|
235
|
+
// Site-wide: the admin is an owner of it, as before.
|
|
236
|
+
assert.equal((await call(ada, 'GET', `/documents/${doc.id}`)).body.access, 'owner');
|
|
237
|
+
assert.equal(docsRegistry().services.restrictedUser({id: 'r-alice', role: 'user'}), false);
|
|
238
|
+
await alice.close();
|
|
239
|
+
await ada.close();
|
|
240
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"note": "Written by `make sync-free-tier` in dcms-marketplace. Do not edit these plugins here - edit them there and sync.",
|
|
3
|
-
"source": "dcms-marketplace@
|
|
3
|
+
"source": "dcms-marketplace@efe58a2",
|
|
4
4
|
"plugins": {
|
|
5
5
|
"blog": {
|
|
6
6
|
"version": "1.10.3",
|
|
@@ -81,9 +81,10 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"docs": {
|
|
84
|
-
"version": "2.
|
|
84
|
+
"version": "2.15.0",
|
|
85
85
|
"files": {
|
|
86
|
-
"
|
|
86
|
+
"CHANGELOG.md": "2bf73d5627e5a1d4ab692f15c2fa128d55d7707062a7f9597d0c9737fc42accb",
|
|
87
|
+
"CLAUDE.md": "29e27e36bdf2acb65481f2e2a77bf28ced83fd403cf9352355a752faa8b41f67",
|
|
87
88
|
"admin/css/docs.css": "89304c596f2d36492198885359fa86998f9f36be522238983e32e5d01319c759",
|
|
88
89
|
"admin/lib/api.js": "0ddd567995a79e2379b92049de3b09a8bdf1c0d798042c7fbe3937f14e3631bf",
|
|
89
90
|
"admin/lib/convert.js": "37e8310aa0c225fad9c063649e31351c05fe4371081ede9fe4466aac64123b0e",
|
|
@@ -101,17 +102,17 @@
|
|
|
101
102
|
"admin/lib/versions.js": "a2335d8cd22fb3c0f31431cc9a95251d18d83cb9fba6afef7300e9121fcb4c18",
|
|
102
103
|
"admin/templates/docs.html": "4a621859200e6c2731db8f0924e6b76b03660dc01ae637d19de5ca2bbe92a33d",
|
|
103
104
|
"admin/templates/editor.html": "cd937141373deeb8f3d204e47d11fe297a9b863499a95e19d62dbe1b2b05213a",
|
|
104
|
-
"admin/views/docs.js": "
|
|
105
|
-
"admin/views/editor.js": "
|
|
105
|
+
"admin/views/docs.js": "c573af0558ee01865896dbf0c2825bc02573cf10a5b984025c942f2b87d4b0af",
|
|
106
|
+
"admin/views/editor.js": "50813e89967e5c5c79f94af0eebcf1b620d889ad5a7395040aa54e4014f24e75",
|
|
106
107
|
"config.js": "4435664c2d96088ad21d68241a2a6998b12c80592270deba77710b8c014de0a3",
|
|
107
|
-
"docs/guide.md": "
|
|
108
|
+
"docs/guide.md": "08c7c14fbabc6ded32fde19498eded2d01fa258f6d673517451c360c5549f40d",
|
|
108
109
|
"lib/extensions.js": "a449f10e309bcb16bb7d426315e85b2efe9be6d3420313c0e30315f146820d99",
|
|
109
110
|
"lib/importer.js": "2bbe9c9d37d6c627fa9ad445171c01b349a14582a882fe8cf9a33c42045e03dc",
|
|
110
111
|
"lib/pdf-worker.js": "c256c32520a37a6579a528f16d5965951cfb65d7984a246168c1b33fd36d72eb",
|
|
111
112
|
"lib/pdf.js": "83abc3aba0c322c50b528b8a037466a294303f55d7c30f3cd1445f811b78ae28",
|
|
112
|
-
"lib/store.js": "
|
|
113
|
-
"plugin.js": "
|
|
114
|
-
"plugin.json": "
|
|
113
|
+
"lib/store.js": "128c372b9b2daa1370205e5261c76e90d3966717d371aeb33b9a5cccb16fa04f",
|
|
114
|
+
"plugin.js": "487191d13142bd70d12e2f9a339ba83c75bb3f1b8ad87eb6cb2688c47b4932dc",
|
|
115
|
+
"plugin.json": "c97fc5e37494aa0ca4e4a0a89b204bb01cbdcd5c4fe36e0e68d185e56d9ba713",
|
|
115
116
|
"plugin.public.js": "a9cd7a9211f5b0006832054a15055a3c36afa9f9b284600cdc5fce19e892c178",
|
|
116
117
|
"templates/public-doc.html": "7360cbeec5cba8a2b1b1d074730972bb4b90cfe913a799a06522b2e1a0f566d8",
|
|
117
118
|
"tests/_env.js": "2daf6b0dd3211498298db79e5da80c17e2be98e380f777bc9c555c3eb99d128a",
|
|
@@ -120,6 +121,7 @@
|
|
|
120
121
|
"tests/drafts.test.js": "209c1691aa321e07c0ab24f747920b15d7bd56c2b3f5a581b116aad73c157d8f",
|
|
121
122
|
"tests/pdf.test.js": "316c7b32fb4562f42fd59da1df9c8a3bccacb8286db6540b36e10f85c510d68e",
|
|
122
123
|
"tests/plugin.test.js": "766ce9418c2285128f74264c62eda013bafda386dba832e261254de26a4d753c",
|
|
124
|
+
"tests/restricted.test.js": "96c933f4016e2378e9e652c06d51021cd9af4077dc60e48c7e6d65443c7b0cff",
|
|
123
125
|
"tests/shortcuts.test.js": "7f96b63e91150e7670eb349a81034ce354f64ea42503d6a8ffcdae4867d7bba1"
|
|
124
126
|
}
|
|
125
127
|
},
|
|
@@ -169,14 +171,14 @@
|
|
|
169
171
|
}
|
|
170
172
|
},
|
|
171
173
|
"mail-reader": {
|
|
172
|
-
"version": "1.2.
|
|
174
|
+
"version": "1.2.9",
|
|
173
175
|
"files": {
|
|
174
|
-
"CLAUDE.md": "
|
|
176
|
+
"CLAUDE.md": "d512f3ebd016bfb4f7a49a8cae9b5e709ce8ae636f2e5ff218fe61098e84b2ec",
|
|
175
177
|
"admin/views/mail.js": "c5c6483f9618c75cac8f4be32d3aea99511db76d4b9d38b8ef43bdc1d35db3c5",
|
|
176
178
|
"config.js": "6e65803ad822a9acda40c203631b8eb32a87cf9d9e5f1c7cb59d01aa406075c6",
|
|
177
179
|
"docs/guide.md": "75e5742c16b2230fb4943ae3214d946436de556eda719e22cde50d8a13a9a88f",
|
|
178
|
-
"plugin.js": "
|
|
179
|
-
"plugin.json": "
|
|
180
|
+
"plugin.js": "7201b206f6429f88288610079b0bd607ff6d08f803e7434bcf0bc2d49f032f9a",
|
|
181
|
+
"plugin.json": "3cb8ac490200c4f8c14da8dae27c02fbc2aab18e3bc6dabe1130a64102f97812"
|
|
180
182
|
}
|
|
181
183
|
},
|
|
182
184
|
"messages": {
|
|
@@ -125,3 +125,9 @@ unless it is the site's own outgoing server or `allowPrivateMailHosts` is set; `
|
|
|
125
125
|
|
|
126
126
|
- 2026-10-13 (1.2.8): this file brought up to date - credentials, the key and the tested modules live in the
|
|
127
127
|
shared `plugins/_lib/mail` core and `plugins/_lib/data/`, not in this plugin's `services/` and `data/`. No code change.
|
|
128
|
+
|
|
129
|
+
## The page cache (unreleased)
|
|
130
|
+
|
|
131
|
+
`plugin.js` marks every route `config: {keepsCache: true}` through an `onRoute` hook (core 1.61.1; ignored by an older
|
|
132
|
+
core): a mailbox setting never appears on a page, so saving one must not empty the site's response cache. Tested with
|
|
133
|
+
Email Pro's, in `plugins/email-pro/tests/keeps-cache.test.js`.
|
|
@@ -18,6 +18,15 @@ import {registerReadRoutes} from '../_lib/mail/readRoutes.js';
|
|
|
18
18
|
import defaultConfig from './config.js';
|
|
19
19
|
|
|
20
20
|
export default async function mailReaderPlugin(fastify, options) {
|
|
21
|
+
// Mail is personal: nothing a mailbox route writes (flags, moves, deletes,
|
|
22
|
+
// folders, drafts, sync, settings) appears on a page of the site. So every
|
|
23
|
+
// route here keeps the page cache (`config: {keepsCache: true}`, core 1.61.1;
|
|
24
|
+
// an older core ignores it) - otherwise reading mail in the admin emptied
|
|
25
|
+
// the whole cache on each click.
|
|
26
|
+
fastify.addHook('onRoute', (route) => {
|
|
27
|
+
if (route.config?.keepsCache === undefined) route.config = {...route.config, keepsCache: true};
|
|
28
|
+
});
|
|
29
|
+
|
|
21
30
|
const config = {...defaultConfig, ...(options.settings || {})};
|
|
22
31
|
const pool = createPool(config);
|
|
23
32
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mail-reader",
|
|
3
3
|
"displayName": "Mail Reader",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.9",
|
|
5
5
|
"tier": "free",
|
|
6
6
|
"description": "Read-only IMAP mailbox reader. Connects to a standard IMAP server and reads mail without ever writing to it.",
|
|
7
7
|
"author": "Darryl Waterhouse",
|