Skip to content
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

Mailer: In dev mode send emails in all locales #41879

Closed
gbourant opened this issue Jul 14, 2024 · 7 comments
Closed

Mailer: In dev mode send emails in all locales #41879

gbourant opened this issue Jul 14, 2024 · 7 comments
Labels
area/devmode area/mailer kind/enhancement New feature or request triage/wontfix This will not be worked on

Comments

@gbourant
Copy link

Description

When you are in dev mode, it would be nice if an email was sent in all locales defined in quarkus.locales.

Implementation ideas

No response

Copy link

quarkus-bot bot commented Jul 14, 2024

/cc @cescoffier (mailer)

@melloware
Copy link
Contributor

@gbourant can you be more clear? Do you mean your Qute template run through all locales and sent?

@gbourant
Copy link
Author

@gbourant can you be more clear? Do you mean your Qute template run through all locales and sent?

Yes, when you send an email and you are in dev mode, it should send it in all locales for debugging purposes. (maybe it should be enabled via a config option).

So if you have defined 3 locales and you send a single e-mail, it should have sent 3 emails in 3 different locales.

@gbourant
Copy link
Author

Well, i was thinking about that and i came up with this

@ApplicationScoped
public class MailService {

    @Inject
    I18N i18n;

    public void send(MailTemplate.MailTemplateInstance mailTemplateInstance, String emailType, String subjectKey, Object... params) {
        if (LaunchMode.current() == LaunchMode.DEVELOPMENT) {
            for (String locale : Globals.locales()) {
                i18n.setForCurrentRequest(locale);
                doSend(mailTemplateInstance, subjectKey, params);
            }
        } else {
            doSend(mailTemplateInstance, subjectKey, params);
        }
    }

    private void doSend(MailTemplate.MailTemplateInstance mailTemplateInstance, String subjectKey, Object... params) {
        mailTemplateInstance
                .subject(i18n.formatMessage(subjectKey, params))
                .send()
                .await()
                .atMost(Duration.ofSeconds(10));

    }
}

@geoand
Copy link
Contributor

geoand commented Jul 16, 2024

I can say that if I were using Quarkus and came across this while developing, I would be very surprised at the behavior and perhaps annoyed of this default

@melloware
Copy link
Contributor

melloware commented Jul 19, 2024

@gbourant I think @geoand and myself are both -1 on this feature. Since you have a local fix do you want to close this ticket or do you still feel strongly about it?

@gbourant
Copy link
Author

Yeap, it's ok.

@geoand geoand added the triage/wontfix This will not be worked on label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devmode area/mailer kind/enhancement New feature or request triage/wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants