field(:following_count, :integer, default: nil)
field(:locked, :boolean, default: false)
field(:confirmation_pending, :boolean, default: false)
+ field(:password_reset_pending, :boolean, default: false)
field(:confirmation_token, :string, default: nil)
field(:default_scope, :string, default: "public")
field(:blocks, {:array, :string}, default: [])
field(:settings, :map, default: nil)
field(:magic_key, :string, default: nil)
field(:uri, :string, default: nil)
- field(:topic, :string, default: nil)
- field(:hub, :string, default: nil)
- field(:salmon, :string, default: nil)
+ field(:hide_followers_count, :boolean, default: false)
+ field(:hide_follows_count, :boolean, default: false)
field(:hide_followers, :boolean, default: false)
field(:hide_follows, :boolean, default: false)
field(:hide_favorites, :boolean, default: true)
+ field(:unread_conversation_count, :integer, default: 0)
field(:pinned_activities, {:array, :string}, default: [])
field(:email_notifications, :map, default: %{"digest" => false})
field(:mascot, :map, default: nil)
field(:pleroma_settings_store, :map, default: %{})
field(:fields, {:array, :map}, default: nil)
field(:raw_fields, {:array, :map}, default: [])
+ field(:discoverable, :boolean, default: false)
+ field(:invisible, :boolean, default: false)
field(:notification_settings, :map,
default: %{
|> validate_required([:deactivated])
end
+ def set_password_reset_pending(info, pending) do
+ params = %{password_reset_pending: pending}
+
+ info
+ |> cast(params, [:password_reset_pending])
+ |> validate_required([:password_reset_pending])
+ end
+
def update_notification_settings(info, settings) do
settings =
settings
|> validate_required([:subscribers])
end
- @spec add_to_mutes(Info.t(), String.t()) :: Changeset.t()
- def add_to_mutes(info, muted) do
- set_mutes(info, Enum.uniq([muted | info.mutes]))
- end
-
- @spec add_to_muted_notifications(Changeset.t(), Info.t(), String.t(), boolean()) ::
- Changeset.t()
- def add_to_muted_notifications(changeset, info, muted, notifications?) do
- set_notification_mutes(
- changeset,
+ @spec add_to_mutes(Info.t(), String.t(), boolean()) :: Changeset.t()
+ def add_to_mutes(info, muted, notifications?) do
+ info
+ |> set_mutes(Enum.uniq([muted | info.mutes]))
+ |> set_notification_mutes(
Enum.uniq([muted | info.muted_notifications]),
notifications?
)
@spec remove_from_mutes(Info.t(), String.t()) :: Changeset.t()
def remove_from_mutes(info, muted) do
- set_mutes(info, List.delete(info.mutes, muted))
- end
-
- @spec remove_from_muted_notifications(Changeset.t(), Info.t(), String.t()) :: Changeset.t()
- def remove_from_muted_notifications(changeset, info, muted) do
- set_notification_mutes(changeset, List.delete(info.muted_notifications, muted), true)
+ info
+ |> set_mutes(List.delete(info.mutes, muted))
+ |> set_notification_mutes(List.delete(info.muted_notifications, muted), true)
end
def add_to_block(info, blocked) do
end
def remote_user_creation(info, params) do
+ params =
+ if Map.has_key?(params, :fields) do
+ Map.put(params, :fields, Enum.map(params[:fields], &truncate_field/1))
+ else
+ params
+ end
+
info
|> cast(params, [
:ap_enabled,
:locked,
:magic_key,
:uri,
- :hub,
- :topic,
- :salmon,
:hide_followers,
:hide_follows,
+ :hide_followers_count,
+ :hide_follows_count,
:follower_count,
:fields,
- :following_count
+ :following_count,
+ :discoverable
])
|> validate_fields(true)
end
:following_count,
:hide_follows,
:fields,
- :hide_followers
+ :hide_followers,
+ :discoverable,
+ :hide_followers_count,
+ :hide_follows_count
])
|> validate_fields(remote?)
end
:banner,
:hide_follows,
:hide_followers,
+ :hide_followers_count,
+ :hide_follows_count,
:hide_favorites,
:background,
:show_role,
:skip_thread_containment,
:fields,
:raw_fields,
- :pleroma_settings_store
+ :pleroma_settings_store,
+ :discoverable
])
|> validate_fields()
end
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)
|> validate_required([:source_data])
end
+ def set_invisible(info, invisible) do
+ params = %{invisible: invisible}
+
+ info
+ |> cast(params, [:invisible])
+ |> validate_required([:invisible])
+ end
+
def admin_api_update(info, params) do
info
|> cast(params, [
:hide_followers,
:hide_follows,
:follower_count,
- :following_count
+ :following_count,
+ :hide_followers_count,
+ :hide_follows_count
])
end
end