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
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
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
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
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
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])