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

[#11878] Add AccountRequest Rejection email generator. #12987

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
12 changes: 12 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,18 @@ 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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think prof mentioned he wanted the email to be BCC-ed to the support email so the admin gets a copy as well

EmailWrapper email = getEmptyEmailAddressedToEmail(accountRequest.getEmail());
email.setType(EmailType.ACCOUNT_REQUEST_REJECTION);
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
23 changes: 23 additions & 0 deletions src/test/java/teammates/sqllogic/api/SqlEmailGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@ void testGenerateNewAccountRequestAcknowledgementEmail_withNoComments_generatesS
Config.SUPPORT_EMAIL,
"/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. 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 is not an 'official' email address provided by your institution.<br />\n")
.append(" <strong>Remedy:</strong> 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, 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,
"/instructorAccountRequestRejectionEmail.html");
}


private void verifyEmail(EmailWrapper email, String expectedRecipientEmailAddress, EmailType expectedEmailType,
String expectedSubject, String expectedEmailContentFilePathname) throws IOException {
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>
Loading