fix: subject and email templates (#28531)
## 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>
This commit is contained in:
parent
e4a03ca56f
commit
dfe12f550d
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -14,4 +14,10 @@ public interface EmailServiceHelperCE {
|
|||
String getEmailVerificationTemplate();
|
||||
|
||||
String getAdminInstanceInviteTemplate();
|
||||
|
||||
String getJoinInstanceCtaPrimaryText();
|
||||
|
||||
String getSubjectJoinInstanceAsAdmin(String instanceName);
|
||||
|
||||
String getSubjectJoinWorkspace(String workspaceName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, String> 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<String, String> getInviteToWorkspaceEmailParams(
|
||||
|
|
|
|||
|
|
@ -384,10 +384,10 @@
|
|||
color: #4c5664;
|
||||
line-height: 1.43;
|
||||
"
|
||||
>{{inviterFirstName}} has invited you as
|
||||
<b>{{role}}</b> to the Appsmith
|
||||
>{{inviterFirstName}} has given you
|
||||
{{role}} access to the Appsmith
|
||||
workspace
|
||||
<b>{{inviterWorkspaceName}}</b></span
|
||||
{{inviterWorkspaceName}}.</span
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
|
|
@ -414,9 +414,8 @@
|
|||
color: #4c5664;
|
||||
line-height: 1.43;
|
||||
"
|
||||
>Join your Appsmith workspace to get
|
||||
access to fast, usable, beautiful
|
||||
apps.</span
|
||||
>Go to your Appsmith workspace to
|
||||
see fast, usable, beautiful apps.</span
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -385,9 +385,9 @@
|
|||
line-height: 1.43;
|
||||
"
|
||||
>{{inviterFirstName}} has invited you as
|
||||
<b>{{role}}</b> access to the Appsmith
|
||||
{{role}} to the Appsmith
|
||||
workspace
|
||||
<b>{{inviterWorkspaceName}}</b></span
|
||||
{{inviterWorkspaceName}}.</span
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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<String, String> 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));
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user