dev vouch dev on at. thats about it atvouch.dev
8
fork

Configure Feed

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

sadly remove the self-route quirk

spammy for the bot :(

authored by

Luna and committed by tangled.org 508d7c6c d73b8461

+39 -12
+13 -12
appview/lib/atvouch/xrpc_router.ex
··· 84 84 85 85 with {:ok, did} <- require_auth(conn), 86 86 {:ok, target} <- parse_target(params) do 87 - {direct_vouch, routes} = 88 - case Atvouch.Graph.find_routes(did, target) do 89 - {:direct, _} -> 90 - {true, []} 87 + output = 88 + if did == target do 89 + %{target: target, self: true, directVouch: false, routes: []} 90 + else 91 + {direct_vouch, routes} = 92 + case Atvouch.Graph.find_routes(did, target) do 93 + {:direct, _} -> 94 + {true, []} 95 + 96 + {:routes, _, paths} -> 97 + {false, paths |> Enum.sort_by(&length/1) |> Enum.map(fn path -> %{path: path} end)} 98 + end 91 99 92 - {:routes, _, paths} -> 93 - {false, paths |> Enum.sort_by(&length/1) |> Enum.map(fn path -> %{path: path} end)} 100 + %{target: target, directVouch: direct_vouch, routes: routes} 94 101 end 95 - 96 - output = %{ 97 - target: target, 98 - directVouch: direct_vouch, 99 - routes: routes 100 - } 101 102 102 103 conn 103 104 |> put_resp_content_type("application/json")
+22
appview/test/atvouch/xrpc_get_routes_test.exs
··· 80 80 assert body["error"] == "InvalidRequest" 81 81 end 82 82 83 + test "returns self flag when checking routes to yourself" do 84 + conn = get_routes("did:plc:alice", "did:plc:alice") 85 + 86 + assert conn.status == 200 87 + body = Jason.decode!(conn.resp_body) 88 + assert body["target"] == "did:plc:alice" 89 + assert body["self"] == true 90 + assert body["directVouch"] == false 91 + assert body["routes"] == [] 92 + end 93 + 94 + test "returns self flag even when user has vouched for others" do 95 + create_vouch("did:plc:alice", "did:plc:bob") 96 + 97 + conn = get_routes("did:plc:alice", "did:plc:alice") 98 + 99 + assert conn.status == 200 100 + body = Jason.decode!(conn.resp_body) 101 + assert body["self"] == true 102 + assert body["routes"] == [] 103 + end 104 + 83 105 test "detects direct vouch" do 84 106 create_vouch("did:plc:alice", "did:plc:bob") 85 107
+4
lexicons/dev/atvouch/graph/getRoutes.json
··· 26 26 "type": "string", 27 27 "format": "did" 28 28 }, 29 + "self": { 30 + "type": "boolean", 31 + "description": "True if the target is the authenticated user themselves." 32 + }, 29 33 "directVouch": { 30 34 "type": "boolean", 31 35 "description": "True if the authenticated user directly vouches for the target."