From ec42b639a347903ea5c0e5f9b365f1d5ea9e624f Mon Sep 17 00:00:00 2001 From: Sadposter Date: Sun, 14 Apr 2019 15:46:54 +0100 Subject: [PATCH 1/4] fix pattern match on user registration deliver_async will return a single atom --- lib/pleroma/user.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 4a41a15c7..3ab7bd742 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -270,7 +270,7 @@ def register(%Ecto.Changeset{} = changeset) do with {:ok, user} <- Repo.insert(changeset), {:ok, user} <- autofollow_users(user), {:ok, _} <- Pleroma.User.WelcomeMessage.post_welcome_message_to_user(user), - {:ok, _} <- try_send_confirmation_email(user) do + :ok <- try_send_confirmation_email(user) do {:ok, user} end end From 5e4555775189ef8c40968769a90602cb10fd5324 Mon Sep 17 00:00:00 2001 From: Sadposter Date: Sun, 14 Apr 2019 16:01:48 +0100 Subject: [PATCH 2/4] Always return {atom, _} from try_send_confirmation --- lib/pleroma/user.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 3ab7bd742..78eb29ddd 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -270,7 +270,7 @@ def register(%Ecto.Changeset{} = changeset) do with {:ok, user} <- Repo.insert(changeset), {:ok, user} <- autofollow_users(user), {:ok, _} <- Pleroma.User.WelcomeMessage.post_welcome_message_to_user(user), - :ok <- try_send_confirmation_email(user) do + {:ok, _} <- try_send_confirmation_email(user) do {:ok, user} end end @@ -281,6 +281,8 @@ def try_send_confirmation_email(%User{} = user) do user |> Pleroma.Emails.UserEmail.account_confirmation_email() |> Pleroma.Emails.Mailer.deliver_async() + + {:ok, :enqueued} else {:ok, :noop} end From 16d8c8b33b654b88e5e934832d5e26eb7152633e Mon Sep 17 00:00:00 2001 From: Sadposter Date: Sun, 14 Apr 2019 16:05:26 +0100 Subject: [PATCH 3/4] Assert on the success of enqueue before returning --- lib/pleroma/user.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index 78eb29ddd..f3ea5289e 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -278,9 +278,10 @@ def register(%Ecto.Changeset{} = changeset) do def try_send_confirmation_email(%User{} = user) do if user.info.confirmation_pending && Pleroma.Config.get([:instance, :account_activation_required]) do - user - |> Pleroma.Emails.UserEmail.account_confirmation_email() - |> Pleroma.Emails.Mailer.deliver_async() + :ok = + user + |> Pleroma.Emails.UserEmail.account_confirmation_email() + |> Pleroma.Emails.Mailer.deliver_async() {:ok, :enqueued} else From e513504e8840f5a64ae4ba795b158a102e4e8843 Mon Sep 17 00:00:00 2001 From: Sadposter Date: Sun, 14 Apr 2019 16:12:54 +0100 Subject: [PATCH 4/4] Revert "Assert on the success of enqueue before returning" This reverts commit 16d8c8b33b654b88e5e934832d5e26eb7152633e. Because it breaks everything --- lib/pleroma/user.ex | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index f3ea5289e..78eb29ddd 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -278,10 +278,9 @@ def register(%Ecto.Changeset{} = changeset) do def try_send_confirmation_email(%User{} = user) do if user.info.confirmation_pending && Pleroma.Config.get([:instance, :account_activation_required]) do - :ok = - user - |> Pleroma.Emails.UserEmail.account_confirmation_email() - |> Pleroma.Emails.Mailer.deliver_async() + user + |> Pleroma.Emails.UserEmail.account_confirmation_email() + |> Pleroma.Emails.Mailer.deliver_async() {:ok, :enqueued} else