Show an assigned shared mailbox as shared, not as a locked account
ci / version (pull_request) Skipped
ci / github (pull_request) Skipped
ci / node (pull_request) Successful in 1m29s
ci / publish (pull_request) Skipped
ci / announce (pull_request) Skipped
ci / docker-build (pull_request) Successful in 36s
github/ci (branch) GitHub Actions
ci / version (pull_request) Skipped
ci / github (pull_request) Skipped
ci / node (pull_request) Successful in 1m29s
ci / publish (pull_request) Skipped
ci / announce (pull_request) Skipped
ci / docker-build (pull_request) Successful in 36s
github/ci (branch) GitHub Actions
The server now marks a shared mailbox (support@, legal@) as a delegation of kind "sharedMailbox" (multi-account spec, MA-S). Without this, the webmail would show one exactly as it shows a locked account: a red bar, a padlock in the tab and on the brand, and its calendars and files in place of the reader's own. Now such a mailbox is listed with the other shared mailboxes under "Mail to show", opens with the shared bar, which also gives the person's access level and whether they can send as it, and changes mail only. Its access level still applies exactly as a lock's does: read changes nothing, organize never deletes, no sending without send-as. Found without asking Mailbox/get, since the server's mark says it is mail. A server that sends no kind is treated as before: every delegation is a lock. No new strings. typecheck and vitest (174 files, 1534 tests) pass.
This commit is contained in:
1 parent
7f12a7d8ee
commit
c66a8aadd7
7 files changed
+51
-14
No files matched your search
@@ -70,7 +70,7 @@ afterEach(() => {
|
||||
describe("delegation", () => {
|
||||
it("is read only from the session's mark, never from a shared account's capabilities", () => {
|
||||
const session = sessionWith(delegated("organize", true));
|
||||
expect(delegationOf(session, "locked")).toEqual({ locked: true, access: "organize", sendAs: true, until: null });
|
||||
expect(delegationOf(session, "locked")).toEqual({ locked: true, kind: "lock", access: "organize", sendAs: true, until: null });
|
||||
expect(delegationOf(session, "shared")).toBeNull();
|
||||
expect(delegationOf(session, "own")).toBeNull();
|
||||
expect(delegatedAccounts(session).map((a) => a.id)).toEqual(["locked"]);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { CAP, client } from "@/jmap/client";
|
||||
import type { JmapSession } from "@/jmap/types";
|
||||
import { useSession } from "@/store/session";
|
||||
import { useSession, viewingDelegation } from "@/store/session";
|
||||
import { findSharedMail, sharedMailCandidates } from "@/lib/sharedMail";
|
||||
import { delegatedAccounts } from "@/lib/delegation";
|
||||
|
||||
/**
|
||||
* MA-A: a group's mailbox, or folders someone shared, can be opened in place
|
||||
@@ -36,6 +37,16 @@ const sessionWith = (extra: Record<string, unknown> = {}) =>
|
||||
isPersonal: false,
|
||||
accountCapabilities: { [CAP.mail]: {}, "urn:inbuxa:jmap": { delegation: { locked: true, access: "read", sendAs: false, until: null } } },
|
||||
},
|
||||
// A shared mailbox an administrator assigned (MA-S): marked, so never asked about
|
||||
desk: {
|
||||
name: "[email protected]",
|
||||
isPersonal: false,
|
||||
accountCapabilities: {
|
||||
[CAP.mail]: {},
|
||||
[CAP.calendars]: {},
|
||||
"urn:inbuxa:jmap": { delegation: { locked: true, kind: "sharedMailbox", access: "organize", sendAs: true, until: null } },
|
||||
},
|
||||
},
|
||||
...extra,
|
||||
},
|
||||
primaryAccounts: { [CAP.mail]: "own", [CAP.calendars]: "own", [CAP.contacts]: "own", [CAP.filenode]: "own" },
|
||||
@@ -76,11 +87,12 @@ afterEach(() => {
|
||||
|
||||
describe("shared mail", () => {
|
||||
it("considers only other people's accounts that advertise mail, leaving locked accounts to delegation", () => {
|
||||
expect(sharedMailCandidates(sessionWith()).map((a) => a.id)).toEqual(["calendarOnly", "group"]);
|
||||
expect(sharedMailCandidates(sessionWith()).map((a) => a.id)).toEqual(["calendarOnly", "desk", "group"]);
|
||||
});
|
||||
|
||||
it("offers only accounts that answer with a mailbox", async () => {
|
||||
expect((await findSharedMail(sessionWith())).map((a) => a.name)).toEqual(["[email protected]"]);
|
||||
// The shared mailbox answers no Mailbox/get here, and is offered anyway
|
||||
expect((await findSharedMail(sessionWith())).map((a) => a.name)).toEqual(["[email protected]", "[email protected]"]);
|
||||
});
|
||||
|
||||
it("can't be opened until it is found, and then shows mail only", async () => {
|
||||
@@ -111,4 +123,14 @@ describe("shared mail", () => {
|
||||
expect(useSession.getState().viewing).toBeNull();
|
||||
expect(useSession.getState().delegationEnded).toBe("[email protected]");
|
||||
});
|
||||
|
||||
it("shows an assigned shared mailbox as shared, not locked, keeping its access level", async () => {
|
||||
await useSession.getState().loadSharedMail();
|
||||
expect(delegatedAccounts(useSession.getState().session).map((a) => a.id)).toEqual(["locked"]);
|
||||
useSession.getState().view("desk");
|
||||
expect(useSession.getState().viewing).toBe("desk");
|
||||
expect(viewingDelegation()?.access).toBe("organize");
|
||||
// Mail only, like any shared mailbox
|
||||
expect(useSession.getState().viewAccountFor(CAP.calendars)).toBe("own");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user