summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2022-01-25 16:59:07 +0000
committerAlex Gleason <alex@alexgleason.me>2022-01-25 16:59:07 +0000
commit99e9c2c668228e7f373a7ced23e4c5701a86f11b (patch)
treed30832251f2d5faa6d75a7dca2126839cc62e8eb
parentdd7977bb68f8289b1487159a81df510da11cd944 (diff)
parentab12a05a432be549b02e3fd84e4e30680a89bbf9 (diff)
Merge branch 'birth-dates' into 'develop'
Fix show_birthday See merge request pleroma/pleroma!3621
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex3
-rw-r--r--test/pleroma/web/mastodon_api/views/account_view_test.exs36
2 files changed, 35 insertions, 4 deletions
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index e73d03f06..1d78ced19 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -297,8 +297,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
skip_thread_containment: user.skip_thread_containment,
background_image: image_url(user.background) |> MediaProxy.url(),
accepts_chat_messages: user.accepts_chat_messages,
- favicon: favicon,
- birthday: user.birthday
+ favicon: favicon
}
}
|> maybe_put_role(user, opts[:for])
diff --git a/test/pleroma/web/mastodon_api/views/account_view_test.exs b/test/pleroma/web/mastodon_api/views/account_view_test.exs
index 329813994..9fc56f7f0 100644
--- a/test/pleroma/web/mastodon_api/views/account_view_test.exs
+++ b/test/pleroma/web/mastodon_api/views/account_view_test.exs
@@ -79,7 +79,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
ap_id: user.ap_id,
also_known_as: ["https://shitposter.zone/users/shp"],
background_image: "https://example.com/images/asuka_hospital.png",
- birthday: nil,
favicon: nil,
is_confirmed: true,
tags: [],
@@ -182,7 +181,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
ap_id: user.ap_id,
also_known_as: [],
background_image: nil,
- birthday: nil,
favicon: nil,
is_confirmed: true,
tags: [],
@@ -496,6 +494,40 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
end
end
+ describe "hiding birthday" do
+ test "doesn't show birthday if hidden" do
+ user =
+ insert(:user, %{
+ birthday: "2001-02-12",
+ show_birthday: false
+ })
+
+ other_user = insert(:user)
+
+ user = User.get_cached_by_ap_id(user.ap_id)
+
+ assert AccountView.render(
+ "show.json",
+ %{user: user, for: other_user}
+ )[:birthday] == nil
+ end
+
+ test "shows hidden birthday to the account owner" do
+ user =
+ insert(:user, %{
+ birthday: "2001-02-12",
+ show_birthday: false
+ })
+
+ user = User.get_cached_by_ap_id(user.ap_id)
+
+ assert AccountView.render(
+ "show.json",
+ %{user: user, for: user}
+ )[:birthday] == nil
+ end
+ end
+
describe "follow requests counter" do
test "shows zero when no follow requests are pending" do
user = insert(:user)