User: On registration, set accepts_chat_messages to true.

This commit is contained in:
lain 2020-07-03 12:47:05 +02:00
parent 8ad166e8e3
commit 98bfdba108
2 changed files with 13 additions and 1 deletions

View file

@ -138,6 +138,7 @@ defmodule Pleroma.User do
field(:also_known_as, {:array, :string}, default: []) field(:also_known_as, {:array, :string}, default: [])
field(:inbox, :string) field(:inbox, :string)
field(:shared_inbox, :string) field(:shared_inbox, :string)
field(:accepts_chat_messages, :boolean, default: false)
embeds_one( embeds_one(
:notification_settings, :notification_settings,
@ -623,6 +624,7 @@ def force_password_reset(user), do: update_password_reset_pending(user, true)
def register_changeset(struct, params \\ %{}, opts \\ []) do def register_changeset(struct, params \\ %{}, opts \\ []) do
bio_limit = Pleroma.Config.get([:instance, :user_bio_length], 5000) bio_limit = Pleroma.Config.get([:instance, :user_bio_length], 5000)
name_limit = Pleroma.Config.get([:instance, :user_name_length], 100) name_limit = Pleroma.Config.get([:instance, :user_name_length], 100)
params = Map.put_new(params, :accepts_chat_messages, true)
need_confirmation? = need_confirmation? =
if is_nil(opts[:need_confirmation]) do if is_nil(opts[:need_confirmation]) do
@ -641,7 +643,8 @@ def register_changeset(struct, params \\ %{}, opts \\ []) do
:nickname, :nickname,
:password, :password,
:password_confirmation, :password_confirmation,
:emoji :emoji,
:accepts_chat_messages
]) ])
|> validate_required([:name, :nickname, :password, :password_confirmation]) |> validate_required([:name, :nickname, :password, :password_confirmation])
|> validate_confirmation(:password) |> validate_confirmation(:password)

View file

@ -486,6 +486,15 @@ test "it sets the password_hash and ap_id" do
} }
setup do: clear_config([:instance, :account_activation_required], true) setup do: clear_config([:instance, :account_activation_required], true)
test "it sets the 'accepts_chat_messages' set to true" do
changeset = User.register_changeset(%User{}, @full_user_data)
assert changeset.valid?
{:ok, user} = Repo.insert(changeset)
assert user.accepts_chat_messages
end
test "it creates unconfirmed user" do test "it creates unconfirmed user" do
changeset = User.register_changeset(%User{}, @full_user_data) changeset = User.register_changeset(%User{}, @full_user_data)
assert changeset.valid? assert changeset.valid?