Share files and folders with other people
Calendars and address books have been shareable since JMAP Sharing went
in; Files never was, though Stalwart treats file storage as a first-class
thing to share and ihasmail has carried the types for it all along.
`FilesRights` and `FileNode.shareWith` were already declared -- what was
missing was asking for the property, offering the dialog, and saying so
in the list.
Checked against the live 0.16.19 first, read-only, because building a
picker against a mock that agrees with you proves nothing:
- `FileNode/get` returns `shareWith`, and `myRights` carries all six
rights, `mayShare` among them and true on one's own nodes. So the
menu entry has a real right to gate on -- unlike folder sharing,
which is offered ungated because `MailboxRights` has no such right
- `Principal/query` answers now that `allowDirectoryQueries` is on:
six individuals, no groups
- `ShareNotification/get` is implemented, which is worth knowing for
later; nothing here reads it yet
The editor preset grants read, add files and edit contents, and stops
there. Rename and delete stay with whoever shared the folder: someone
given a folder to work in should not be able to rename the thing they
were given, or delete it out from under the person who shared it. Both
are still there to tick by hand.
One finding is worth a test of its own, and has one. Stalwart answers
`shareWith` as `{}` for a node shared with nobody, not `null` -- every
unshared node in a live account came back that way. A truthiness test on
the property is therefore true for every node the server has ever
returned, and the badge driven by it would report the whole account as
shared while being, technically, about the right property. `isShared`
counts keys, and the test says why.
Verified against the mock end to end: sharing Documents with a principal
as Editor persists `mayRead`, `mayAddChildren` and `mayModifyContent` and
nothing else, the badge appears on that folder and not on the file beside
it, and re-opening the dialog shows the saved rights rather than an empty
form -- which is what proves `fileNodeProps` is really asking for the
property.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isShared } from "@/lib/filenode";
|
||||
|
||||
/**
|
||||
* The one thing about file sharing that a mock would never have told us.
|
||||
*
|
||||
* Stalwart 0.16.19 answers `shareWith` as `{}` for a node shared with nobody,
|
||||
* not `null` — every unshared node in a live account came back that way on
|
||||
* 2026-08-27. A truthiness test on the property is therefore true for every
|
||||
* node the server has ever returned, and a badge driven by one would report
|
||||
* the entire account as shared while being, technically, about the right
|
||||
* property.
|
||||
*/
|
||||
|
||||
describe("whether a node is shared", () => {
|
||||
it("treats the empty object Stalwart sends as not shared", () => {
|
||||
expect(isShared({ shareWith: {} })).toBe(false);
|
||||
});
|
||||
|
||||
it("treats a missing or null shareWith as not shared", () => {
|
||||
expect(isShared({ shareWith: null })).toBe(false);
|
||||
expect(isShared({})).toBe(false);
|
||||
});
|
||||
|
||||
it("is shared once a principal is on it", () => {
|
||||
expect(isShared({ shareWith: { p1: { mayRead: true } } as never })).toBe(true);
|
||||
});
|
||||
|
||||
it("stays shared when the rights granted are all false", () => {
|
||||
// An entry with nothing enabled is still an entry: the principal is on the
|
||||
// list, and the owner should see that rather than an empty-looking folder.
|
||||
expect(isShared({ shareWith: { p1: { mayRead: false } } as never })).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user