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

HAI-1526 Add functions to send hanke and application invitation emails #399

Merged
merged 6 commits into from
Sep 6, 2023

Conversation

pitkni
Copy link
Contributor

@pitkni pitkni commented Sep 1, 2023

Description

Add templates for hanke and application invitation emails. Add functionality to send these invitations in EmailSenderService.

Note: It is possible for inviter name to be unknown. In these cases the emails use only the inviter email ([email protected] kutsui sinut..).

Note: mjml.io plugin is used to create the email templates. From mjml documentation:

MJML is a markup language designed to reduce the pain of coding a responsive email. Its semantic syntax makes it easy and straightforward and its rich standard components library speeds up your development time and lightens your email codebase. MJML’s open-source engine generates high quality responsive HTML compliant with best practices.

Note: Email translations are not included in this pr, as mentioned in the Jira ticket.

Using the new email sending features will be implemented on a different upcoming pr.

Jira Issue: https://helsinkisolutionoffice.atlassian.net/browse/HAI-1526

Type of change

  • Bug fix
  • New feature
  • Other

Instructions for testing

This cannot be directly tested, but adding something like this to EmailSenderService can be used for verification:


    @Scheduled(fixedDelay = 60000)
    fun testSendHanke() {
        sendHankeInvitationEmail(
            to = "[email protected]",
            HankeInvitationData(
                inviterName = "Matti Meikäläinen",
                inviterEmail = "[email protected]",
                hankeTunnus = "HAI24-1",
                hankeNimi = "Testi hanke",
                invitationToken = "testtoken"
            )
        )
    }

    @Scheduled(fixedDelay = 60000)
    fun testSendHakemus() {
        sendApplicationInvitationEmail(
            to = "[email protected]",
            ApplicationInvitationData(
                inviterName = "Matti Meikäläinen",
                inviterEmail = "[email protected]",
                applicationType = ApplicationType.CABLE_REPORT,
                applicationIdentifier = "JS002",
                hankeTunnus = "HAI24-1",
                roleType = ContactType.RAKENNUTTAJA,
            )
        )
    }

Then you can check localhost:3003 (email server in docker compose)

Checklist:

  • I have written new tests (if applicable)
  • I have ran the tests myself (if applicable)
  • I have made necessary changes to the documentation, link to confluence
    or other location:

Other relevant info

Please describe here if there is e.g. some requirements for this change or
other info that the tester/user needs to know.

@pitkni pitkni marked this pull request as ready for review September 1, 2023 09:49
@pitkni pitkni force-pushed the HAI-1526/invitation-emails-and-client branch 2 times, most recently from e33521b to eac3ea3 Compare September 1, 2023 10:54
@pitkni pitkni marked this pull request as draft September 1, 2023 11:16
@pitkni pitkni force-pushed the HAI-1526/invitation-emails-and-client branch 4 times, most recently from a115b5f to 7f15911 Compare September 5, 2023 07:26
@pitkni pitkni marked this pull request as ready for review September 5, 2023 07:55
@pitkni pitkni force-pushed the HAI-1526/invitation-emails-and-client branch 3 times, most recently from 015c32a to 952c6e5 Compare September 5, 2023 10:21
Add templates for hanke and application invitation emails. Add functionality to send these invitations in EmailSenderService.

Note: It is possible for inviter name to be unknown. In these cases the emails use only the inviter email ([email protected] kutsui sinut..).

Using the new email sending features will be implemented on a different upcoming pr.
@pitkni pitkni force-pushed the HAI-1526/invitation-emails-and-client branch from 952c6e5 to aa0917b Compare September 5, 2023 13:29
@@ -0,0 +1,5 @@
<mj-attributes>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mjml files could be moved elsewhere. Under resources, they will be a part of the runtime package, which they clearly don't need to be.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any suggestions on where they should be located?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about an emailtemplate directory under scripts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not scripts, so that doesn't feel correct. Emails directory in either project root or services/hanke-service/emails?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Placed them in project root email/.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Dividing the common parts to a separate directory was a good addition.

README.md Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Sep 6, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

96.6% 96.6% Coverage
0.0% 0.0% Duplication

@pitkni pitkni merged commit 454e855 into dev Sep 6, 2023
4 checks passed
@pitkni pitkni deleted the HAI-1526/invitation-emails-and-client branch September 6, 2023 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants