objective categorical abstract machine language personal data server
65
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update PDS to use [@@xrpc_query] rewrite

futurGH a1cc895a d5844fb9

+23 -10
+2 -6
pegasus/lib/api/proxy/appBskyFeedGetFeed.ml
··· 1 - type query = 2 - { feed: string 3 - ; limit: int option [@default None] 4 - ; cursor: string option [@default None] } 5 - [@@deriving yojson {strict= false}] 1 + open Lexicons.App.Bsky.Feed.GetFeed.Main 6 2 7 3 let handler = 8 4 Xrpc.handler ~auth:Authorization (fun ctx -> 9 - let input = Xrpc.parse_query ctx.req query_of_yojson in 5 + let input = Xrpc.parse_query ctx.req params_of_yojson in 10 6 match Util.Syntax.parse_at_uri input.feed with 11 7 | None -> 12 8 Errors.invalid_request ("invalid feed URI " ^ input.feed)
+21 -4
pegasus/lib/xrpc.ml
··· 167 167 (of_yojson : Yojson.Safe.t -> ('a, string) result) : 'a = 168 168 try 169 169 let queries = Dream.all_queries req in 170 + (* group repeated keys into JSON arrays, single keys stay as strings *) 171 + let tbl = Hashtbl.create 16 in 172 + let order = ref [] in 173 + List.iter 174 + (fun (k, v) -> 175 + if not (Hashtbl.mem tbl k) then order := k :: !order ; 176 + let prev = try Hashtbl.find tbl k with Not_found -> [] in 177 + Hashtbl.replace tbl k (prev @ [v]) ) 178 + queries ; 170 179 let query_json = 171 180 `Assoc 172 - (List.map 173 - (fun (k, v) -> 174 - (k, try Yojson.Safe.from_string v with _ -> `String v) ) 175 - queries ) 181 + (List.rev_map 182 + (fun k -> 183 + let vs = Hashtbl.find tbl k in 184 + let v = 185 + match vs with 186 + | [v] -> 187 + `String v 188 + | vs -> 189 + `List (List.map (fun v -> `String v) vs) 190 + in 191 + (k, v) ) 192 + !order ) 176 193 in 177 194 match query_json |> of_yojson with 178 195 | Error e ->