truncate fields for remote users instead

This commit is contained in:
Sadposter 2019-09-02 12:15:21 +01:00
commit 35ef470d00
2 changed files with 20 additions and 4 deletions

View file

@ -242,6 +242,7 @@ defmodule Pleroma.User.Info do
end
def remote_user_creation(info, params) do
params = Map.put(params, "fields", Enum.map(params["fields"], &truncate_field/1))
info
|> cast(params, [
:ap_enabled,
@ -326,6 +327,12 @@ defmodule Pleroma.User.Info do
defp valid_field?(_), do: false
defp truncate_field(%{"name" => name, "value" => value}) do
{name, _chopped} = String.split_at(name, Pleroma.Config.get([:instance, :account_field_name_length], 255))
{value, _chopped} = String.split_at(value, Pleroma.Config.get([:instance, :account_field_value_length], 255))
%{"name" => name, "value" => value}
end
@spec confirmation_changeset(Info.t(), keyword()) :: Changeset.t()
def confirmation_changeset(info, opts) do
need_confirmation? = Keyword.get(opts, :need_confirmation)