Birthdays: hide_birthday -> show_birthday
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
aaa9314f4c
commit
0266bc3c96
14 changed files with 39 additions and 37 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue