fix: share files on Stalwart versions before 0.16.6

Stalwart before 0.16.6 implements an older JMAP File Storage draft
whose rights are only `mayRead`, `mayWrite` and `mayShare`. Bulwark
always sent the newer `mayAddChildren` / `mayRename` / `mayDelete` /
`mayModifyContent`, so sharing a file or folder failed there with
`Invalid permission "mayAddChildren"`, and the rights such a server
reported did not match what the UI checks.

When the account's filenode capability lacks `forbiddenNameChars`
(added by the same draft update), shares are now written with
`mayWrite` set from the finer rights, and `mayWrite` read from the
server is spread over them.
This commit is contained in:
Linus Rath
2026-09-22 20:49:44 +02:00
parent 1ecddf3cbb
commit c3225b3fa8
2 changed files with 72 additions and 4 deletions
@@ -89,6 +89,27 @@ describe('FileNode writes', () => {
expect(calls.some(([m]) => m === 'Blob/copy')).toBe(false);
});
it('shares with the mayWrite rights of servers before 0.16.6', async () => {
const { client, calls } = makeClient({});
await client.setFileNodeShare('n1', 'p1', {
mayRead: true, mayAddChildren: true, mayRename: false, mayDelete: false, mayModifyContent: false, mayShare: false,
}).catch(() => {});
expect(sets(calls)[0]).toMatchObject({
accountId: 'me',
update: { n1: { 'shareWith/p1': { mayRead: true, mayWrite: true, mayShare: false } } },
});
});
it('reads old mayWrite rights as the finer rights', async () => {
const { client } = makeClient({
me: [{ id: 'd1', name: 'Docs', parentId: null, blobId: null, myRights: { mayRead: true, mayWrite: true, mayShare: false } }],
});
const [node] = await client.listAllFileNodes();
expect(node.myRights).toEqual({
mayRead: true, mayAddChildren: true, mayRename: true, mayDelete: true, mayModifyContent: true, mayShare: false,
});
});
it('copies file content across accounts with Blob/copy', async () => {
const { client, calls } = makeClient({
grp: [{ id: 'f1', name: 'shared.pdf', parentId: null, blobId: 'b1', type: 'application/pdf', size: 9 }],