Merge branch 'fix/background-profile-fetch' into 'develop'

Fetch external profile in the background.

See merge request pleroma/pleroma!49
This commit is contained in:
lambda 2018-01-16 14:18:07 +00:00
commit ac7580df78
2 changed files with 7 additions and 5 deletions

View File

@ -316,10 +316,12 @@ def conversation_id_to_context(id) do
def get_external_profile(for_user, uri) do def get_external_profile(for_user, uri) do
with {:ok, %User{} = user} <- OStatus.find_or_make_user(uri) do with {:ok, %User{} = user} <- OStatus.find_or_make_user(uri) do
with url <- user.info["topic"], spawn(fn ->
{:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do with url <- user.info["topic"],
OStatus.handle_incoming(body) {:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do
end OStatus.handle_incoming(body)
end
end)
{:ok, UserView.render("show.json", %{user: user, for: for_user})} {:ok, UserView.render("show.json", %{user: user, for: for_user})}
else _e -> else _e ->
{:error, "Couldn't find user"} {:error, "Couldn't find user"}

View File

@ -404,7 +404,7 @@ test "fetches a user by uri" do
assert represented["id"] == UserView.render("show.json", %{user: remote, for: user})["id"] assert represented["id"] == UserView.render("show.json", %{user: remote, for: user})["id"]
# Also fetches the feed. # Also fetches the feed.
assert Activity.get_create_activity_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status") # assert Activity.get_create_activity_by_object_ap_id("tag:mastodon.social,2017-04-05:objectId=1641750:objectType=Status")
end end
end end
end end