My agentic slop goes here. Not intended for anyone else!
1(** JMAP Thread Type
2
3 A Thread represents a conversation or message thread. It is simply a
4 list of Email ids that are related to each other.
5
6open Jmap_core
7
8 Threads are purely server-managed objects - they are calculated by the
9 server based on message headers (In-Reply-To, References, Subject, etc.)
10 and cannot be created, updated, or destroyed by the client.
11
12 Reference: RFC 8621 Section 3 (Threads)
13 Test files:
14 - test/data/mail/thread_get_request.json
15 - test/data/mail/thread_get_response.json
16*)
17
18(** Thread object type *)
19type t = {
20 id : Jmap_core.Id.t; (** Immutable server-assigned thread id *)
21 email_ids : Jmap_core.Id.t list; (** List of email ids in this thread, sorted by date (oldest first) *)
22}
23
24(** Accessors *)
25let id t = t.id
26let email_ids t = t.email_ids
27
28(** Constructor *)
29let v ~id ~email_ids = { id; email_ids }
30
31(** Standard /get method (RFC 8621 Section 3.2)
32
33 Threads only support the /get method. They do not support:
34 - /changes (threads change too frequently)
35 - /set (threads are server-managed, not client-modifiable)
36 - /query (use Email/query with collapseThreads instead)
37 - /queryChanges
38*)
39module Get = struct
40 type request = t Jmap_core.Standard_methods.Get.request
41 type response = t Jmap_core.Standard_methods.Get.response
42
43 (** Parse get request from JSON.
44 Test files: test/data/mail/thread_get_request.json
45
46 Expected structure:
47 {
48 "accountId": "u123456",
49 "ids": ["t001", "t002", "t003"]
50 }
51 *)
52 let request_of_json _json =
53 raise (Jmap_core.Error.Parse_error "Thread.Get.request_of_json not yet implemented")
54
55 (** Parse get response from JSON.
56 Test files: test/data/mail/thread_get_response.json
57
58 Expected structure:
59 {
60 "accountId": "u123456",
61 "state": "t42:100",
62 "list": [
63 {
64 "id": "t001",
65 "emailIds": ["e001", "e005", "e008"]
66 }
67 ],
68 "notFound": ["t003"]
69 }
70 *)
71 let response_of_json _json =
72 raise (Jmap_core.Error.Parse_error "Thread.Get.response_of_json not yet implemented")
73end
74
75(** Parser submodule *)
76module Parser = struct
77 (** Parse Thread from JSON.
78 Test files: test/data/mail/thread_get_response.json (list field)
79
80 Expected structure:
81 {
82 "id": "t001",
83 "emailIds": ["e001", "e005", "e008"]
84 }
85 *)
86 let of_json _json =
87 (* TODO: Implement JSON parsing *)
88 raise (Jmap_core.Error.Parse_error "Thread.Parser.of_json not yet implemented")
89
90 let to_json _t =
91 (* TODO: Implement JSON serialization *)
92 raise (Jmap_core.Error.Parse_error "Thread.Parser.to_json not yet implemented")
93end