Return accepts_newsletter to account owner only
This commit is contained in:
parent
a0f2cba0d8
commit
6109532083
@ -292,6 +292,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||||||
|> maybe_put_allow_following_move(user, opts[:for])
|
|> maybe_put_allow_following_move(user, opts[:for])
|
||||||
|> maybe_put_unread_conversation_count(user, opts[:for])
|
|> maybe_put_unread_conversation_count(user, opts[:for])
|
||||||
|> maybe_put_unread_notification_count(user, opts[:for])
|
|> maybe_put_unread_notification_count(user, opts[:for])
|
||||||
|
|> maybe_put_accepts_newsletter(user, opts[:for])
|
||||||
end
|
end
|
||||||
|
|
||||||
defp username_from_nickname(string) when is_binary(string) do
|
defp username_from_nickname(string) when is_binary(string) do
|
||||||
@ -403,6 +404,16 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||||||
|
|
||||||
defp maybe_put_unread_notification_count(data, _, _), do: data
|
defp maybe_put_unread_notification_count(data, _, _), do: data
|
||||||
|
|
||||||
|
defp maybe_put_accepts_newsletter(data, %User{id: user_id}, %User{id: user_id} = user) do
|
||||||
|
Kernel.put_in(
|
||||||
|
data,
|
||||||
|
[:pleroma, :accepts_newsletter],
|
||||||
|
user.accepts_newsletter
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
defp maybe_put_accepts_newsletter(data, _, _), do: data
|
||||||
|
|
||||||
defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
|
defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
|
||||||
defp image_url(_), do: nil
|
defp image_url(_), do: nil
|
||||||
end
|
end
|
||||||
|
@ -470,6 +470,23 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "shows accepts_newsletter only to the account owner" do
|
||||||
|
user = insert(:user)
|
||||||
|
other_user = insert(:user)
|
||||||
|
|
||||||
|
user = User.get_cached_by_ap_id(user.ap_id)
|
||||||
|
|
||||||
|
assert AccountView.render(
|
||||||
|
"show.json",
|
||||||
|
%{user: user, for: other_user}
|
||||||
|
)[:pleroma][:accepts_newsletter] == nil
|
||||||
|
|
||||||
|
assert AccountView.render(
|
||||||
|
"show.json",
|
||||||
|
%{user: user, for: user}
|
||||||
|
)[:pleroma][:accepts_newsletter] == user.accepts_newsletter
|
||||||
|
end
|
||||||
|
|
||||||
describe "follow requests counter" do
|
describe "follow requests counter" do
|
||||||
test "shows zero when no follow requests are pending" do
|
test "shows zero when no follow requests are pending" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
Loading…
Reference in New Issue
Block a user