mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
Provide known-good user.uri, remove User.profile_url/1
This commit is contained in:
parent
b30fb1f3bb
commit
185520d1b4
7 changed files with 19 additions and 13 deletions
|
@ -305,11 +305,6 @@ defmodule Pleroma.User do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
def ap_id(%User{nickname: nickname}), do: "#{Web.base_url()}/users/#{nickname}"
|
def ap_id(%User{nickname: nickname}), do: "#{Web.base_url()}/users/#{nickname}"
|
||||||
|
|
||||||
def ap_followers(%User{follower_address: fa}) when is_binary(fa), do: fa
|
def ap_followers(%User{follower_address: fa}) when is_binary(fa), do: fa
|
||||||
|
|
|
@ -1379,6 +1379,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@spec get_actor_url(any()) :: binary() | nil
|
||||||
|
defp get_actor_url(url) when is_binary(url), do: url
|
||||||
|
defp get_actor_url(%{"href" => href}) when is_binary(href), do: href
|
||||||
|
|
||||||
|
defp get_actor_url(url) when is_list(url) do
|
||||||
|
url
|
||||||
|
|> List.first()
|
||||||
|
|> get_actor_url()
|
||||||
|
end
|
||||||
|
|
||||||
|
defp get_actor_url(_url), do: nil
|
||||||
|
|
||||||
defp object_to_user_data(data) do
|
defp object_to_user_data(data) do
|
||||||
avatar =
|
avatar =
|
||||||
data["icon"]["url"] &&
|
data["icon"]["url"] &&
|
||||||
|
@ -1408,6 +1420,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
||||||
|
|
||||||
user_data = %{
|
user_data = %{
|
||||||
ap_id: data["id"],
|
ap_id: data["id"],
|
||||||
|
uri: get_actor_url(data["url"]),
|
||||||
ap_enabled: true,
|
ap_enabled: true,
|
||||||
source_data: data,
|
source_data: data,
|
||||||
banner: banner,
|
banner: banner,
|
||||||
|
|
|
@ -43,7 +43,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
||||||
id: to_string(user.id),
|
id: to_string(user.id),
|
||||||
acct: user.nickname,
|
acct: user.nickname,
|
||||||
username: username_from_nickname(user.nickname),
|
username: username_from_nickname(user.nickname),
|
||||||
url: User.profile_url(user)
|
url: user.uri || user.ap_id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
||||||
following_count: following_count,
|
following_count: following_count,
|
||||||
statuses_count: user.note_count,
|
statuses_count: user.note_count,
|
||||||
note: user.bio || "",
|
note: user.bio || "",
|
||||||
url: User.profile_url(user),
|
url: user.uri || user.ap_id,
|
||||||
avatar: image,
|
avatar: image,
|
||||||
avatar_static: image,
|
avatar_static: image,
|
||||||
header: header,
|
header: header,
|
||||||
|
|
|
@ -68,7 +68,7 @@ defmodule Pleroma.Web.Metadata.Providers.OpenGraph do
|
||||||
property: "og:title",
|
property: "og:title",
|
||||||
content: Utils.user_name_string(user)
|
content: Utils.user_name_string(user)
|
||||||
], []},
|
], []},
|
||||||
{:meta, [property: "og:url", content: User.profile_url(user)], []},
|
{:meta, [property: "og:url", content: user.uri || user.ap_id], []},
|
||||||
{:meta, [property: "og:description", content: truncated_bio], []},
|
{:meta, [property: "og:description", content: truncated_bio], []},
|
||||||
{:meta, [property: "og:type", content: "website"], []},
|
{:meta, [property: "og:type", content: "website"], []},
|
||||||
{:meta, [property: "og:image", content: Utils.attachment_url(User.avatar_url(user))], []},
|
{:meta, [property: "og:image", content: Utils.attachment_url(User.avatar_url(user))], []},
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="p-author h-card">
|
<div class="p-author h-card">
|
||||||
<a class="u-url" rel="author noopener" href="<%= User.profile_url(@user) %>">
|
<a class="u-url" rel="author noopener" href="<%= (@user.uri || @user.ap_id) %>">
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
<img src="<%= User.avatar_url(@user) |> MediaProxy.url %>" width="48" height="48" alt="">
|
<img src="<%= User.avatar_url(@user) |> MediaProxy.url %>" width="48" height="48" alt="">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<button type="submit" class="collapse">Remote follow</button>
|
<button type="submit" class="collapse">Remote follow</button>
|
||||||
</form>
|
</form>
|
||||||
<%= raw Formatter.emojify(@user.name, emoji_for_user(@user)) %> |
|
<%= raw Formatter.emojify(@user.name, emoji_for_user(@user)) %> |
|
||||||
<%= link "@#{@user.nickname}@#{Endpoint.host()}", to: User.profile_url(@user) %>
|
<%= link "@#{@user.nickname}@#{Endpoint.host()}", to: (@user.uri || @user.ap_id) %>
|
||||||
</h3>
|
</h3>
|
||||||
<p><%= raw @user.bio %></p>
|
<p><%= raw @user.bio %></p>
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -178,9 +178,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||||
|
|
||||||
assert represented = AccountView.render("show.json", %{user: user})
|
assert represented = AccountView.render("show.json", %{user: user})
|
||||||
assert represented.acct == "compositions@channels.tests.funkwhale.audio"
|
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
|
end
|
||||||
|
|
||||||
test "Represent a deactivated user for an admin" do
|
test "Represent a deactivated user for an admin" do
|
||||||
|
|
Loading…
Reference in a new issue