mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 00:07:01 +00:00
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:
@@ -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)}`;
|
||||
}
|
||||
Reference in New Issue
Block a user