aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user.ex7
-rw-r--r--lib/pleroma/user/query.ex4
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex5
-rw-r--r--lib/pleroma/web/activity_pub/views/user_view.ex2
-rw-r--r--lib/pleroma/web/api_spec/operations/account_operation.ex6
-rw-r--r--lib/pleroma/web/api_spec/schemas/account.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/account_controller.ex2
-rw-r--r--lib/pleroma/web/mastodon_api/views/account_view.ex20
-rw-r--r--lib/pleroma/web/pleroma_api/controllers/account_controller.ex2
-rw-r--r--lib/pleroma/web/router.ex2
10 files changed, 26 insertions, 26 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 8bb4fb204..0d209c5a8 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -155,7 +155,7 @@ defmodule Pleroma.User do
field(:is_suggested, :boolean, default: false)
field(:last_status_at, :naive_datetime)
field(:birthday, :date)
- field(:hide_birthday, :boolean, default: false)
+ field(:show_birthday, :boolean, default: false)
embeds_one(
:notification_settings,
@@ -473,7 +473,8 @@ defmodule Pleroma.User do
:also_known_as,
:accepts_chat_messages,
:pinned_objects,
- :birthday
+ :birthday,
+ :show_birthday
]
)
|> cast(params, [:name], empty_values: [])
@@ -536,7 +537,7 @@ defmodule Pleroma.User do
:accepts_chat_messages,
:disclose_client,
:birthday,
- :hide_birthday
+ :show_birthday
]
)
|> validate_min_age()
diff --git a/lib/pleroma/user/query.ex b/lib/pleroma/user/query.ex
index dddfe07bf..bd11d287c 100644
--- a/lib/pleroma/user/query.ex
+++ b/lib/pleroma/user/query.ex
@@ -234,14 +234,14 @@ defmodule Pleroma.User.Query do
defp compose_query({:birthday_day, day}, query) do
query
- |> where([u], u.hide_birthday == false)
+ |> where([u], u.show_birthday == true)
|> where([u], not is_nil(u.birthday))
|> where([u], fragment("date_part('day', ?)", u.birthday) == ^day)
end
defp compose_query({:birthday_month, month}, query) do
query
- |> where([u], u.hide_birthday == false)
+ |> where([u], u.show_birthday == true)
|> where([u], not is_nil(u.birthday))
|> where([u], fragment("date_part('month', ?)", u.birthday) == ^month)
end
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 7551dd56d..e6475a2b7 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -1511,6 +1511,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
nil
end
+ show_birthday = !!birthday
+
user_data = %{
ap_id: data["id"],
uri: get_actor_url(data["url"]),
@@ -1534,7 +1536,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
shared_inbox: shared_inbox,
accepts_chat_messages: accepts_chat_messages,
pinned_objects: pinned_objects,
- birthday: birthday
+ birthday: birthday,
+ show_birthday: show_birthday
}
# nickname can be nil because of virtual actors
diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex
index 8ab516214..5ed08d7f6 100644
--- a/lib/pleroma/web/activity_pub/views/user_view.ex
+++ b/lib/pleroma/web/activity_pub/views/user_view.ex
@@ -93,7 +93,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
end
birthday =
- if !user.hide_birthday,
+ if user.show_birthday,
do: user.birthday,
else: nil
diff --git a/lib/pleroma/web/api_spec/operations/account_operation.ex b/lib/pleroma/web/api_spec/operations/account_operation.ex
index 1b2bffa3e..03efa3c38 100644
--- a/lib/pleroma/web/api_spec/operations/account_operation.ex
+++ b/lib/pleroma/web/api_spec/operations/account_operation.ex
@@ -733,10 +733,10 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
description: "User's birthday",
format: :date
},
- hide_birthday: %Schema{
+ show_birthday: %Schema{
allOf: [BooleanLike],
nullable: true,
- description: "User's birthday will be hidden"
+ description: "User's birthday will be visible"
}
},
example: %{
@@ -758,7 +758,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
also_known_as: ["https://foo.bar/users/foo"],
discoverable: false,
actor_type: "Person",
- hide_birthday: true,
+ show_birthday: false,
birthday: "2001-02-12"
}
}
diff --git a/lib/pleroma/web/api_spec/schemas/account.ex b/lib/pleroma/web/api_spec/schemas/account.ex
index 2113f0d31..029c6f6cf 100644
--- a/lib/pleroma/web/api_spec/schemas/account.ex
+++ b/lib/pleroma/web/api_spec/schemas/account.ex
@@ -54,7 +54,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
description:
"whether the user account is waiting on email confirmation to be activated"
},
- hide_birthday: %Schema{type: :boolean, nullable: true},
+ show_birthday: %Schema{type: :boolean, nullable: true},
hide_favorites: %Schema{type: :boolean},
hide_followers_count: %Schema{
type: :boolean,
diff --git a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
index 60c9f7d69..8e6d49168 100644
--- a/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/account_controller.ex
@@ -192,7 +192,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
:allow_following_move,
:also_known_as,
:accepts_chat_messages,
- :hide_birthday
+ :show_birthday
]
|> Enum.reduce(%{}, fn key, acc ->
Maps.put_if_present(acc, key, params[key], &{:ok, Params.truthy_param?(&1)})
diff --git a/lib/pleroma/web/mastodon_api/views/account_view.ex b/lib/pleroma/web/mastodon_api/views/account_view.ex
index e0137a112..e73d03f06 100644
--- a/lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/lib/pleroma/web/mastodon_api/views/account_view.ex
@@ -298,8 +298,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
background_image: image_url(user.background) |> MediaProxy.url(),
accepts_chat_messages: user.accepts_chat_messages,
favicon: favicon,
- birthday: user.birthday,
- hide_birthday: user.hide_birthday
+ birthday: user.birthday
}
}
|> maybe_put_role(user, opts[:for])
@@ -313,7 +312,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|> maybe_put_unread_conversation_count(user, opts[:for])
|> maybe_put_unread_notification_count(user, opts[:for])
|> maybe_put_email_address(user, opts[:for])
- |> maybe_hide_birthday(user, opts[:for])
+ |> maybe_show_birthday(user, opts[:for])
end
defp username_from_nickname(string) when is_binary(string) do
@@ -347,6 +346,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|> Kernel.put_in([:source, :privacy], user.default_scope)
|> Kernel.put_in([:source, :pleroma, :show_role], user.show_role)
|> Kernel.put_in([:source, :pleroma, :no_rich_text], user.no_rich_text)
+ |> Kernel.put_in([:source, :pleroma, :show_birthday], user.show_birthday)
end
defp maybe_put_settings(data, _, _, _), do: data
@@ -435,22 +435,18 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
defp maybe_put_email_address(data, _, _), do: data
- defp maybe_hide_birthday(data, %User{id: user_id}, %User{id: user_id}) do
+ defp maybe_show_birthday(data, %User{id: user_id} = user, %User{id: user_id}) do
data
+ |> Kernel.put_in([:pleroma, :birthday], user.birthday)
end
- defp maybe_hide_birthday(data, %User{hide_birthday: true}, _) do
+ defp maybe_show_birthday(data, %User{show_birthday: true} = user, _) do
data
- |> Kernel.pop_in([:pleroma, :birthday])
- |> elem(1)
- |> Kernel.pop_in([:pleroma, :hide_birthday])
- |> elem(1)
+ |> Kernel.put_in([:pleroma, :birthday], user.birthday)
end
- defp maybe_hide_birthday(data, _, _) do
+ defp maybe_show_birthday(data, _, _) do
data
- |> Kernel.pop_in([:pleroma, :hide_birthday])
- |> elem(1)
end
defp image_url(%{"url" => [%{"href" => href} | _]}), do: href
diff --git a/lib/pleroma/web/pleroma_api/controllers/account_controller.ex b/lib/pleroma/web/pleroma_api/controllers/account_controller.ex
index 20697fa46..d78ebbe2e 100644
--- a/lib/pleroma/web/pleroma_api/controllers/account_controller.ex
+++ b/lib/pleroma/web/pleroma_api/controllers/account_controller.ex
@@ -143,7 +143,7 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do
end
end
- @doc "GET /api/v1/pleroma/birthday_reminders"
+ @doc "GET /api/v1/pleroma/birthdays"
def birthdays(%{assigns: %{user: %User{} = user}} = conn, %{day: day, month: month} = _params) do
birthdays =
User.get_friends_birthdays_query(user, day, month)
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 2d896fdd4..26706a6b8 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -449,7 +449,7 @@ defmodule Pleroma.Web.Router do
post("/accounts/:id/subscribe", AccountController, :subscribe)
post("/accounts/:id/unsubscribe", AccountController, :unsubscribe)
- get("/birthday_reminders", AccountController, :birthdays)
+ get("/birthdays", AccountController, :birthdays)
end
post("/accounts/confirmation_resend", AccountController, :confirmation_resend)