+1
-1
bin/fastmail_list.ml
+1
-1
bin/fastmail_list.ml
···
138
138
| Ok conn ->
139
139
(* Get the primary account ID *)
140
140
let primary_account_id =
141
-
let mail_capability = Jmap_mail.Capability.to_string (Jmap_mail.Capability.Mail Mail) in
141
+
let mail_capability = Jmap_mail.Capability.to_string Jmap_mail.Capability.Mail in
142
142
match List.assoc_opt mail_capability conn.session.primary_accounts with
143
143
| Some id -> id
144
144
| None ->
+23
-66
lib/jmap_mail.ml
+23
-66
lib/jmap_mail.ml
···
2
2
3
3
(** Module for managing JMAP Mail-specific capability URIs *)
4
4
module Capability = struct
5
-
(** Mail capability types *)
6
-
type mail = Mail
7
-
8
5
(** Mail capability URI *)
9
6
let mail_uri = "urn:ietf:params:jmap:mail"
10
7
11
-
(** Convert mail capability to URI string *)
12
-
let string_of_mail = function
13
-
| Mail -> mail_uri
14
-
15
-
(** Parse a string to mail capability *)
16
-
let mail_of_string = function
17
-
| s when s = mail_uri -> Some Mail
18
-
| _ -> None
19
-
20
-
(** Submission capability types *)
21
-
type submission = Submission
22
-
23
8
(** Submission capability URI *)
24
9
let submission_uri = "urn:ietf:params:jmap:submission"
25
10
26
-
(** Convert submission capability to URI string *)
27
-
let string_of_submission = function
28
-
| Submission -> submission_uri
29
-
30
-
(** Parse a string to submission capability *)
31
-
let submission_of_string = function
32
-
| s when s = submission_uri -> Some Submission
33
-
| _ -> None
34
-
35
-
(** Vacation response capability types *)
36
-
type vacation_response = VacationResponse
37
-
38
11
(** Vacation response capability URI *)
39
12
let vacation_response_uri = "urn:ietf:params:jmap:vacationresponse"
40
13
41
-
(** Convert vacation response capability to URI string *)
42
-
let string_of_vacation_response = function
43
-
| VacationResponse -> vacation_response_uri
44
-
45
-
(** Parse a string to vacation response capability *)
46
-
let vacation_response_of_string = function
47
-
| s when s = vacation_response_uri -> Some VacationResponse
48
-
| _ -> None
49
-
50
14
(** All mail extension capability types *)
51
15
type t =
52
-
| Mail of mail
53
-
| Submission of submission
54
-
| VacationResponse of vacation_response
55
-
| Extension of string
16
+
| Mail (** Mail capability *)
17
+
| Submission (** Submission capability *)
18
+
| VacationResponse (** Vacation response capability *)
19
+
| Extension of string (** Custom extension *)
56
20
57
21
(** Convert capability to URI string *)
58
22
let to_string = function
59
-
| Mail m -> string_of_mail m
60
-
| Submission s -> string_of_submission s
61
-
| VacationResponse v -> string_of_vacation_response v
23
+
| Mail -> mail_uri
24
+
| Submission -> submission_uri
25
+
| VacationResponse -> vacation_response_uri
62
26
| Extension s -> s
63
27
64
28
(** Parse a string to a capability *)
65
29
let of_string s =
66
-
match mail_of_string s with
67
-
| Some m -> Mail m
68
-
| None ->
69
-
match submission_of_string s with
70
-
| Some s -> Submission s
71
-
| None ->
72
-
match vacation_response_of_string s with
73
-
| Some v -> VacationResponse v
74
-
| None -> Extension s
30
+
if s = mail_uri then Mail
31
+
else if s = submission_uri then Submission
32
+
else if s = vacation_response_uri then VacationResponse
33
+
else Extension s
75
34
76
35
(** Check if a capability is a standard mail capability *)
77
36
let is_standard = function
78
-
| Mail _ | Submission _ | VacationResponse _ -> true
37
+
| Mail | Submission | VacationResponse -> true
79
38
| Extension _ -> false
80
39
81
40
(** Check if a capability string is a standard mail capability *)
82
41
let is_standard_string s =
83
-
match of_string s with
84
-
| Extension _ -> false
85
-
| _ -> true
42
+
s = mail_uri || s = submission_uri || s = vacation_response_uri
86
43
87
44
(** Create a list of capability strings *)
88
45
let strings_of_capabilities capabilities =
···
1297
1254
let get_mailboxes conn ~account_id =
1298
1255
let request = {
1299
1256
using = [
1300
-
Jmap.Capability.to_string (Jmap.Capability.Core Core);
1301
-
Capability.to_string (Capability.Mail Mail)
1257
+
Jmap.Capability.to_string Jmap.Capability.Core;
1258
+
Capability.to_string Capability.Mail
1302
1259
];
1303
1260
method_calls = [
1304
1261
{
···
1346
1303
let get_mailbox conn ~account_id ~mailbox_id =
1347
1304
let request = {
1348
1305
using = [
1349
-
Jmap.Capability.to_string (Jmap.Capability.Core Core);
1350
-
Capability.to_string (Capability.Mail Mail)
1306
+
Jmap.Capability.to_string Jmap.Capability.Core;
1307
+
Capability.to_string Capability.Mail
1351
1308
];
1352
1309
method_calls = [
1353
1310
{
···
1393
1350
(* First query the emails in the mailbox *)
1394
1351
let query_request = {
1395
1352
using = [
1396
-
Jmap.Capability.to_string (Jmap.Capability.Core Core);
1397
-
Capability.to_string (Capability.Mail Mail)
1353
+
Jmap.Capability.to_string Jmap.Capability.Core;
1354
+
Capability.to_string Capability.Mail
1398
1355
];
1399
1356
method_calls = [
1400
1357
{
···
1431
1388
if List.length email_ids > 0 then
1432
1389
let get_request = {
1433
1390
using = [
1434
-
Jmap.Capability.to_string (Jmap.Capability.Core Core);
1435
-
Capability.to_string (Capability.Mail Mail)
1391
+
Jmap.Capability.to_string Jmap.Capability.Core;
1392
+
Capability.to_string Capability.Mail
1436
1393
];
1437
1394
method_calls = [
1438
1395
{
···
1488
1445
let get_email conn ~account_id ~email_id =
1489
1446
let request = {
1490
1447
using = [
1491
-
Jmap.Capability.to_string (Jmap.Capability.Core Core);
1492
-
Capability.to_string (Capability.Mail Mail)
1448
+
Jmap.Capability.to_string Jmap.Capability.Core;
1449
+
Capability.to_string Capability.Mail
1493
1450
];
1494
1451
method_calls = [
1495
1452
{
+4
-31
lib/jmap_mail.mli
+4
-31
lib/jmap_mail.mli
···
2
2
3
3
(** Module for managing JMAP Mail-specific capability URIs *)
4
4
module Capability : sig
5
-
(** Mail capability types *)
6
-
type mail = Mail
7
-
8
5
(** Mail capability URI *)
9
6
val mail_uri : string
10
7
11
-
(** Convert mail capability to URI string *)
12
-
val string_of_mail : mail -> string
13
-
14
-
(** Parse a string to mail capability *)
15
-
val mail_of_string : string -> mail option
16
-
17
-
(** Submission capability types *)
18
-
type submission = Submission
19
-
20
8
(** Submission capability URI *)
21
9
val submission_uri : string
22
10
23
-
(** Convert submission capability to URI string *)
24
-
val string_of_submission : submission -> string
25
-
26
-
(** Parse a string to submission capability *)
27
-
val submission_of_string : string -> submission option
28
-
29
-
(** Vacation response capability types *)
30
-
type vacation_response = VacationResponse
31
-
32
11
(** Vacation response capability URI *)
33
12
val vacation_response_uri : string
34
-
35
-
(** Convert vacation response capability to URI string *)
36
-
val string_of_vacation_response : vacation_response -> string
37
-
38
-
(** Parse a string to vacation response capability *)
39
-
val vacation_response_of_string : string -> vacation_response option
40
13
41
14
(** All mail extension capability types *)
42
15
type t =
43
-
| Mail of mail
44
-
| Submission of submission
45
-
| VacationResponse of vacation_response
46
-
| Extension of string
16
+
| Mail (** Mail capability *)
17
+
| Submission (** Submission capability *)
18
+
| VacationResponse (** Vacation response capability *)
19
+
| Extension of string (** Custom extension *)
47
20
48
21
(** Convert capability to URI string *)
49
22
val to_string : t -> string