Feature/896 toggling confirmation
This commit is contained in:
parent
a2771869a3
commit
73ae58fdfa
6 changed files with 80 additions and 2 deletions
|
|
@ -1378,4 +1378,17 @@ defmodule Pleroma.User do
|
|||
def showing_reblogs?(%User{} = user, %User{} = target) do
|
||||
target.ap_id not in user.info.muted_reblogs
|
||||
end
|
||||
|
||||
@spec toggle_confirmation(User.t()) :: {:ok, User.t()} | {:error, Changeset.t()}
|
||||
def toggle_confirmation(%User{} = user) do
|
||||
need_confirmation? = !user.info.confirmation_pending
|
||||
|
||||
info_changeset =
|
||||
User.Info.confirmation_changeset(user.info, need_confirmation: need_confirmation?)
|
||||
|
||||
user
|
||||
|> change()
|
||||
|> put_embed(:info, info_changeset)
|
||||
|> update_and_set_cache()
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ defmodule Pleroma.User.Info do
|
|||
])
|
||||
end
|
||||
|
||||
@spec confirmation_changeset(Info.t(), keyword()) :: Ecto.Changerset.t()
|
||||
@spec confirmation_changeset(Info.t(), keyword()) :: Changeset.t()
|
||||
def confirmation_changeset(info, opts) do
|
||||
need_confirmation? = Keyword.get(opts, :need_confirmation)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue