diff options
author | rinpatch <rinpatch@sdf.org> | 2019-05-16 13:23:42 +0000 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2019-05-16 13:23:42 +0000 |
commit | 103f205097e73dd5bcc1b302e0d27a180c4b0e15 (patch) | |
tree | 568b4358d1c41516ac94c1173504d9ea77734444 /lib/pleroma | |
parent | a2771869a3b9851edea4961314c7944f3823f754 (diff) | |
parent | 73ae58fdfaf0b9dc9630929b0b84ae3b6083684a (diff) | |
download | pleroma-103f205097e73dd5bcc1b302e0d27a180c4b0e15.tar.gz |
Merge branch 'feature/896-toggling-confirmation' into 'develop'
Feature/896 toggling confirmation
Closes #896
See merge request pleroma/pleroma!1165
Diffstat (limited to 'lib/pleroma')
-rw-r--r-- | lib/pleroma/user.ex | 13 | ||||
-rw-r--r-- | lib/pleroma/user/info.ex | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index c6a562a61..1aa966dfc 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -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 diff --git a/lib/pleroma/user/info.ex b/lib/pleroma/user/info.ex index 5a50ee639..5f0cefc00 100644 --- a/lib/pleroma/user/info.ex +++ b/lib/pleroma/user/info.ex @@ -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) |