Skip to content

Commit 3c941dc

Browse files
committed
✨(jmap) add JMAP endpoint
This is the first step in our standards-compliant JMAP support. It implements just enough to be able to list recent threads.
1 parent bef485a commit 3c941dc

12 files changed

Lines changed: 1960 additions & 3 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""JMAP API module for the messages application."""
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
"""JMAP error types as per RFC 8620."""
2+
3+
4+
class JMAPError(Exception):
5+
"""Base JMAP error."""
6+
7+
error_type: str = "serverFail"
8+
9+
def __init__(self, description: str = ""):
10+
self.description = description
11+
super().__init__(description)
12+
13+
def to_response(self, call_id: str) -> list:
14+
"""Convert to JMAP error response tuple."""
15+
return [
16+
"error",
17+
{"type": self.error_type, "description": self.description},
18+
call_id,
19+
]
20+
21+
22+
class UnknownCapabilityError(JMAPError):
23+
"""The request used a capability not advertised in the session."""
24+
25+
error_type = "unknownCapability"
26+
27+
28+
class UnknownMethodError(JMAPError):
29+
"""The method name is not recognized."""
30+
31+
error_type = "unknownMethod"
32+
33+
34+
class InvalidArgumentsError(JMAPError):
35+
"""One or more arguments are of the wrong type or invalid."""
36+
37+
error_type = "invalidArguments"
38+
39+
40+
class InvalidResultReferenceError(JMAPError):
41+
"""A result reference could not be resolved."""
42+
43+
error_type = "invalidResultReference"
44+
45+
46+
class AccountNotFoundError(JMAPError):
47+
"""The accountId does not correspond to a valid account."""
48+
49+
error_type = "accountNotFound"
50+
51+
52+
class ForbiddenError(JMAPError):
53+
"""The action is forbidden for the authenticated user."""
54+
55+
error_type = "forbidden"
56+
57+
58+
class ServerFailError(JMAPError):
59+
"""An unexpected server error occurred."""
60+
61+
error_type = "serverFail"

0 commit comments

Comments
 (0)