objective categorical abstract machine language personal data server
65
fork

Configure Feed

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

Handle cid to/from json $link in cid module

futurGH 26b124ac fb97b3fb

+12 -6
+10
ipld/lib/cid.ml
··· 132 132 133 133 let as_cid str = Result.get_ok @@ of_string str 134 134 135 + let to_yojson cid = `Assoc [("$link", `String (to_string cid))] 136 + 137 + let of_yojson = function 138 + | `Assoc [("$link", `String str)] -> 139 + of_string str 140 + | `String str -> 141 + of_string str 142 + | _ -> 143 + Error "CID must be a string" 144 + 135 145 let compare a b = String.compare (to_string a) (to_string b) 136 146 137 147 let equal a b = String.equal (to_string a) (to_string b)
+2 -6
mist/lib/blob_ref.ml
··· 15 15 if List.mem_assoc "$type" assoc then 16 16 let type' = assoc |> List.assoc "$type" |> to_string in 17 17 if type' = "blob" then 18 - let cid_str = 19 - assoc |> List.assoc "ref" |> to_assoc |> List.assoc "$link" 20 - |> to_string 21 - in 22 - let ref = Result.get_ok @@ Cid.of_string cid_str in 18 + let ref = assoc |> List.assoc "ref" |> Cid.of_yojson |> Result.get_ok in 23 19 let mime_type = assoc |> List.assoc "mimeType" |> to_string in 24 20 let maybe_size = assoc |> List.assoc "size" in 25 21 let size = ··· 47 43 | Typed {type'; ref; mime_type; size} -> 48 44 `Assoc 49 45 [ ("$type", `String type') 50 - ; ("ref", `Assoc [("$link", `String (Cid.to_string ref))]) 46 + ; ("ref", Cid.to_yojson ref) 51 47 ; ("mimeType", `String mime_type) 52 48 ; ("size", `Int size) ] 53 49 | Untyped {cid; mime_type} ->