My agentic slop goes here. Not intended for anyone else!
1(** JMAP Identity Type
2
3 An Identity represents an email address and associated metadata that
4 the user may send from. Users may have multiple identities for different
5 purposes (work, personal, aliases, etc.).
6
7open Jmap_core
8
9 Reference: RFC 8621 Section 6 (Identity)
10 Test files:
11 - test/data/mail/identity_get_request.json
12 - test/data/mail/identity_get_response.json
13*)
14
15(** Identity object type (RFC 8621 Section 6.1) *)
16type t = {
17 id : Jmap_core.Id.t; (** Immutable server-assigned id *)
18 name : string; (** Display name for this identity (e.g., "Alice Jones") *)
19 email : string; (** Email address (e.g., "alice@example.com") *)
20 reply_to : Jmap_email.EmailAddress.t list option; (** Reply-To addresses to use *)
21 bcc : Jmap_email.EmailAddress.t list option; (** BCC addresses to automatically add *)
22 text_signature : string; (** Signature to insert for text/plain messages *)
23 html_signature : string; (** Signature to insert for text/html messages *)
24 may_delete : bool; (** Can user delete this identity? *)
25}
26
27(** Accessors *)
28let id t = t.id
29let name t = t.name
30let email t = t.email
31let reply_to t = t.reply_to
32let bcc t = t.bcc
33let text_signature t = t.text_signature
34let html_signature t = t.html_signature
35let may_delete t = t.may_delete
36
37(** Constructor *)
38let v ~id ~name ~email ?reply_to ?bcc ~text_signature ~html_signature ~may_delete () =
39 { id; name; email; reply_to; bcc; text_signature; html_signature; may_delete }
40
41(** Standard /get method (RFC 8621 Section 6.2)
42
43 Identities are mostly read-only. They support /get and /changes,
44 but /set is typically limited to updating signatures. The server
45 controls which identities exist based on account configuration.
46*)
47module Get = struct
48 type request = t Jmap_core.Standard_methods.Get.request
49 type response = t Jmap_core.Standard_methods.Get.response
50
51 (** Parse get request from JSON.
52 Test files: test/data/mail/identity_get_request.json
53
54 Expected structure:
55 {
56 "accountId": "u123456",
57 "ids": null
58 }
59 *)
60 let request_of_json _json =
61 raise (Jmap_core.Error.Parse_error "Identity.Get.request_of_json not yet implemented")
62
63 (** Parse get response from JSON.
64 Test files: test/data/mail/identity_get_response.json
65
66 Expected structure:
67 {
68 "accountId": "u123456",
69 "state": "i42:100",
70 "list": [
71 {
72 "id": "id001",
73 "name": "Alice Jones",
74 "email": "alice@example.com",
75 "replyTo": null,
76 "bcc": null,
77 "textSignature": "Best regards,\nAlice Jones",
78 "htmlSignature": "<p>Best regards,<br>Alice Jones</p>",
79 "mayDelete": false
80 }
81 ],
82 "notFound": []
83 }
84 *)
85 let response_of_json _json =
86 raise (Jmap_core.Error.Parse_error "Identity.Get.response_of_json not yet implemented")
87end
88
89(** Standard /changes method (RFC 8621 Section 6.3) *)
90module Changes = struct
91 type request = Jmap_core.Standard_methods.Changes.request
92 type response = Jmap_core.Standard_methods.Changes.response
93
94 let request_of_json _json =
95 raise (Jmap_core.Error.Parse_error "Identity.Changes.request_of_json not yet implemented")
96
97 let response_of_json _json =
98 raise (Jmap_core.Error.Parse_error "Identity.Changes.response_of_json not yet implemented")
99end
100
101(** Standard /set method (RFC 8621 Section 6.4)
102
103 Most servers only allow updating textSignature and htmlSignature fields.
104 Creating and destroying identities is typically not allowed, as identities
105 are derived from server/account configuration.
106*)
107module Set = struct
108 type request = t Jmap_core.Standard_methods.Set.request
109 type response = t Jmap_core.Standard_methods.Set.response
110
111 let request_of_json _json =
112 raise (Jmap_core.Error.Parse_error "Identity.Set.request_of_json not yet implemented")
113
114 let response_of_json _json =
115 raise (Jmap_core.Error.Parse_error "Identity.Set.response_of_json not yet implemented")
116end
117
118(** Parser submodule *)
119module Parser = struct
120 (** Parse Identity from JSON.
121 Test files: test/data/mail/identity_get_response.json (list field)
122
123 Expected structure:
124 {
125 "id": "id001",
126 "name": "Alice Jones",
127 "email": "alice@example.com",
128 "replyTo": null,
129 "bcc": null,
130 "textSignature": "Best regards,\nAlice Jones\nSoftware Engineer\nexample.com",
131 "htmlSignature": "<div><p>Best regards,</p><p><strong>Alice Jones</strong><br>Software Engineer<br>example.com</p></div>",
132 "mayDelete": false
133 }
134 *)
135 let of_json _json =
136 (* TODO: Implement JSON parsing *)
137 raise (Jmap_core.Error.Parse_error "Identity.Parser.of_json not yet implemented")
138
139 let to_json _t =
140 (* TODO: Implement JSON serialization *)
141 raise (Jmap_core.Error.Parse_error "Identity.Parser.to_json not yet implemented")
142end