From 756764266cb5319a775845635b91b04aacf16aae Mon Sep 17 00:00:00 2001 From: lain Date: Sun, 18 Nov 2018 18:27:04 +0100 Subject: [PATCH] Formatting. --- lib/pleroma/user.ex | 30 +++++++++++++++++++----------- lib/pleroma/user/info.ex | 27 ++++++++++++++------------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 5603d1f5f..7b0edee75 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -23,7 +23,7 @@ defmodule Pleroma.User do field(:search_distance, :float, virtual: true) field(:last_refreshed_at, :naive_datetime) has_many(:notifications, Notification) - embeds_one :info, Pleroma.User.Info + embeds_one(:info, Pleroma.User.Info) timestamps() end @@ -412,16 +412,20 @@ defmodule Pleroma.User do def increase_note_count(%User{} = user) do info_cng = User.Info.add_to_note_count(user.info, 1) - cng = change(user) - |> put_embed(:info, info_cng) + + cng = + change(user) + |> put_embed(:info, info_cng) update_and_set_cache(cng) end def decrease_note_count(%User{} = user) do info_cng = User.Info.add_to_note_count(user.info, -1) - cng = change(user) - |> put_embed(:info, info_cng) + + cng = + change(user) + |> put_embed(:info, info_cng) update_and_set_cache(cng) end @@ -454,11 +458,13 @@ defmodule Pleroma.User do follower_count = Repo.one(follower_count_query) - info_cng = user.info - |> User.Info.set_follower_count(follower_count) + info_cng = + user.info + |> User.Info.set_follower_count(follower_count) - cng = change(user) - |> put_embed(:info, info_cng) + cng = + change(user) + |> put_embed(:info, info_cng) update_and_set_cache(cng) end @@ -613,8 +619,10 @@ defmodule Pleroma.User do def deactivate(%User{} = user, status \\ true) do info_cng = User.Info.set_activation_status(user.info, status) - cng = change(user) - |> put_embed(:info, info_cng) + + cng = + change(user) + |> put_embed(:info, info_cng) update_and_set_cache(cng) end diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 49b52d5da..da5e26ebd 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -3,18 +3,19 @@ defmodule Pleroma.User.Info do import Ecto.Changeset embedded_schema do - field :banner, :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 :default_scope, :string, default: "public" - field :blocks, {:array, :string}, default: [] - field :domain_blocks, {:array, :string}, default: [] - field :deactivated, :boolean, default: false - field :no_rich_text, :boolean, default: false - field :ap_enabled, :boolean, default: false - field :keys, :map, default: %{} + field(:banner, :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(:default_scope, :string, default: "public") + field(:blocks, {:array, :string}, default: []) + field(:domain_blocks, {:array, :string}, default: []) + field(:deactivated, :boolean, default: false) + field(:no_rich_text, :boolean, default: false) + field(:ap_enabled, :boolean, default: false) + field(:is_moderator, :boolean, default: false) + field(:keys, :map, default: %{}) end def set_activation_status(info, deactivated) do @@ -26,7 +27,7 @@ defmodule Pleroma.User.Info do end def add_to_note_count(info, number) do - params = %{note_count: Enum.max([0, info.note_count + number])} + params = %{note_count: Enum.max([0, number])} info |> cast(params, [:note_count])