Birthdays: birth_date --> birthday
This commit is contained in:
parent
74cf0f0355
commit
66e8c6f90f
@ -25,8 +25,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- Ability to log slow Ecto queries by configuring `:pleroma, :telemetry, :slow_queries_logging`
|
- Ability to log slow Ecto queries by configuring `:pleroma, :telemetry, :slow_queries_logging`
|
||||||
- Added Phoenix LiveDashboard at `/phoenix/live_dashboard`
|
- Added Phoenix LiveDashboard at `/phoenix/live_dashboard`
|
||||||
- Added `/manifest.json` for progressive web apps.
|
- Added `/manifest.json` for progressive web apps.
|
||||||
- MastoAPI: Support for `birth_date` and `show_birth_date` field in `/api/v1/accounts/update_credentials`.
|
- MastoAPI: Support for `birthday` and `show_birthday` field in `/api/v1/accounts/update_credentials`.
|
||||||
- Configuration: Add `birth_date_required` and `birth_date_min_age` settings to provide a way to require users to enter their birth date.
|
- Configuration: Add `birthday_required` and `birthday_min_age` settings to provide a way to require users to enter their birth date.
|
||||||
- PleromaAPI: Add `GET /api/v1/pleroma/birthday_reminders` API endpoint
|
- PleromaAPI: Add `GET /api/v1/pleroma/birthday_reminders` API endpoint
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -260,8 +260,8 @@ config :pleroma, :instance,
|
|||||||
profile_directory: true,
|
profile_directory: true,
|
||||||
privileged_staff: false,
|
privileged_staff: false,
|
||||||
max_endorsed_users: 20,
|
max_endorsed_users: 20,
|
||||||
birth_date_required: false,
|
birthday_required: false,
|
||||||
birth_date_min_age: 0
|
birthday_min_age: 0
|
||||||
|
|
||||||
config :pleroma, :welcome,
|
config :pleroma, :welcome,
|
||||||
direct_message: [
|
direct_message: [
|
||||||
|
@ -959,12 +959,12 @@ config :pleroma, :config_description, [
|
|||||||
"Let moderators access sensitive data (e.g. updating user credentials, get password reset token, delete users, index and read private statuses and chats)"
|
"Let moderators access sensitive data (e.g. updating user credentials, get password reset token, delete users, index and read private statuses and chats)"
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :birth_date_required,
|
key: :birthday_required,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description: "Require users to provide birth day."
|
description: "Require users to provide birth day."
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
key: :birth_date_min_age,
|
key: :birthday_min_age,
|
||||||
type: :integer,
|
type: :integer,
|
||||||
description:
|
description:
|
||||||
"Min age for users to create account. Only makes sense if birth date is required."
|
"Min age for users to create account. Only makes sense if birth date is required."
|
||||||
|
@ -154,8 +154,8 @@ defmodule Pleroma.User do
|
|||||||
field(:pinned_objects, :map, default: %{})
|
field(:pinned_objects, :map, default: %{})
|
||||||
field(:is_suggested, :boolean, default: false)
|
field(:is_suggested, :boolean, default: false)
|
||||||
field(:last_status_at, :naive_datetime)
|
field(:last_status_at, :naive_datetime)
|
||||||
field(:birth_date, :date)
|
field(:birthday, :date)
|
||||||
field(:hide_birth_date, :boolean, default: false)
|
field(:hide_birthday, :boolean, default: false)
|
||||||
|
|
||||||
embeds_one(
|
embeds_one(
|
||||||
:notification_settings,
|
:notification_settings,
|
||||||
@ -473,7 +473,7 @@ defmodule Pleroma.User do
|
|||||||
:also_known_as,
|
:also_known_as,
|
||||||
:accepts_chat_messages,
|
:accepts_chat_messages,
|
||||||
:pinned_objects,
|
:pinned_objects,
|
||||||
:birth_date
|
:birthday
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|> cast(params, [:name], empty_values: [])
|
|> cast(params, [:name], empty_values: [])
|
||||||
@ -535,8 +535,8 @@ defmodule Pleroma.User do
|
|||||||
:actor_type,
|
:actor_type,
|
||||||
:accepts_chat_messages,
|
:accepts_chat_messages,
|
||||||
:disclose_client,
|
:disclose_client,
|
||||||
:birth_date,
|
:birthday,
|
||||||
:hide_birth_date
|
:hide_birthday
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|> validate_min_age()
|
|> validate_min_age()
|
||||||
@ -745,7 +745,7 @@ defmodule Pleroma.User do
|
|||||||
:emoji,
|
:emoji,
|
||||||
:accepts_chat_messages,
|
:accepts_chat_messages,
|
||||||
:registration_reason,
|
:registration_reason,
|
||||||
:birth_date
|
:birthday
|
||||||
])
|
])
|
||||||
|> validate_required([:name, :nickname, :password, :password_confirmation])
|
|> validate_required([:name, :nickname, :password, :password_confirmation])
|
||||||
|> validate_confirmation(:password)
|
|> validate_confirmation(:password)
|
||||||
@ -767,7 +767,7 @@ defmodule Pleroma.User do
|
|||||||
|> validate_length(:name, min: 1, max: name_limit)
|
|> validate_length(:name, min: 1, max: name_limit)
|
||||||
|> validate_length(:registration_reason, max: reason_limit)
|
|> validate_length(:registration_reason, max: reason_limit)
|
||||||
|> maybe_validate_required_email(opts[:external])
|
|> maybe_validate_required_email(opts[:external])
|
||||||
|> maybe_validate_required_birth_date
|
|> maybe_validate_required_birthday
|
||||||
|> validate_min_age()
|
|> validate_min_age()
|
||||||
|> put_password_hash
|
|> put_password_hash
|
||||||
|> put_ap_id()
|
|> put_ap_id()
|
||||||
@ -785,9 +785,9 @@ defmodule Pleroma.User do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_validate_required_birth_date(changeset) do
|
defp maybe_validate_required_birthday(changeset) do
|
||||||
if Config.get([:instance, :birth_date_required]) do
|
if Config.get([:instance, :birthday_required]) do
|
||||||
validate_required(changeset, [:birth_date])
|
validate_required(changeset, [:birthday])
|
||||||
else
|
else
|
||||||
changeset
|
changeset
|
||||||
end
|
end
|
||||||
@ -795,13 +795,13 @@ defmodule Pleroma.User do
|
|||||||
|
|
||||||
defp validate_min_age(changeset) do
|
defp validate_min_age(changeset) do
|
||||||
changeset
|
changeset
|
||||||
|> validate_change(:birth_date, fn :birth_date, birth_date ->
|
|> validate_change(:birthday, fn :birthday, birthday ->
|
||||||
valid? =
|
valid? =
|
||||||
Date.utc_today()
|
Date.utc_today()
|
||||||
|> Date.diff(birth_date) >=
|
|> Date.diff(birthday) >=
|
||||||
Config.get([:instance, :birth_date_min_age])
|
Config.get([:instance, :birthday_min_age])
|
||||||
|
|
||||||
if valid?, do: [], else: [birth_date: "Invalid birth date"]
|
if valid?, do: [], else: [birthday: "Invalid age"]
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -2589,8 +2589,8 @@ defmodule Pleroma.User do
|
|||||||
User.Query.build(%{
|
User.Query.build(%{
|
||||||
friends: user,
|
friends: user,
|
||||||
deactivated: false,
|
deactivated: false,
|
||||||
birth_day: day,
|
birthday_day: day,
|
||||||
birth_month: month
|
birthday_month: month
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -60,8 +60,8 @@ defmodule Pleroma.User.Query do
|
|||||||
select: term(),
|
select: term(),
|
||||||
limit: pos_integer(),
|
limit: pos_integer(),
|
||||||
actor_types: [String.t()],
|
actor_types: [String.t()],
|
||||||
birth_day: pos_integer(),
|
birthday_day: pos_integer(),
|
||||||
birth_month: pos_integer()
|
birthday_month: pos_integer()
|
||||||
}
|
}
|
||||||
| map()
|
| map()
|
||||||
|
|
||||||
@ -232,18 +232,18 @@ defmodule Pleroma.User.Query do
|
|||||||
|> where([u], not like(u.nickname, "internal.%"))
|
|> where([u], not like(u.nickname, "internal.%"))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp compose_query({:birth_day, day}, query) do
|
defp compose_query({:birthday_day, day}, query) do
|
||||||
query
|
query
|
||||||
|> where([u], u.hide_birth_date == false)
|
|> where([u], u.hide_birthday == false)
|
||||||
|> where([u], not is_nil(u.birth_date))
|
|> where([u], not is_nil(u.birthday))
|
||||||
|> where([u], fragment("date_part('day', ?)", u.birth_date) == ^day)
|
|> where([u], fragment("date_part('day', ?)", u.birthday) == ^day)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp compose_query({:birth_month, month}, query) do
|
defp compose_query({:birthday_month, month}, query) do
|
||||||
query
|
query
|
||||||
|> where([u], u.hide_birth_date == false)
|
|> where([u], u.hide_birthday == false)
|
||||||
|> where([u], not is_nil(u.birth_date))
|
|> where([u], not is_nil(u.birthday))
|
||||||
|> where([u], fragment("date_part('month', ?)", u.birth_date) == ^month)
|
|> where([u], fragment("date_part('month', ?)", u.birthday) == ^month)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp compose_query(_unsupported_param, query), do: query
|
defp compose_query(_unsupported_param, query), do: query
|
||||||
|
@ -1501,8 +1501,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
birth_date =
|
birthday =
|
||||||
if data["vcard:bday"] do
|
if is_binary(data["vcard:bday"]) do
|
||||||
case Date.from_iso8601(data["vcard:bday"]) do
|
case Date.from_iso8601(data["vcard:bday"]) do
|
||||||
{:ok, date} -> date
|
{:ok, date} -> date
|
||||||
{:error, _} -> nil
|
{:error, _} -> nil
|
||||||
@ -1534,7 +1534,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||||||
shared_inbox: shared_inbox,
|
shared_inbox: shared_inbox,
|
||||||
accepts_chat_messages: accepts_chat_messages,
|
accepts_chat_messages: accepts_chat_messages,
|
||||||
pinned_objects: pinned_objects,
|
pinned_objects: pinned_objects,
|
||||||
birth_date: birth_date
|
birthday: birthday
|
||||||
}
|
}
|
||||||
|
|
||||||
# nickname can be nil because of virtual actors
|
# nickname can be nil because of virtual actors
|
||||||
|
@ -92,9 +92,9 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||||||
%{}
|
%{}
|
||||||
end
|
end
|
||||||
|
|
||||||
birth_date =
|
birthday =
|
||||||
if !user.hide_birth_date,
|
if !user.hide_birthday,
|
||||||
do: user.birth_date,
|
do: user.birthday,
|
||||||
else: nil
|
else: nil
|
||||||
|
|
||||||
%{
|
%{
|
||||||
@ -122,7 +122,7 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||||||
"discoverable" => user.is_discoverable,
|
"discoverable" => user.is_discoverable,
|
||||||
"capabilities" => capabilities,
|
"capabilities" => capabilities,
|
||||||
"alsoKnownAs" => user.also_known_as,
|
"alsoKnownAs" => user.also_known_as,
|
||||||
"vcard:bday" => birth_date
|
"vcard:bday" => birthday
|
||||||
}
|
}
|
||||||
|> Map.merge(maybe_make_image(&User.avatar_url/2, "icon", user))
|
|> Map.merge(maybe_make_image(&User.avatar_url/2, "icon", user))
|
||||||
|> Map.merge(maybe_make_image(&User.banner_url/2, "image", user))
|
|> Map.merge(maybe_make_image(&User.banner_url/2, "image", user))
|
||||||
|
@ -544,10 +544,10 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||||||
nullable: true,
|
nullable: true,
|
||||||
description: "Invite token required when the registrations aren't public"
|
description: "Invite token required when the registrations aren't public"
|
||||||
},
|
},
|
||||||
birth_date: %Schema{
|
birthday: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
description: "User's birth date",
|
description: "User's birthday",
|
||||||
format: :date
|
format: :date
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -727,16 +727,16 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||||||
"Discovery (listing, indexing) of this account by external services (search bots etc.) is allowed."
|
"Discovery (listing, indexing) of this account by external services (search bots etc.) is allowed."
|
||||||
},
|
},
|
||||||
actor_type: ActorType,
|
actor_type: ActorType,
|
||||||
birth_date: %Schema{
|
birthday: %Schema{
|
||||||
type: :string,
|
type: :string,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
description: "User's birth date",
|
description: "User's birthday",
|
||||||
format: :date
|
format: :date
|
||||||
},
|
},
|
||||||
hide_birth_date: %Schema{
|
hide_birthday: %Schema{
|
||||||
allOf: [BooleanLike],
|
allOf: [BooleanLike],
|
||||||
nullable: true,
|
nullable: true,
|
||||||
description: "User's birth date will be hidden"
|
description: "User's birthday will be hidden"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
example: %{
|
example: %{
|
||||||
@ -758,8 +758,8 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||||||
also_known_as: ["https://foo.bar/users/foo"],
|
also_known_as: ["https://foo.bar/users/foo"],
|
||||||
discoverable: false,
|
discoverable: false,
|
||||||
actor_type: "Person",
|
actor_type: "Person",
|
||||||
hide_birth_date: true,
|
hide_birthday: true,
|
||||||
birth_date: "2001-02-12"
|
birthday: "2001-02-12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -47,14 +47,14 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
|||||||
description: "whether the user allows automatically follow moved following accounts"
|
description: "whether the user allows automatically follow moved following accounts"
|
||||||
},
|
},
|
||||||
background_image: %Schema{type: :string, nullable: true, format: :uri},
|
background_image: %Schema{type: :string, nullable: true, format: :uri},
|
||||||
birth_date: %Schema{type: :string, nullable: true, format: :date},
|
birthday: %Schema{type: :string, nullable: true, format: :date},
|
||||||
chat_token: %Schema{type: :string},
|
chat_token: %Schema{type: :string},
|
||||||
is_confirmed: %Schema{
|
is_confirmed: %Schema{
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
description:
|
description:
|
||||||
"whether the user account is waiting on email confirmation to be activated"
|
"whether the user account is waiting on email confirmation to be activated"
|
||||||
},
|
},
|
||||||
hide_birth_date: %Schema{type: :boolean, nullable: true},
|
hide_birthday: %Schema{type: :boolean, nullable: true},
|
||||||
hide_favorites: %Schema{type: :boolean},
|
hide_favorites: %Schema{type: :boolean},
|
||||||
hide_followers_count: %Schema{
|
hide_followers_count: %Schema{
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
@ -205,7 +205,7 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
|||||||
"settings_store" => %{
|
"settings_store" => %{
|
||||||
"pleroma-fe" => %{}
|
"pleroma-fe" => %{}
|
||||||
},
|
},
|
||||||
"birth_date" => "2001-02-12"
|
"birthday" => "2001-02-12"
|
||||||
},
|
},
|
||||||
"source" => %{
|
"source" => %{
|
||||||
"fields" => [],
|
"fields" => [],
|
||||||
|
@ -192,7 +192,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
|||||||
:allow_following_move,
|
:allow_following_move,
|
||||||
:also_known_as,
|
:also_known_as,
|
||||||
:accepts_chat_messages,
|
:accepts_chat_messages,
|
||||||
:hide_birth_date
|
:hide_birthday
|
||||||
]
|
]
|
||||||
|> Enum.reduce(%{}, fn key, acc ->
|
|> Enum.reduce(%{}, fn key, acc ->
|
||||||
Maps.put_if_present(acc, key, params[key], &{:ok, Params.truthy_param?(&1)})
|
Maps.put_if_present(acc, key, params[key], &{:ok, Params.truthy_param?(&1)})
|
||||||
@ -220,7 +220,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
|||||||
|> Maps.put_if_present(:is_locked, params[:locked])
|
|> Maps.put_if_present(:is_locked, params[:locked])
|
||||||
# Note: param name is indeed :discoverable (not an error)
|
# Note: param name is indeed :discoverable (not an error)
|
||||||
|> Maps.put_if_present(:is_discoverable, params[:discoverable])
|
|> Maps.put_if_present(:is_discoverable, params[:discoverable])
|
||||||
|> Maps.put_if_present(:birth_date, params[:birth_date])
|
|> Maps.put_if_present(:birthday, params[:birthday])
|
||||||
|
|
||||||
# What happens here:
|
# What happens here:
|
||||||
#
|
#
|
||||||
|
@ -298,8 +298,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||||||
background_image: image_url(user.background) |> MediaProxy.url(),
|
background_image: image_url(user.background) |> MediaProxy.url(),
|
||||||
accepts_chat_messages: user.accepts_chat_messages,
|
accepts_chat_messages: user.accepts_chat_messages,
|
||||||
favicon: favicon,
|
favicon: favicon,
|
||||||
birth_date: user.birth_date,
|
birthday: user.birthday,
|
||||||
hide_birth_date: user.hide_birth_date
|
hide_birthday: user.hide_birthday
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> maybe_put_role(user, opts[:for])
|
|> maybe_put_role(user, opts[:for])
|
||||||
@ -313,7 +313,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||||||
|> 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_email_address(user, opts[:for])
|
|> maybe_put_email_address(user, opts[:for])
|
||||||
|> maybe_hide_birth_date(user, opts[:for])
|
|> maybe_hide_birthday(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
|
||||||
@ -435,21 +435,21 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||||||
|
|
||||||
defp maybe_put_email_address(data, _, _), do: data
|
defp maybe_put_email_address(data, _, _), do: data
|
||||||
|
|
||||||
defp maybe_hide_birth_date(data, %User{id: user_id}, %User{id: user_id}) do
|
defp maybe_hide_birthday(data, %User{id: user_id}, %User{id: user_id}) do
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_hide_birth_date(data, %User{hide_birth_date: true}, _) do
|
defp maybe_hide_birthday(data, %User{hide_birthday: true}, _) do
|
||||||
data
|
data
|
||||||
|> Kernel.pop_in([:pleroma, :birth_date])
|
|> Kernel.pop_in([:pleroma, :birthday])
|
||||||
|> elem(1)
|
|> elem(1)
|
||||||
|> Kernel.pop_in([:pleroma, :hide_birth_date])
|
|> Kernel.pop_in([:pleroma, :hide_birthday])
|
||||||
|> elem(1)
|
|> elem(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp maybe_hide_birth_date(data, _, _) do
|
defp maybe_hide_birthday(data, _, _) do
|
||||||
data
|
data
|
||||||
|> Kernel.pop_in([:pleroma, :hide_birth_date])
|
|> Kernel.pop_in([:pleroma, :hide_birthday])
|
||||||
|> elem(1)
|
|> elem(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
|||||||
fields_limits: fields_limits(),
|
fields_limits: fields_limits(),
|
||||||
post_formats: Config.get([:instance, :allowed_post_formats]),
|
post_formats: Config.get([:instance, :allowed_post_formats]),
|
||||||
privileged_staff: Config.get([:instance, :privileged_staff]),
|
privileged_staff: Config.get([:instance, :privileged_staff]),
|
||||||
birth_date_required: Config.get([:instance, :birth_date_required]),
|
birthday_required: Config.get([:instance, :birthday_required]),
|
||||||
birth_date_min_age: Config.get([:instance, :birth_date_min_age])
|
birthday_min_age: Config.get([:instance, :birthday_min_age])
|
||||||
},
|
},
|
||||||
stats: %{mau: Pleroma.User.active_user_count()},
|
stats: %{mau: Pleroma.User.active_user_count()},
|
||||||
vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
|
vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
|
||||||
|
@ -20,7 +20,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
|
|||||||
|> Map.put(:name, Map.get(params, :fullname, params[:username]))
|
|> Map.put(:name, Map.get(params, :fullname, params[:username]))
|
||||||
|> Map.put(:password_confirmation, params[:password])
|
|> Map.put(:password_confirmation, params[:password])
|
||||||
|> Map.put(:registration_reason, params[:reason])
|
|> Map.put(:registration_reason, params[:reason])
|
||||||
|> Map.put(:birth_date, params[:birth_date])
|
|> Map.put(:birthday, params[:birthday])
|
||||||
|
|
||||||
if Pleroma.Config.get([:instance, :registrations_open]) do
|
if Pleroma.Config.get([:instance, :registrations_open]) do
|
||||||
create_user(params, opts)
|
create_user(params, opts)
|
||||||
|
@ -3,8 +3,8 @@ defmodule Pleroma.Repo.Migrations.AddBirthDateToUsers do
|
|||||||
|
|
||||||
def change do
|
def change do
|
||||||
alter table(:users) do
|
alter table(:users) do
|
||||||
add_if_not_exists(:birth_date, :date)
|
add_if_not_exists(:birthday, :date)
|
||||||
add_if_not_exists(:hide_birth_date, :boolean, default: false, null: false)
|
add_if_not_exists(:hide_birthday, :boolean, default: false, null: false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -755,7 +755,7 @@ defmodule Pleroma.UserTest do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "user registration, with :birth_date_required and :birth_date_min_age" do
|
describe "user registration, with :birthday_required and :birthday_min_age" do
|
||||||
@full_user_data %{
|
@full_user_data %{
|
||||||
bio: "A guy",
|
bio: "A guy",
|
||||||
name: "my name",
|
name: "my name",
|
||||||
@ -766,17 +766,17 @@ defmodule Pleroma.UserTest do
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
clear_config([:instance, :birth_date_required], true)
|
clear_config([:instance, :birthday_required], true)
|
||||||
clear_config([:instance, :birth_date_min_age], 18 * 365)
|
clear_config([:instance, :birthday_min_age], 18 * 365)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it passes when correct birth date is provided" do
|
test "it passes when correct birth date is provided" do
|
||||||
today = Date.utc_today()
|
today = Date.utc_today()
|
||||||
birth_date = Date.add(today, -19 * 365)
|
birthday = Date.add(today, -19 * 365)
|
||||||
|
|
||||||
params =
|
params =
|
||||||
@full_user_data
|
@full_user_data
|
||||||
|> Map.put(:birth_date, birth_date)
|
|> Map.put(:birthday, birthday)
|
||||||
|
|
||||||
changeset = User.register_changeset(%User{}, params)
|
changeset = User.register_changeset(%User{}, params)
|
||||||
|
|
||||||
@ -791,11 +791,11 @@ defmodule Pleroma.UserTest do
|
|||||||
|
|
||||||
test "it fails when provided invalid birth date" do
|
test "it fails when provided invalid birth date" do
|
||||||
today = Date.utc_today()
|
today = Date.utc_today()
|
||||||
birth_date = Date.add(today, -17 * 365)
|
birthday = Date.add(today, -17 * 365)
|
||||||
|
|
||||||
params =
|
params =
|
||||||
@full_user_data
|
@full_user_data
|
||||||
|> Map.put(:birth_date, birth_date)
|
|> Map.put(:birthday, birthday)
|
||||||
|
|
||||||
changeset = User.register_changeset(%User{}, params)
|
changeset = User.register_changeset(%User{}, params)
|
||||||
|
|
||||||
|
@ -1588,8 +1588,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||||||
|
|
||||||
describe "create account with required birth date" do
|
describe "create account with required birth date" do
|
||||||
setup %{conn: conn} do
|
setup %{conn: conn} do
|
||||||
clear_config([:instance, :birth_date_required], true)
|
clear_config([:instance, :birthday_required], true)
|
||||||
clear_config([:instance, :birth_date_min_age], 18 * 365)
|
clear_config([:instance, :birthday_min_age], 18 * 365)
|
||||||
|
|
||||||
app_token = insert(:oauth_token, user: nil)
|
app_token = insert(:oauth_token, user: nil)
|
||||||
|
|
||||||
@ -1602,7 +1602,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
test "creates an account if provided valid birth date", %{conn: conn} do
|
test "creates an account if provided valid birth date", %{conn: conn} do
|
||||||
birth_date =
|
birthday =
|
||||||
Date.utc_today()
|
Date.utc_today()
|
||||||
|> Date.add(-19 * 365)
|
|> Date.add(-19 * 365)
|
||||||
|> Date.to_string()
|
|> Date.to_string()
|
||||||
@ -1612,7 +1612,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||||||
email: "mkljczk@example.org",
|
email: "mkljczk@example.org",
|
||||||
password: "dupa.8",
|
password: "dupa.8",
|
||||||
agreement: true,
|
agreement: true,
|
||||||
birth_date: birth_date
|
birthday: birthday
|
||||||
}
|
}
|
||||||
|
|
||||||
res =
|
res =
|
||||||
@ -1635,7 +1635,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||||||
|> post("/api/v1/accounts", params)
|
|> post("/api/v1/accounts", params)
|
||||||
|
|
||||||
assert json_response_and_validate_schema(res, 400) == %{
|
assert json_response_and_validate_schema(res, 400) == %{
|
||||||
"error" => "{\"birth_date\":[\"can't be blank\"]}"
|
"error" => "{\"birthday\":[\"can't be blank\"]}"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -370,24 +370,24 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "updates birth date", %{conn: conn, user: user} do
|
test "updates birth date", %{conn: conn} do
|
||||||
res =
|
res =
|
||||||
patch(conn, "/api/v1/accounts/update_credentials", %{
|
patch(conn, "/api/v1/accounts/update_credentials", %{
|
||||||
"birth_date" => "2001-02-12"
|
"birthday" => "2001-02-12"
|
||||||
})
|
})
|
||||||
|
|
||||||
assert user_data = json_response_and_validate_schema(res, 200)
|
assert user_data = json_response_and_validate_schema(res, 200)
|
||||||
assert user_data["pleroma"]["birth_date"] == "2001-02-12"
|
assert user_data["pleroma"]["birthday"] == "2001-02-12"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "updates the user's hide_birth_date status", %{conn: conn} do
|
test "updates the user's hide_birthday status", %{conn: conn} do
|
||||||
res =
|
res =
|
||||||
patch(conn, "/api/v1/accounts/update_credentials", %{
|
patch(conn, "/api/v1/accounts/update_credentials", %{
|
||||||
"hide_birth_date" => true
|
"hide_birthday" => true
|
||||||
})
|
})
|
||||||
|
|
||||||
assert user_data = json_response_and_validate_schema(res, 200)
|
assert user_data = json_response_and_validate_schema(res, 200)
|
||||||
assert user_data["pleroma"]["hide_birth_date"] == true
|
assert user_data["pleroma"]["hide_birthday"] == true
|
||||||
end
|
end
|
||||||
|
|
||||||
test "emojis in fields labels", %{conn: conn} do
|
test "emojis in fields labels", %{conn: conn} do
|
||||||
|
@ -79,7 +79,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||||||
ap_id: user.ap_id,
|
ap_id: user.ap_id,
|
||||||
also_known_as: ["https://shitposter.zone/users/shp"],
|
also_known_as: ["https://shitposter.zone/users/shp"],
|
||||||
background_image: "https://example.com/images/asuka_hospital.png",
|
background_image: "https://example.com/images/asuka_hospital.png",
|
||||||
birth_date: nil,
|
birthday: nil,
|
||||||
favicon: nil,
|
favicon: nil,
|
||||||
is_confirmed: true,
|
is_confirmed: true,
|
||||||
tags: [],
|
tags: [],
|
||||||
@ -182,7 +182,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||||||
ap_id: user.ap_id,
|
ap_id: user.ap_id,
|
||||||
also_known_as: [],
|
also_known_as: [],
|
||||||
background_image: nil,
|
background_image: nil,
|
||||||
birth_date: nil,
|
birthday: nil,
|
||||||
favicon: nil,
|
favicon: nil,
|
||||||
is_confirmed: true,
|
is_confirmed: true,
|
||||||
tags: [],
|
tags: [],
|
||||||
|
@ -312,12 +312,12 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||||||
%{id: id1} =
|
%{id: id1} =
|
||||||
user1 =
|
user1 =
|
||||||
insert(:user, %{
|
insert(:user, %{
|
||||||
birth_date: "2001-02-12"
|
birthday: "2001-02-12"
|
||||||
})
|
})
|
||||||
|
|
||||||
user2 =
|
user2 =
|
||||||
insert(:user, %{
|
insert(:user, %{
|
||||||
birth_date: "2001-02-14"
|
birthday: "2001-02-14"
|
||||||
})
|
})
|
||||||
|
|
||||||
user3 = insert(:user)
|
user3 = insert(:user)
|
||||||
@ -337,15 +337,15 @@ defmodule Pleroma.Web.PleromaAPI.AccountControllerTest do
|
|||||||
|
|
||||||
user1 =
|
user1 =
|
||||||
insert(:user, %{
|
insert(:user, %{
|
||||||
birth_date: "2001-02-12",
|
birthday: "2001-02-12",
|
||||||
hide_birth_date: true
|
hide_birthday: true
|
||||||
})
|
})
|
||||||
|
|
||||||
%{id: id2} =
|
%{id: id2} =
|
||||||
user2 =
|
user2 =
|
||||||
insert(:user, %{
|
insert(:user, %{
|
||||||
birth_date: "2001-02-12",
|
birthday: "2001-02-12",
|
||||||
hide_birth_date: false
|
hide_birthday: false
|
||||||
})
|
})
|
||||||
|
|
||||||
CommonAPI.follow(user, user1)
|
CommonAPI.follow(user, user1)
|
||||||
|
Loading…
Reference in New Issue
Block a user