Something went wrong. Try again.
Correctness- and interoperability-oriented Tangled CLI
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384open Camlet_domain
let error ~category ~code ~message = App_error.make ~category ~code ~message
type kind = State | Comment
let label = function State -> "state" | Comment -> "comment"
let decode_response ~kind ~decode response = let code suffix = "issue.view_" ^ label kind ^ suffix in match response with | response when response.Camlet_adapter_http.Http_client.status = 200 -> if Camlet_adapter_http.Http_client.has_media_type response "application/json" then decode response.body else Error (error ~category:Protocol ~code:(code "_content_type") ~message:"Bobbin returned an unexpected relation-list content type") | response when response.status = 400 -> ( match ( Camlet_adapter_http.Http_client.has_media_type response "application/json" , Camlet_atproto_protocol.Repository_read_codec.decode_xrpc_error response.body ) with | true, Some ("InvalidRequest", _) -> Error (error ~category:Protocol ~code:(code "_invalid_request") ~message:"Bobbin rejected the relation-list request") | _ -> Error (error ~category:Protocol ~code:(code "_response_unexpected") ~message:"Bobbin returned an ambiguous relation-list error")) | response when response.status = 429 -> Error (error ~category:Transport ~code:"issue.view_rate_limited" ~message:"Bobbin rate limited the issue observation") | response when response.status >= 500 && response.status <= 599 -> Error (error ~category:Transport ~code:"issue.view_bobbin_failed" ~message:"Bobbin could not list issue relations") | _ -> Error (error ~category:Protocol ~code:(code "_response_unexpected") ~message:"Bobbin returned an unexpected relation-list response")
let decode_state_response = decode_response ~kind:State ~decode:Camlet_atproto_protocol.Issue_view_codec.decode_state_page
let decode_comment_response = decode_response ~kind:Comment ~decode:Camlet_atproto_protocol.Issue_view_codec.decode_comment_page
let list client origin issue_uri ~cursor ~kind ~path ~decode = let query = [ ("subject", At_uri.to_string issue_uri) ; ("limit", "100") ; ("order", "asc") ] @ match cursor with None -> [] | Some value -> [ ("cursor", value) ] in match Camlet_adapter_http.Http_client.get client ~origin ~path ~query ~accept:"application/json" ~max_body_bytes:(8 * 1024 * 1024) with | Error error -> Error error | Ok response -> decode_response ~kind ~decode response
let list_states client origin issue_uri ~cursor = list client origin issue_uri ~cursor ~kind:State ~path:"/xrpc/sh.tangled.repo.issue.listStates" ~decode:Camlet_atproto_protocol.Issue_view_codec.decode_state_page
let list_comments client origin issue_uri ~cursor = list client origin issue_uri ~cursor ~kind:Comment ~path:"/xrpc/sh.tangled.feed.listComments" ~decode:Camlet_atproto_protocol.Issue_view_codec.decode_comment_page