fix: check JMAP method errors in every mail call, split requests to server limits and file sent mail through Drafts (#188, #234, #850)

This commit is contained in:
Linus Rath
2026-08-29 17:49:23 +02:00
parent 506a4b1a84
commit ccbe67c1bc
8 changed files with 859 additions and 332 deletions
+35
View File
@@ -0,0 +1,35 @@
/**
* Naming one member of an object in a JMAP PatchObject. Port of the webmail's
* lib/jmap/patch-pointer.ts.
*
* A PatchObject key is a JSON Pointer (RFC 8620 section 5.3), so a slash in the
* member's own name starts a new path segment unless it is escaped. That bites
* keywords: a nested tag is stored as `$label:work/clients`, and the unescaped
* pointer `keywords/$label:work/clients` asks for the `clients` member of the
* `$label:work` keyword - not a boolean, so the patch is rejected or ignored
* and the tag never lands.
*/
/** One JSON Pointer reference token: `~` -> `~0`, `/` -> `~1` (RFC 6901). */
export function pointerToken(value: string): string {
return value.replace(/~/g, '~0').replace(/\//g, '~1');
}
/**
* The member name a reference token stands for: the inverse of
* `pointerToken`. `~1` is read before `~0`, per RFC 6901 - the other order
* would turn the escaped `~1` of `~01` back into a slash.
*/
export function pointerTokenValue(token: string): string {
return token.replace(/~1/g, '/').replace(/~0/g, '~');
}
/** The PatchObject key that sets or clears the keyword `keyword`. */
export function keywordPointer(keyword: string): string {
return `keywords/${pointerToken(keyword)}`;
}
/** The PatchObject key that adds or removes membership of `mailboxId`. */
export function mailboxPointer(mailboxId: string): string {
return `mailboxIds/${pointerToken(mailboxId)}`;
}