From b547f1f1ee3a5532f993e330ecfba5667a86c62e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Mon, 15 Nov 2021 08:47:03 +0100 Subject: [PATCH] Handle Webfinger endpoint not returning 200 Signed-off-by: Thomas Citharel --- lib/federation/web_finger/web_finger.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/federation/web_finger/web_finger.ex b/lib/federation/web_finger/web_finger.ex index e7bcd49dd..7a952b436 100644 --- a/lib/federation/web_finger/web_finger.ex +++ b/lib/federation/web_finger/web_finger.ex @@ -188,10 +188,12 @@ defmodule Mobilizon.Federation.WebFinger do @spec find_webfinger_endpoint(String.t()) :: {:ok, String.t()} | {:error, :link_not_found} | {:error, any()} defp find_webfinger_endpoint(domain) when is_binary(domain) do - with {:ok, %{body: body}} <- fetch_document("http://#{domain}/.well-known/host-meta"), + with {:ok, %Tesla.Env{status: 200, body: body}} <- + fetch_document("http://#{domain}/.well-known/host-meta"), link_template when is_binary(link_template) <- find_link_from_template(body) do {:ok, link_template} else + {:ok, %Tesla.Env{status: 404}} -> {:error, :entity_not_found} {:error, :link_not_found} -> {:error, :link_not_found} {:error, error} -> {:error, error} end