Format code, expose instance configuration related to birth dates
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
b108b05650
commit
397f67fef8
7 changed files with 16 additions and 12 deletions
|
@ -966,7 +966,8 @@ config :pleroma, :config_description, [
|
||||||
%{
|
%{
|
||||||
key: :birth_date_min_age,
|
key: :birth_date_min_age,
|
||||||
type: :integer,
|
type: :integer,
|
||||||
description: "Min age for users to create account. Only makes sense if birth date is required."
|
description:
|
||||||
|
"Min age for users to create account. Only makes sense if birth date is required."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -157,7 +157,6 @@ defmodule Pleroma.User do
|
||||||
field(:birth_date, :date)
|
field(:birth_date, :date)
|
||||||
field(:hide_birth_date, :boolean, default: false)
|
field(:hide_birth_date, :boolean, default: false)
|
||||||
|
|
||||||
|
|
||||||
embeds_one(
|
embeds_one(
|
||||||
:notification_settings,
|
:notification_settings,
|
||||||
Pleroma.User.NotificationSetting,
|
Pleroma.User.NotificationSetting,
|
||||||
|
@ -799,7 +798,7 @@ defmodule Pleroma.User do
|
||||||
valid? =
|
valid? =
|
||||||
Date.utc_today()
|
Date.utc_today()
|
||||||
|> Date.diff(birth_date) >=
|
|> Date.diff(birth_date) >=
|
||||||
Config.get([:instance, :birth_date_min_age])
|
Config.get([:instance, :birth_date_min_age])
|
||||||
|
|
||||||
if valid?, do: [], else: [birth_date: "Invalid birth date"]
|
if valid?, do: [], else: [birth_date: "Invalid birth date"]
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -549,7 +549,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
||||||
nullable: true,
|
nullable: true,
|
||||||
description: "User's birth date",
|
description: "User's birth date",
|
||||||
format: :date
|
format: :date
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
example: %{
|
example: %{
|
||||||
"username" => "cofe",
|
"username" => "cofe",
|
||||||
|
|
|
@ -47,7 +47,7 @@ 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, format: :date},
|
birth_date: %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,
|
||||||
|
|
|
@ -46,7 +46,9 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
||||||
federation: federation(),
|
federation: federation(),
|
||||||
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]),
|
||||||
|
birth_date_min_age: Config.get([:instance, :birth_date_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)
|
||||||
|
|
|
@ -149,11 +149,11 @@ defmodule Pleroma.Web.PleromaAPI.AccountController do
|
||||||
User.Query.build(%{friends: user, deactivated: false, birth_day: day, birth_month: month})
|
User.Query.build(%{friends: user, deactivated: false, birth_day: day, birth_month: month})
|
||||||
|> Pleroma.Repo.all()
|
|> Pleroma.Repo.all()
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> render("index.json",
|
|> render("index.json",
|
||||||
for: user,
|
for: user,
|
||||||
users: birthdays,
|
users: birthdays,
|
||||||
as: :user
|
as: :user
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,6 +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,
|
||||||
favicon: nil,
|
favicon: nil,
|
||||||
is_confirmed: true,
|
is_confirmed: true,
|
||||||
tags: [],
|
tags: [],
|
||||||
|
@ -181,6 +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,
|
||||||
favicon: nil,
|
favicon: nil,
|
||||||
is_confirmed: true,
|
is_confirmed: true,
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|
Loading…
Reference in a new issue