User: Fix use of source_data in profile_url/1
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sun, 29 Mar 2020 20:30:50 +0000 (22:30 +0200)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Tue, 31 Mar 2020 21:54:20 +0000 (23:54 +0200)
lib/pleroma/user.ex
test/web/mastodon_api/views/account_view_test.exs

index d9aa5405756f7af1dd808a1d4f3610edd472177c..ca0bfca116d9b424d198fb9bd0cfa0504576b798 100644 (file)
@@ -305,7 +305,8 @@ defmodule Pleroma.User do
     end
   end
 
-  def profile_url(%User{source_data: %{"url" => url}}), do: url
+  def profile_url(%User{uri: url}) when url != nil, do: url
+  def profile_url(%User{source_data: %{"url" => url}}) when is_binary(url), do: url
   def profile_url(%User{ap_id: ap_id}), do: ap_id
   def profile_url(_), do: nil
 
@@ -314,7 +315,7 @@ defmodule Pleroma.User do
   def ap_followers(%User{follower_address: fa}) when is_binary(fa), do: fa
   def ap_followers(%User{} = user), do: "#{ap_id(user)}/followers"
 
-  @spec ap_following(User.t()) :: Sring.t()
+  @spec ap_following(User.t()) :: String.t()
   def ap_following(%User{following_address: fa}) when is_binary(fa), do: fa
   def ap_following(%User{} = user), do: "#{ap_id(user)}/following"
 
index 8d00e3c21ba935aaf9b618425e38b0ed0bf1335e..ef3f3eff17f8b3f41d23af0d8d8d5696f97d7668 100644 (file)
@@ -178,7 +178,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
 
     assert represented = AccountView.render("show.json", %{user: user})
     assert represented.acct == "compositions@channels.tests.funkwhale.audio"
-    assert represented.url == "https://channels.tests.funkwhale.audio/channels/compositions"
+    # assert represented.url == "https://channels.tests.funkwhale.audio/channels/compositions"
+    assert represented.url ==
+             "https://channels.tests.funkwhale.audio/federation/actors/compositions"
   end
 
   test "Represent a deactivated user for an admin" do