···11+type query = {did: string} [@@deriving yojson]
22+33+type response =
44+ {did: string; active: bool; status: string option; rev: string option}
55+[@@deriving yojson]
66+77+let handler =
88+ Xrpc.handler (fun ctx ->
99+ let {did} : query = Xrpc.parse_query ctx.req query_of_yojson in
1010+ let%lwt actor =
1111+ match%lwt Data_store.get_actor_by_identifier did ctx.db with
1212+ | Some actor ->
1313+ Lwt.return actor
1414+ | None ->
1515+ Errors.invalid_request ~name:"RepoNotFound"
1616+ "couldn't find a repo with that did"
1717+ in
1818+ let%lwt user_db = User_store.connect actor.did in
1919+ let%lwt _, commit =
2020+ match%lwt User_store.get_commit user_db with
2121+ | Some c ->
2222+ Lwt.return c
2323+ | None ->
2424+ failwith ("failed to retrieve commit for " ^ actor.did)
2525+ in
2626+ let active, status, rev =
2727+ match actor.deactivated_at with
2828+ | Some _ ->
2929+ (false, Some "deactivated", None)
3030+ | None ->
3131+ (true, None, Some commit.rev)
3232+ in
3333+ Dream.json @@ Yojson.Safe.to_string
3434+ @@ response_to_yojson {did; active; status; rev} )
+3-1
pegasus/lib/api/sync/listBlobs.ml
···2020 let%lwt db = User_store.connect did in
2121 let%lwt cids = User_store.list_blobs db ~limit ~cursor ?since in
2222 let cids = List.map Cid.to_string cids in
2323- let cursor = if List.length cids = limit then Some cursor else None in
2323+ let cursor =
2424+ if List.length cids = limit then Mist.Util.last cids else None
2525+ in
2426 Dream.json @@ Yojson.Safe.to_string @@ response_to_yojson {cursor; cids} )
+53
pegasus/lib/api/sync/listRepos.ml
···11+type query = {cursor: string option; limit: int option} [@@deriving yojson]
22+33+type response = {cursor: string option; repos: res_repo list}
44+[@@deriving yojson]
55+66+and res_repo =
77+ { did: string
88+ ; head: string
99+ ; rev: string
1010+ ; active: bool option
1111+ ; status: string option }
1212+[@@deriving yojson]
1313+1414+let handler =
1515+ Xrpc.handler (fun ctx ->
1616+ let {cursor; limit} = Xrpc.parse_query ctx.req query_of_yojson in
1717+ let limit =
1818+ match limit with
1919+ | Some limit when limit > 0 && limit <= 1000 ->
2020+ limit
2121+ | _ ->
2222+ 1000
2323+ in
2424+ let%lwt actors = Data_store.list_actors ?cursor ~limit ctx.db in
2525+ let%lwt repos =
2626+ List.map
2727+ (fun (a : Data_store.Types.actor) ->
2828+ let%lwt user_db = User_store.connect a.did in
2929+ let%lwt head, {rev; _} =
3030+ match%lwt User_store.get_commit user_db with
3131+ | Some c ->
3232+ Lwt.return c
3333+ | None ->
3434+ failwith ("failed to retrieve commit for " ^ a.did)
3535+ in
3636+ let active, status =
3737+ match a.deactivated_at with
3838+ | Some _ ->
3939+ (Some false, Some "deactivated")
4040+ | None ->
4141+ (Some true, None)
4242+ in
4343+ Lwt.return
4444+ {did= a.did; head= Cid.to_string head; rev; active; status} )
4545+ actors
4646+ |> Lwt.all
4747+ in
4848+ let cursor =
4949+ if List.length repos = limit then
5050+ Option.map (fun r -> r.did) @@ Mist.Util.last repos
5151+ else None
5252+ in
5353+ Dream.json @@ Yojson.Safe.to_string @@ response_to_yojson {cursor; repos} )