-
-
Notifications
You must be signed in to change notification settings - Fork 104
Mark emails as unreachable #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark emails as unreachable #393
Conversation
Hey @henriqueberlesi, thanks you for taking on this issue! I’ll take a closer look in the coming days 😊 |
lib/keila/mailings/worker.ex
Outdated
@@ -106,19 +107,70 @@ defmodule Keila.Mailings.Worker do | |||
# Email was already sent | |||
defp handle_result({:error, :already_sent}, _), do: {:cancel, :already_sent} | |||
|
|||
# Email is invalid | |||
defp handle_result({:error, :invalid_email}, recipient) do | |||
Multi.new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you refactor this to just
Repo.transaction(fn ->
recipient
|> set_recipient_failed_query()
|> Repo.update_all([])
# ...
end)
We don’t really use Ecto.Multi anywhere else in the codebase and so I think overall this is easier to read 😊
Sorry it took so long, but overall this PR is looking good and is a valuable contribution, thank you! I just left one small comment – and once that’s been addressed, I’d be happy to merge 🚀 |
@wmnnd thanks for the feedback! I refactored |
Excellent, thank you! Sorry for the nit-pick about Ecto.Multi 😅 |
My attempt on #390.
Updating the
handle_result
fromKeila.Mailings.Worker
to deal with the already existent:invalid_email
return error. The action will update thefailed_at
date for the recipient, and update the recipient's contact to theunreachable
atom.Also, refactored a few queries into their own private functions. Maybe in the future these functions could be moved to their own service/module?
Also, @wmnnd: I have not found any tests covering this file. Should we add tests with this PR?
Thanks!