Skip to content

Commit

Permalink
[#11878] Add AccountRequest Rejection email generator. (#12987)
Browse files Browse the repository at this point in the history
* add rejection-email template and email generator method

* add javadoc for email generator method

* add test

* fix test method names

* fix test method name 2

* fix lint

* add bcc for rejection email
  • Loading branch information
EuniceSim142 authored Apr 8, 2024
1 parent 62750b0 commit 96e5abd
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/teammates/common/util/EmailType.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum EmailType {
STUDENT_COURSE_REJOIN_AFTER_GOOGLE_ID_RESET("TEAMMATES: Your account has been reset for course [%s][Course ID: %s]"),
NEW_ACCOUNT_REQUEST_ADMIN_ALERT("TEAMMATES (Action Needed): New Account Request Received"),
NEW_ACCOUNT_REQUEST_ACKNOWLEDGEMENT("TEAMMATES: Acknowledgement of Instructor Account Request"),
ACCOUNT_REQUEST_REJECTION("TEAMMATES: %s"),
INSTRUCTOR_COURSE_JOIN("TEAMMATES: Invitation to join course as an instructor [%s][Course ID: %s]"),
INSTRUCTOR_COURSE_REJOIN_AFTER_GOOGLE_ID_RESET("TEAMMATES: Your account has been reset for course [%s][Course ID: %s]"),
USER_COURSE_REGISTER("TEAMMATES: Registered for Course [%s][Course ID: %s]"),
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,19 @@ public EmailWrapper generateNewAccountRequestAcknowledgementEmail(AccountRequest
return email;
}

/**
* Generates the email to be sent to instructor when their account request has been rejected by admin.
*/
public EmailWrapper generateAccountRequestRejectionEmail(AccountRequest accountRequest, String title, String content) {
EmailWrapper email = getEmptyEmailAddressedToEmail(accountRequest.getEmail());
email.setType(EmailType.ACCOUNT_REQUEST_REJECTION);
email.setBcc(Config.SUPPORT_EMAIL);
email.setSubjectFromType(SanitizationHelper.sanitizeTitle(title));
email.setContent(SanitizationHelper.sanitizeForRichText(content));

return email;
}

/**
* Generates the course registered email for the user with the given details in {@code course}.
*/
Expand Down
27 changes: 27 additions & 0 deletions src/test/java/teammates/sqllogic/api/SqlEmailGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@ void testGenerateNewAccountRequestAcknowledgementEmail_withNoComments_generatesS
"/instructorNewAccountRequestAcknowledgementEmailWithNoComments.html");
}

@Test
void testGenerateAccountRequestRejectionEmail_withDefaultReason_generatesSuccessfully() throws IOException {
AccountRequest accountRequest = new AccountRequest("maul@sith.org", "Maul", "Sith Order",
AccountRequestStatus.PENDING, null);
String title = "We are Unable to Create an Account for you";
String content = new StringBuilder()
.append("<p>Hi, Maul</p>\n")
.append("<p>Thanks for your interest in using TEAMMATES. ")
.append("We are unable to create a TEAMMATES instructor account for you.</p>\n\n")
.append("<p>\n")
.append(" <strong>Reason:</strong> The email address you provided ")
.append("is not an 'official' email address provided by your institution.<br />\n")
.append(" <strong>Remedy:</strong> ")
.append("Please re-submit an account request with your 'official' institution email address.\n")
.append("</p>\n\n")
.append("<p>If you need further clarification or would like to appeal this decision, ")
.append("please feel free to contact us at teammates@comp.nus.edu.sg.</p>\n")
.append("<p>Regards,<br />TEAMMATES Team.</p>\n")
.toString();

EmailWrapper email = sqlEmailGenerator.generateAccountRequestRejectionEmail(accountRequest, title, content);
verifyEmail(email, "maul@sith.org", EmailType.ACCOUNT_REQUEST_REJECTION,
"TEAMMATES: " + title,
Config.SUPPORT_EMAIL,
"/instructorAccountRequestRejectionEmail.html");
}

private void verifyEmail(EmailWrapper email, String expectedRecipientEmailAddress, EmailType expectedEmailType,
String expectedSubject, String expectedEmailContentFilePathname) throws IOException {
assertEquals(expectedRecipientEmailAddress, email.getRecipient());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<p>Hi, Maul</p>
<p>Thanks for your interest in using TEAMMATES. We are unable to create a TEAMMATES instructor account for you.</p>

<p>
<strong>Reason:</strong> The email address you provided is not an &#39;official&#39; email address provided by your institution.<br />
<strong>Remedy:</strong> Please re-submit an account request with your &#39;official&#39; institution email address.
</p>

<p>If you need further clarification or would like to appeal this decision, please feel free to contact us at teammates&#64;comp.nus.edu.sg.</p>
<p>Regards,<br />TEAMMATES Team.</p>

0 comments on commit 96e5abd

Please sign in to comment.