def webfinger(resource) do
host = Pleroma.Web.host
regex = ~r/(acct:)?(?<username>\w+)@#{host}/
- case Regex.named_captures(regex, resource) do
- %{"username" => username} ->
- user = User.get_cached_by_nickname(username)
+ with %{"username" => username} <- Regex.named_captures(regex, resource) do
+ user = User.get_by_nickname(username)
+ {:ok, represent_user(user)}
+ else _e ->
+ with user when not is_nil(user) <- User.get_cached_by_ap_id(resource) do
{:ok, represent_user(user)}
- _ -> nil
+ else _e ->
+ {:error, "Couldn't find user"}
+ end
end
end
|> XmlBuilder.to_doc
end
+ # This seems a better fit in Salmon
def ensure_keys_present(user) do
info = user.info || %{}
if info["keys"] do