X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fuser%2Finfo.ex;h=71848d91ed6df591da9dbc4a74ef98cd3dd90c05;hb=33e3a7ba7dab750f2a5f85e22b0e44251ec308d2;hp=2846459340a3f94b80788a0c0e2a003259a4111f;hpb=93f2dc19d99375356d986651490cb9f496f18928;p=akkoma diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 284645934..71848d91e 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -1,14 +1,20 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.User.Info do use Ecto.Schema import Ecto.Changeset embedded_schema do field(:banner, :map, default: %{}) - field(:background, :string, default: nil) + field(:background, :map, default: %{}) field(:source_data, :map, default: %{}) field(:note_count, :integer, default: 0) field(:follower_count, :integer, default: 0) field(:locked, :boolean, default: false) + field(:confirmation_pending, :boolean, default: false) + field(:confirmation_token, :string, default: nil) field(:default_scope, :string, default: "public") field(:blocks, {:array, :string}, default: []) field(:domain_blocks, {:array, :string}, default: []) @@ -23,6 +29,8 @@ defmodule Pleroma.User.Info do field(:uri, :string, default: nil) field(:topic, :string, default: nil) field(:hub, :string, default: nil) + field(:salmon, :string, default: nil) + field(:hide_network, :boolean, default: false) # Found in the wild # ap_id -> Where is this used? @@ -30,13 +38,11 @@ defmodule Pleroma.User.Info do # avatar -> Where is this used? # fqn -> Where is this used? # host -> Where is this used? - # name -> Where is this used? - # nickname -> Where is this used? - # salmon -> Where is this used? # subject _> Where is this used? - # subscribe_address -> Where is this used? end + def superuser?(info), do: info.is_admin || info.is_moderator + def set_activation_status(info, deactivated) do params = %{deactivated: deactivated} @@ -115,7 +121,8 @@ defmodule Pleroma.User.Info do :magic_key, :uri, :hub, - :topic + :topic, + :salmon ]) end @@ -136,10 +143,30 @@ defmodule Pleroma.User.Info do :locked, :no_rich_text, :default_scope, - :banner + :banner, + :hide_network, + :background ]) end + def confirmation_changeset(info, :confirmed) do + confirmation_changeset(info, %{ + confirmation_pending: false, + confirmation_token: nil + }) + end + + def confirmation_changeset(info, :unconfirmed) do + confirmation_changeset(info, %{ + confirmation_pending: true, + confirmation_token: :crypto.strong_rand_bytes(32) |> Base.url_encode64() + }) + end + + def confirmation_changeset(info, params) do + cast(info, params, [:confirmation_pending, :confirmation_token]) + end + def mastodon_profile_update(info, params) do info |> cast(params, [ @@ -148,6 +175,14 @@ defmodule Pleroma.User.Info do ]) end + def mastodon_settings_update(info, settings) do + params = %{settings: settings} + + info + |> cast(params, [:settings]) + |> validate_required([:settings]) + end + def set_source_data(info, source_data) do params = %{source_data: source_data}