Location: user_location_length

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2022-03-14 22:51:04 +01:00
parent 4c56e0fceb
commit d76bfd4e89
4 changed files with 14 additions and 0 deletions

View file

@ -234,6 +234,7 @@
limit_to_local_content: :unauthenticated,
user_bio_length: 5000,
user_name_length: 100,
user_location_length: 50,
max_account_fields: 10,
max_remote_account_fields: 20,
account_field_name_length: 512,

View file

@ -824,6 +824,14 @@
100
]
},
%{
key: :user_location_length,
type: :integer,
description: "A user location maximum length. Default: 50.",
suggestions: [
50
]
},
%{
key: :skip_thread_containment,
type: :boolean,

View file

@ -53,6 +53,7 @@ To add configuration to your config file, you can copy it from the base config.
* `remote_post_retention_days`: The default amount of days to retain remote posts when pruning the database.
* `user_bio_length`: A user bio maximum length (default: `5000`).
* `user_name_length`: A user name maximum length (default: `100`).
* `user_name_length`: A user location maximum length (default: `50`).
* `skip_thread_containment`: Skip filter out broken threads. The default is `false`.
* `limit_to_local_content`: Limit unauthenticated users to search for local statutes and users only. Possible values: `:unauthenticated`, `:all` and `false`. The default is `:unauthenticated`.
* `max_account_fields`: The maximum number of custom fields in the user profile (default: `10`).

View file

@ -426,6 +426,7 @@ defp fix_follower_address(params), do: params
def remote_user_changeset(struct \\ %User{local: false}, params) do
bio_limit = Config.get([:instance, :user_bio_length], 5000)
name_limit = Config.get([:instance, :user_name_length], 100)
location_limit = Config.get([:instance, :user_location_length], 50)
name =
case params[:name] do
@ -487,6 +488,7 @@ def remote_user_changeset(struct \\ %User{local: false}, params) do
|> validate_format(:nickname, @email_regex)
|> validate_length(:bio, max: bio_limit)
|> validate_length(:name, max: name_limit)
|> validate_length(:location, max: location_limit)
|> validate_fields(true)
|> validate_non_local()
end
@ -505,6 +507,7 @@ defp validate_non_local(cng) do
def update_changeset(struct, params \\ %{}) do
bio_limit = Config.get([:instance, :user_bio_length], 5000)
name_limit = Config.get([:instance, :user_name_length], 100)
location_limit = Config.get([:instance, :user_location_length], 50)
struct
|> cast(
@ -549,6 +552,7 @@ def update_changeset(struct, params \\ %{}) do
|> unique_constraint(:nickname)
|> validate_format(:nickname, local_nickname_regex())
|> validate_length(:bio, max: bio_limit)
|> validate_length(:location, max: location_limit)
|> validate_length(:name, min: 1, max: name_limit)
|> validate_inclusion(:actor_type, ["Person", "Service"])
|> put_fields()