Matrix protocol in OCaml, Eio specialised
at main 204 lines 4.2 kB view raw
1(** Push notification operations. 2 3 @see <https://spec.matrix.org/v1.11/client-server-api/#push-notifications> Push Notifications *) 4 5(** {1 Push Rule Types} *) 6 7(** Push rule kinds. *) 8type rule_kind = 9 | Override 10 | Underride 11 | Sender 12 | Room 13 | Content 14 15val rule_kind_to_string : rule_kind -> string 16(** Convert rule kind to string. *) 17 18val rule_kind_of_string : string -> (rule_kind, string) result 19(** Parse rule kind from string. *) 20 21val rule_kind_jsont : rule_kind Jsont.t 22(** JSON codec for rule kind. *) 23 24(** {1 Push Rule Actions} *) 25 26(** Push rule action. *) 27type action = 28 | Notify 29 | Dont_notify 30 | Coalesce 31 | Set_tweak of string * Jsont.json 32 33val action_jsont : action Jsont.t 34(** JSON codec for action. *) 35 36(** {1 Push Rule Conditions} *) 37 38(** Push rule condition. *) 39type condition = { 40 kind : string; 41 key : string option; 42 pattern : string option; 43 is_ : string option; 44} 45 46val condition_jsont : condition Jsont.t 47(** JSON codec for condition. *) 48 49(** {1 Push Rules} *) 50 51(** Push rule. *) 52type rule = { 53 rule_id : string; 54 default : bool; 55 enabled : bool; 56 actions : action list; 57 conditions : condition list option; 58 pattern : string option; 59} 60 61val rule_jsont : rule Jsont.t 62(** JSON codec for rule. *) 63 64(** {1 Push Ruleset} *) 65 66(** Push ruleset. *) 67type ruleset = { 68 override : rule list; 69 underride : rule list; 70 sender : rule list; 71 room : rule list; 72 content : rule list; 73} 74 75val ruleset_jsont : ruleset Jsont.t 76(** JSON codec for ruleset. *) 77 78(** Push rules response. *) 79type push_rules_response = { 80 global : ruleset; 81} 82 83val push_rules_response_jsont : push_rules_response Jsont.t 84(** JSON codec for push rules response. *) 85 86(** {1 Push Rule Operations} *) 87 88val get_push_rules : Client.t -> (push_rules_response, Error.t) result 89(** Get all push rules. *) 90 91val get_push_rule : 92 Client.t -> 93 scope:string -> 94 kind:rule_kind -> 95 rule_id:string -> 96 (rule, Error.t) result 97(** Get a specific push rule. *) 98 99val delete_push_rule : 100 Client.t -> 101 scope:string -> 102 kind:rule_kind -> 103 rule_id:string -> 104 (unit, Error.t) result 105(** Delete a push rule. *) 106 107val set_push_rule : 108 Client.t -> 109 scope:string -> 110 kind:rule_kind -> 111 rule_id:string -> 112 actions:action list -> 113 ?conditions:condition list -> 114 ?pattern:string -> 115 ?before:string -> 116 ?after:string -> 117 unit -> 118 (unit, Error.t) result 119(** Add or update a push rule. *) 120 121val set_push_rule_enabled : 122 Client.t -> 123 scope:string -> 124 kind:rule_kind -> 125 rule_id:string -> 126 enabled:bool -> 127 (unit, Error.t) result 128(** Enable or disable a push rule. *) 129 130val set_push_rule_actions : 131 Client.t -> 132 scope:string -> 133 kind:rule_kind -> 134 rule_id:string -> 135 actions:action list -> 136 (unit, Error.t) result 137(** Set the actions for a push rule. *) 138 139(** {1 Pusher Types} *) 140 141(** Pusher kinds. *) 142type pusher_kind = 143 | Http 144 | Email 145 146val pusher_kind_to_string : pusher_kind -> string 147(** Convert pusher kind to string. *) 148 149val pusher_kind_of_string : string -> (pusher_kind, string) result 150(** Parse pusher kind from string. *) 151 152val pusher_kind_jsont : pusher_kind Jsont.t 153(** JSON codec for pusher kind. *) 154 155(** Pusher data. *) 156type pusher_data = { 157 url : string option; 158 format : string option; 159} 160 161val pusher_data_jsont : pusher_data Jsont.t 162(** JSON codec for pusher data. *) 163 164(** Pusher. *) 165type pusher = { 166 pushkey : string; 167 kind : pusher_kind; 168 app_id : string; 169 app_display_name : string; 170 device_display_name : string; 171 profile_tag : string option; 172 lang : string; 173 data : pusher_data; 174} 175 176val pusher_jsont : pusher Jsont.t 177(** JSON codec for pusher. *) 178 179(** {1 Pusher Operations} *) 180 181val get_pushers : Client.t -> (pusher list, Error.t) result 182(** Get all pushers for the current user. *) 183 184val set_pusher : 185 Client.t -> 186 pushkey:string -> 187 kind:pusher_kind -> 188 app_id:string -> 189 app_display_name:string -> 190 device_display_name:string -> 191 ?profile_tag:string -> 192 lang:string -> 193 data:pusher_data -> 194 ?append:bool -> 195 unit -> 196 (unit, Error.t) result 197(** Set a pusher. *) 198 199val delete_pusher : 200 Client.t -> 201 pushkey:string -> 202 app_id:string -> 203 (unit, Error.t) result 204(** Delete a pusher by setting kind to null. *)