properly get actor from key id for Streams.

This commit is contained in:
Moon Man 2024-05-21 23:50:35 +00:00
parent 7fca598268
commit aee44ac25e
1 changed files with 18 additions and 0 deletions

View File

@ -17,6 +17,7 @@ def key_id_to_actor_id(key_id) do
key_id
|> URI.parse()
|> Map.put(:fragment, nil)
|> remove_query()
|> remove_suffix(@known_suffixes)
maybe_ap_id = URI.to_string(uri)
@ -33,6 +34,23 @@ def key_id_to_actor_id(key_id) do
end
end
defp remove_query(uri) do
if uri.query do
new_query =
URI.decode_query(uri.query)
|> Map.delete("operation")
|> URI.encode_query()
|> case do
"" -> nil
query -> query
end
Map.put(uri, :query, new_query)
else
uri
end
end
defp remove_suffix(uri, [test | rest]) do
if not is_nil(uri.path) and String.ends_with?(uri.path, test) do
Map.put(uri, :path, String.replace(uri.path, test, ""))