diff --git a/src/main/java/teammates/common/util/EmailType.java b/src/main/java/teammates/common/util/EmailType.java index 6ee9abcbab9..a42280ba7f0 100644 --- a/src/main/java/teammates/common/util/EmailType.java +++ b/src/main/java/teammates/common/util/EmailType.java @@ -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]"), diff --git a/src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java b/src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java index befe9647656..2fb76991cc6 100644 --- a/src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java +++ b/src/main/java/teammates/sqllogic/api/SqlEmailGenerator.java @@ -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}. */ diff --git a/src/test/java/teammates/sqllogic/api/SqlEmailGeneratorTest.java b/src/test/java/teammates/sqllogic/api/SqlEmailGeneratorTest.java index 036ccf4b448..f984b10f46c 100644 --- a/src/test/java/teammates/sqllogic/api/SqlEmailGeneratorTest.java +++ b/src/test/java/teammates/sqllogic/api/SqlEmailGeneratorTest.java @@ -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("
Hi, Maul
\n") + .append("Thanks for your interest in using TEAMMATES. ") + .append("We are unable to create a TEAMMATES instructor account for you.
\n\n") + .append("\n")
+ .append(" Reason: The email address you provided ")
+ .append("is not an 'official' email address provided by your institution.
\n")
+ .append(" Remedy: ")
+ .append("Please re-submit an account request with your 'official' institution email address.\n")
+ .append("
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.
\n") + .append("Regards,
TEAMMATES Team.
Hi, Maul
+Thanks for your interest in using TEAMMATES. We are unable to create a TEAMMATES instructor account for you.
+ +
+ Reason: The email address you provided is not an 'official' email address provided by your institution.
+ Remedy: Please re-submit an account request with your 'official' institution email address.
+
If you need further clarification or would like to appeal this decision, please feel free to contact us at teammates@comp.nus.edu.sg.
+Regards,
TEAMMATES Team.