From 847cb15626debd15eb50c00bb50113457bed7d1c Mon Sep 17 00:00:00 2001 From: lain Date: Sat, 24 Mar 2018 15:09:09 +0100 Subject: [PATCH] Fix tests. --- lib/pleroma/user.ex | 8 ++++++++ lib/pleroma/web/twitter_api/twitter_api.ex | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 5da146014..e92b85f52 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -458,4 +458,12 @@ def insert_or_update_user(data) do def ap_enabled?(%User{info: info}), do: info["ap_enabled"] def ap_enabled?(_), do: false + + def get_or_fetch(uri_or_nickname) do + if String.starts_with?(uri_or_nickname, "http") do + get_or_fetch_by_ap_id(uri_or_nickname) + else + get_or_fetch_by_nickname(uri_or_nickname) + end + end end diff --git a/lib/pleroma/web/twitter_api/twitter_api.ex b/lib/pleroma/web/twitter_api/twitter_api.ex index 61b11681a..6e1f141f3 100644 --- a/lib/pleroma/web/twitter_api/twitter_api.ex +++ b/lib/pleroma/web/twitter_api/twitter_api.ex @@ -328,8 +328,7 @@ def conversation_id_to_context(id) do end def get_external_profile(for_user, uri) do - IO.inspect(uri) - with %User{} = user <- User.get_or_fetch_by_nickname(uri) do + with %User{} = user <- User.get_or_fetch(uri) do spawn(fn -> with url <- user.info["topic"], {:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do