Matrix protocol in OCaml, Eio specialised
at main 120 lines 3.4 kB view raw
1(** Event relations: reactions, edits, threads, and replies. *) 2 3(** {1 Relation Types} *) 4 5(** Types of event relations. *) 6type relation_type = 7 | Annotation (** m.annotation - used for reactions *) 8 | Reference (** m.reference - generic reference *) 9 | Replace (** m.replace - used for edits *) 10 | Thread (** m.thread - used for threads *) 11 12val relation_type_to_string : relation_type -> string 13val relation_type_of_string : string -> (relation_type, string) result 14 15(** {1 Reactions} *) 16 17(** A reaction to an event. *) 18type reaction = { 19 event_id : Matrix_proto.Id.Event_id.t; 20 key : string; (** Emoji or shortcode *) 21} 22 23(** Send a reaction to an event. 24 25 @param room_id The room containing the event. 26 @param event_id The event to react to. 27 @param key The reaction key (typically an emoji). *) 28val send_reaction : 29 Client.t -> 30 room_id:Matrix_proto.Id.Room_id.t -> 31 event_id:Matrix_proto.Id.Event_id.t -> 32 key:string -> 33 (Matrix_proto.Id.Event_id.t, Error.t) result 34 35(** {1 Edits} *) 36 37(** Edit a text message. 38 39 @param room_id The room containing the message. 40 @param event_id The message event to edit. 41 @param new_body The new message body. *) 42val edit_message : 43 Client.t -> 44 room_id:Matrix_proto.Id.Room_id.t -> 45 event_id:Matrix_proto.Id.Event_id.t -> 46 new_body:string -> 47 (Matrix_proto.Id.Event_id.t, Error.t) result 48 49(** {1 Replies} *) 50 51(** Send a reply to a message. 52 53 @param room_id The room containing the message. 54 @param event_id The message event to reply to. 55 @param body The reply text. *) 56val send_reply : 57 Client.t -> 58 room_id:Matrix_proto.Id.Room_id.t -> 59 event_id:Matrix_proto.Id.Event_id.t -> 60 body:string -> 61 (Matrix_proto.Id.Event_id.t, Error.t) result 62 63(** {1 Threads} *) 64 65(** Send a message in a thread. 66 67 @param room_id The room containing the thread. 68 @param thread_root_id The event ID of the thread root. 69 @param reply_to_id Optional event to reply to within the thread. 70 @param body The message text. *) 71val send_in_thread : 72 Client.t -> 73 room_id:Matrix_proto.Id.Room_id.t -> 74 thread_root_id:Matrix_proto.Id.Event_id.t -> 75 ?reply_to_id:Matrix_proto.Id.Event_id.t -> 76 body:string -> 77 unit -> 78 (Matrix_proto.Id.Event_id.t, Error.t) result 79 80(** {1 Querying Relations} *) 81 82(** An aggregated event in a relations response. *) 83type aggregation = { 84 event_id : Matrix_proto.Id.Event_id.t; 85 origin_server_ts : int64; 86 sender : Matrix_proto.Id.User_id.t; 87} 88 89(** Relations response. *) 90type relations_response = { 91 chunk : aggregation list; 92 next_batch : string option; 93 prev_batch : string option; 94} 95 96(** Get relations for an event. 97 98 @param room_id The room containing the event. 99 @param event_id The event to get relations for. 100 @param rel_type Filter by relation type. 101 @param event_type Filter by event type. 102 @param limit Maximum number of results. 103 @param from Pagination token. *) 104val get_relations : 105 Client.t -> 106 room_id:Matrix_proto.Id.Room_id.t -> 107 event_id:Matrix_proto.Id.Event_id.t -> 108 ?rel_type:relation_type -> 109 ?event_type:string -> 110 ?limit:int -> 111 ?from:string -> 112 unit -> 113 (relations_response, Error.t) result 114 115(** Get all reactions for an event. *) 116val get_reactions : 117 Client.t -> 118 room_id:Matrix_proto.Id.Room_id.t -> 119 event_id:Matrix_proto.Id.Event_id.t -> 120 (relations_response, Error.t) result