Merge branch 'feature/support-bot-field-in-update-credentials' into 'develop'

Support 'bot' field in account update_credentials

Closes #1600 and #1467

See merge request pleroma/pleroma!2662
This commit is contained in:
lain 2020-06-20 09:57:12 +00:00
commit 31761340fe
5 changed files with 73 additions and 1 deletions

View file

@ -465,6 +465,7 @@ defmodule Pleroma.User do
|> validate_format(:nickname, local_nickname_regex())
|> validate_length(:bio, max: bio_limit)
|> validate_length(:name, min: 1, max: name_limit)
|> validate_inclusion(:actor_type, ["Person", "Service"])
|> put_fields()
|> put_emoji()
|> put_change_if_present(:bio, &{:ok, parse_bio(&1, struct)})

View file

@ -177,6 +177,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|> Maps.put_if_present(:pleroma_settings_store, params[:pleroma_settings_store])
|> Maps.put_if_present(:default_scope, params[:default_scope])
|> Maps.put_if_present(:default_scope, params["source"]["privacy"])
|> Maps.put_if_present(:actor_type, params[:bot], fn bot ->
if bot, do: {:ok, "Service"}, else: {:ok, "Person"}
end)
|> Maps.put_if_present(:actor_type, params[:actor_type])
changeset = User.update_changeset(user, user_params)

View file

@ -179,7 +179,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
0
end
bot = user.actor_type in ["Application", "Service"]
bot = user.actor_type == "Service"
emojis =
Enum.map(user.emoji, fn {shortcode, raw_url} ->