From dfe12f550dd90e6a27eaeae6a24b9e7c1c039c25 Mon Sep 17 00:00:00 2001 From: Nilesh Sarupriya Date: Wed, 1 Nov 2023 16:02:01 +0530 Subject: [PATCH] fix: subject and email templates (#28531) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description > Fix email templates and subjects. > Related EE PR: https://github.com/appsmithorg/appsmith-ee/pull/2791 #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [x] Manual Manual testing done on the DP: ee-2787 #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com> --- .../server/constants/ce/EmailConstantsCE.java | 8 +++++--- .../helpers/ce/EmailServiceHelperCE.java | 6 ++++++ .../helpers/ce/EmailServiceHelperCEImpl.java | 18 +++++++++++++++++ .../services/ce/EmailServiceCEImpl.java | 20 ++++++++++--------- .../inviteWorkspaceExistingUserTemplate.html | 11 +++++----- .../ce/inviteWorkspaceNewUserTemplate.html | 4 ++-- .../services/ce/EmailServiceCEImplTest.java | 4 ++-- 7 files changed, 49 insertions(+), 22 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/EmailConstantsCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/EmailConstantsCE.java index 6d2abde6d6..8073c1a122 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/EmailConstantsCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/constants/ce/EmailConstantsCE.java @@ -11,14 +11,16 @@ public class EmailConstantsCE { public static final String PRIMARY_LINK_URL = "primaryLinkUrl"; public static final String PRIMARY_LINK_TEXT = "primaryLinkText"; public static final String PRIMARY_LINK_TEXT_USER_SIGNUP = "Sign up now"; - public static final String PRIMARY_LINK_TEXT_INVITE_TO_INSTANCE = "Go to instance"; + public static final String PRIMARY_LINK_TEXT_INVITE_TO_INSTANCE_CE = "Join your Appsmith instance"; public static final String PRIMARY_LINK_TEXT_WORKSPACE_REDIRECTION = "Go to your Appsmith workspace"; public static final String INVITE_USER_CLIENT_URL_FORMAT = "%s/user/signup?email=%s"; - public static final String WORKSPACE_EMAIL_SUBJECT_FOR_NEW_USER = "You’re invited to the workspace %s."; + public static final String INVITE_TO_WORKSPACE_EMAIL_SUBJECT_CE = + "You’re invited to the Appsmith workspace. \uD83E\uDD73"; public static final String FORGOT_PASSWORD_EMAIL_SUBJECT = "Reset your Appsmith password"; public static final String EMAIL_VERIFICATION_EMAIL_SUBJECT = "Verify your account"; - public static final String INSTANCE_ADMIN_INVITE_EMAIL_SUBJECT = "You're invited to an Appsmith instance"; + public static final String INSTANCE_ADMIN_INVITE_EMAIL_SUBJECT = + "You're invited to an Appsmith instance. \uD83E\uDD73"; public static final String INVITE_WORKSPACE_TEMPLATE_EXISTING_USER_CE = "email/ce/inviteWorkspaceExistingUserTemplate.html"; public static final String INVITE_WORKSPACE_TEMPLATE_NEW_USER_CE = "email/ce/inviteWorkspaceNewUserTemplate.html"; diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/EmailServiceHelperCE.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/EmailServiceHelperCE.java index 0c4ff608fd..db905304a4 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/EmailServiceHelperCE.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/EmailServiceHelperCE.java @@ -14,4 +14,10 @@ public interface EmailServiceHelperCE { String getEmailVerificationTemplate(); String getAdminInstanceInviteTemplate(); + + String getJoinInstanceCtaPrimaryText(); + + String getSubjectJoinInstanceAsAdmin(String instanceName); + + String getSubjectJoinWorkspace(String workspaceName); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/EmailServiceHelperCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/EmailServiceHelperCEImpl.java index 3360126080..2dca84c12c 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/EmailServiceHelperCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/EmailServiceHelperCEImpl.java @@ -11,10 +11,13 @@ import java.util.Map; import static com.appsmith.server.constants.ce.EmailConstantsCE.EMAIL_VERIFICATION_EMAIL_TEMPLATE_CE; import static com.appsmith.server.constants.ce.EmailConstantsCE.FORGOT_PASSWORD_TEMPLATE_CE; +import static com.appsmith.server.constants.ce.EmailConstantsCE.INSTANCE_ADMIN_INVITE_EMAIL_SUBJECT; import static com.appsmith.server.constants.ce.EmailConstantsCE.INSTANCE_ADMIN_INVITE_EMAIL_TEMPLATE; import static com.appsmith.server.constants.ce.EmailConstantsCE.INSTANCE_NAME; +import static com.appsmith.server.constants.ce.EmailConstantsCE.INVITE_TO_WORKSPACE_EMAIL_SUBJECT_CE; import static com.appsmith.server.constants.ce.EmailConstantsCE.INVITE_WORKSPACE_TEMPLATE_EXISTING_USER_CE; import static com.appsmith.server.constants.ce.EmailConstantsCE.INVITE_WORKSPACE_TEMPLATE_NEW_USER_CE; +import static com.appsmith.server.constants.ce.EmailConstantsCE.PRIMARY_LINK_TEXT_INVITE_TO_INSTANCE_CE; @Component @AllArgsConstructor @@ -52,4 +55,19 @@ public class EmailServiceHelperCEImpl implements EmailServiceHelperCE { public String getAdminInstanceInviteTemplate() { return INSTANCE_ADMIN_INVITE_EMAIL_TEMPLATE; } + + @Override + public String getJoinInstanceCtaPrimaryText() { + return PRIMARY_LINK_TEXT_INVITE_TO_INSTANCE_CE; + } + + @Override + public String getSubjectJoinInstanceAsAdmin(String instanceName) { + return INSTANCE_ADMIN_INVITE_EMAIL_SUBJECT; + } + + @Override + public String getSubjectJoinWorkspace(String workspaceName) { + return INVITE_TO_WORKSPACE_EMAIL_SUBJECT_CE; + } } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/EmailServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/EmailServiceCEImpl.java index 95571ce473..dddb54db66 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/EmailServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/EmailServiceCEImpl.java @@ -55,7 +55,7 @@ public class EmailServiceCEImpl implements EmailServiceCE { originHeader, URLEncoder.encode(invitedUser.getUsername().toLowerCase(), StandardCharsets.UTF_8)) : originHeader; - String emailSubject = String.format(WORKSPACE_EMAIL_SUBJECT_FOR_NEW_USER, workspaceInvitedTo.getName()); + String emailSubject = emailServiceHelper.getSubjectJoinWorkspace(workspaceInvitedTo.getName()); Map params = getInviteToWorkspaceEmailParams( workspaceInvitedTo, invitingUser, inviteUrl, assignedPermissionGroup.getName(), isNewUser); return emailServiceHelper @@ -92,19 +92,21 @@ public class EmailServiceCEImpl implements EmailServiceCE { : originHeader; params.put(PRIMARY_LINK_URL, inviteUrl); - String primaryLinkText = isNewUser ? PRIMARY_LINK_TEXT_USER_SIGNUP : PRIMARY_LINK_TEXT_INVITE_TO_INSTANCE; + String primaryLinkText = emailServiceHelper.getJoinInstanceCtaPrimaryText(); params.put(PRIMARY_LINK_TEXT, primaryLinkText); if (invitingUser != null) { params.put(INVITER_FIRST_NAME, StringUtils.defaultIfEmpty(invitingUser.getName(), invitingUser.getEmail())); } - return emailServiceHelper - .enrichWithBrandParams(params, originHeader) - .flatMap(updatedParams -> emailSender.sendMail( - invitedUser.getEmail(), - String.format(INSTANCE_ADMIN_INVITE_EMAIL_SUBJECT), - emailServiceHelper.getAdminInstanceInviteTemplate(), - updatedParams)); + return emailServiceHelper.enrichWithBrandParams(params, originHeader).flatMap(updatedParams -> { + String instanceName = updatedParams.get(INSTANCE_NAME); + String subject = emailServiceHelper.getSubjectJoinInstanceAsAdmin(instanceName); + return emailSender.sendMail( + invitedUser.getEmail(), + subject, + emailServiceHelper.getAdminInstanceInviteTemplate(), + updatedParams); + }); } private Map getInviteToWorkspaceEmailParams( diff --git a/app/server/appsmith-server/src/main/resources/email/ce/inviteWorkspaceExistingUserTemplate.html b/app/server/appsmith-server/src/main/resources/email/ce/inviteWorkspaceExistingUserTemplate.html index 70c1b13141..4539d2799e 100644 --- a/app/server/appsmith-server/src/main/resources/email/ce/inviteWorkspaceExistingUserTemplate.html +++ b/app/server/appsmith-server/src/main/resources/email/ce/inviteWorkspaceExistingUserTemplate.html @@ -384,10 +384,10 @@ color: #4c5664; line-height: 1.43; " - >{{inviterFirstName}} has invited you as - {{role}} to the Appsmith + >{{inviterFirstName}} has given you + {{role}} access to the Appsmith workspace - {{inviterWorkspaceName}}

@@ -414,9 +414,8 @@ color: #4c5664; line-height: 1.43; " - >Join your Appsmith workspace to get - access to fast, usable, beautiful - apps.Go to your Appsmith workspace to + see fast, usable, beautiful apps.

diff --git a/app/server/appsmith-server/src/main/resources/email/ce/inviteWorkspaceNewUserTemplate.html b/app/server/appsmith-server/src/main/resources/email/ce/inviteWorkspaceNewUserTemplate.html index b3b487fbba..1c8dfcb3a8 100644 --- a/app/server/appsmith-server/src/main/resources/email/ce/inviteWorkspaceNewUserTemplate.html +++ b/app/server/appsmith-server/src/main/resources/email/ce/inviteWorkspaceNewUserTemplate.html @@ -385,9 +385,9 @@ line-height: 1.43; " >{{inviterFirstName}} has invited you as - {{role}} access to the Appsmith + {{role}} to the Appsmith workspace - {{inviterWorkspaceName}}

diff --git a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/EmailServiceCEImplTest.java b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/EmailServiceCEImplTest.java index e4c1c1110d..653bb61e03 100644 --- a/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/EmailServiceCEImplTest.java +++ b/app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/EmailServiceCEImplTest.java @@ -26,10 +26,10 @@ import static com.appsmith.server.constants.ce.EmailConstantsCE.INSTANCE_ADMIN_I import static com.appsmith.server.constants.ce.EmailConstantsCE.INSTANCE_NAME; import static com.appsmith.server.constants.ce.EmailConstantsCE.INVITER_FIRST_NAME; import static com.appsmith.server.constants.ce.EmailConstantsCE.INVITER_WORKSPACE_NAME; +import static com.appsmith.server.constants.ce.EmailConstantsCE.INVITE_TO_WORKSPACE_EMAIL_SUBJECT_CE; import static com.appsmith.server.constants.ce.EmailConstantsCE.PRIMARY_LINK_TEXT; import static com.appsmith.server.constants.ce.EmailConstantsCE.PRIMARY_LINK_URL; import static com.appsmith.server.constants.ce.EmailConstantsCE.RESET_URL; -import static com.appsmith.server.constants.ce.EmailConstantsCE.WORKSPACE_EMAIL_SUBJECT_FOR_NEW_USER; import static graphql.Assert.assertTrue; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -120,7 +120,7 @@ class EmailServiceCEImplTest { Map params = invocation.getArgument(3); assertEquals(invitedUser.getEmail(), to); - assertEquals(String.format(WORKSPACE_EMAIL_SUBJECT_FOR_NEW_USER, workspace.getName()), subject); + assertEquals(String.format(INVITE_TO_WORKSPACE_EMAIL_SUBJECT_CE, workspace.getName()), subject); assertTrue(params.containsKey(PRIMARY_LINK_URL)); assertTrue(params.containsKey(PRIMARY_LINK_TEXT)); assertEquals(expectedParams.get(INSTANCE_NAME), params.get(INSTANCE_NAME));