https://community.openproject.org/wp/57932
Retrying 14 times with polynomial backoff means it will retry for
roughly 1.5 days.
Previously the `retry_on StandardError` defined in the
`Mails::MailerJob` class was ignored because there is also a
`rescue_from StandardError` declared after it. As `retry_on` is
implemented using `rescue_from`, and the handlers are evaluated in
reverse order, the last declared `rescue_from` would be picked up and
the retry logic would not be triggered. That's why mail jobs were
discarded instead of being retried.
This commit fixes the issue by inheriting directly from
`ActionMailer::MailDeliveryJob` instead of redefining its methods. This
was the `rescue_from` is declared first in the parent class, and then
`retry_on` is declared second in the child class, meaning it will take
precedence and be picked up.
The needed shared logic from `ApplicationJob` is extracted to a new
`SharedJobSetup` module and included in both `ApplicationJob` and
`Mails::MailerJob`.