|
1 | 1 | package org.sefglobal.scholarx.util;
|
2 | 2 |
|
| 3 | +import org.apache.commons.lang.StringUtils; |
3 | 4 | import org.sefglobal.scholarx.model.Mentee;
|
4 | 5 | import org.sefglobal.scholarx.model.Mentor;
|
5 | 6 | import org.sefglobal.scholarx.model.Program;
|
@@ -30,35 +31,85 @@ public void sendMenteeApplicationEmails(long id, Optional<Program> program) thro
|
30 | 31 |
|
31 | 32 | String message;
|
32 | 33 | for (Mentor mentor : mentors) {
|
33 |
| - message = "You have been " + mentor.getState().name().toLowerCase(); |
34 |
| - emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message); |
| 34 | + |
| 35 | + if (mentor.getState().name().equals("APPROVED")) { |
| 36 | + |
| 37 | + message = "Dear " + mentor.getProfile().getFirstName() + ",<br /><br />" + |
| 38 | + "<b>Congratulations!</b><br />You have been selected by the " + |
| 39 | + "ScholarX committee to be a mentor of the " + program.get().getTitle() + |
| 40 | + " program. We will soon open up the program for students to " + |
| 41 | + "apply and keep you posted on the progress via email. Until " + |
| 42 | + "then, read more about student experience " + |
| 43 | + "<a href=\"https://medium.com/search?q=scholarx\">here</a> and reach out to us via " + |
| 44 | + |
| 45 | + "for any clarifications."; |
| 46 | + |
| 47 | + emailService.sendEmail(mentor.getProfile().getEmail(), StringUtils.capitalize(mentor.getState().name()), message, false); |
| 48 | + |
| 49 | + } else if (mentor.getState().name().equals("REJECTED")) { |
| 50 | + |
| 51 | + message = "Dear " + mentor.getProfile().getFirstName() + ",<br /><br />" + |
| 52 | + "Thank you very much for taking your time to apply for the " + program.get().getTitle() + " program. " + |
| 53 | + "However, due to the competitive nature of the mentor applications, your application " + |
| 54 | + "did not make it to the final list of mentors for the program. We encourage you to try " + |
| 55 | + "again next year and follow us on our social media channels for future programs. " + |
| 56 | + "If you have any clarifications, please reach out to us via " + |
| 57 | + |
| 58 | + |
| 59 | + emailService.sendEmail(mentor.getProfile().getEmail(), StringUtils.capitalize(mentor.getState().name()), message, false); |
| 60 | + |
| 61 | + } |
35 | 62 | }
|
36 | 63 | }
|
37 | 64 |
|
38 | 65 | public void sendMenteeSelectionEmails(long id, Optional<Program> program) throws IOException, MessagingException {
|
39 | 66 | List<Mentor> approvedMentors = mentorRepository.findAllByProgramIdAndState(id, EnrolmentState.APPROVED);
|
| 67 | + List<Mentee> mentees = menteeRepository.findAllByProgramId(id); |
40 | 68 |
|
41 |
| - String message = "You can approve or reject your mentees by visiting the dashboard"; |
| 69 | + // Notify mentors |
42 | 70 | for (Mentor mentor : approvedMentors) {
|
43 |
| - emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message); |
| 71 | + |
| 72 | + String message = "Dear " + mentor.getProfile().getFirstName() + ",<br /><br />" + |
| 73 | + "You have student applications waiting to be reviewed. You can approve or reject your mentees " + |
| 74 | + "by visiting the <b>ScholarX dashboard.</b>"; |
| 75 | + |
| 76 | + emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message, true); |
| 77 | + } |
| 78 | + |
| 79 | + // Notify mentees |
| 80 | + for (Mentee mentee : mentees) { |
| 81 | + String message = "Dear " + mentee.getProfile().getFirstName() + ",<br /><br />" + |
| 82 | + "Thank you very much for applying to the " + program.get().getTitle() + " program. Your application has been received. " + |
| 83 | + "Mentors will soon review your applications and we will keep you posted on the progress via email. " + |
| 84 | + "Until then, read more about student experience <a href=\"https://medium.com/search?q=scholarx\">here</a> and reach out to us via " + |
| 85 | + |
| 86 | + "for any clarifications."; |
| 87 | + |
| 88 | + emailService.sendEmail(mentee.getProfile().getEmail(), program.get().getTitle(), message, false); |
44 | 89 | }
|
45 | 90 | }
|
46 | 91 |
|
47 | 92 | public void sendOnGoingEmails(long id, Optional<Program> program) throws IOException, MessagingException {
|
48 | 93 | List<Mentor> approvedMentors = mentorRepository.findAllByProgramIdAndState(id, EnrolmentState.APPROVED);
|
49 | 94 |
|
50 |
| - String message = "You can check your mentees by visiting the dashboard"; |
51 | 95 | for (Mentor mentor : approvedMentors) {
|
52 |
| - emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message); |
| 96 | + |
| 97 | + String message = "Dear " + mentor.getProfile().getFirstName() + ",<br /><br />" + |
| 98 | + "<b>Congratulations!</b><br />Students have accepted you as their mentor. " + |
| 99 | + "You can check your mentees and their contact details by visiting the <b>ScholarX dashboard.</b> " + |
| 100 | + "Please make the first contact with them as we have instructed them to wait for your email."; |
| 101 | + |
| 102 | + emailService.sendEmail(mentor.getProfile().getEmail(), program.get().getTitle(), message, true); |
53 | 103 | }
|
54 | 104 | }
|
55 | 105 |
|
56 | 106 | public void sendMentorConfirmationEmails(long id, Optional<Program> program) throws IOException, MessagingException {
|
57 | 107 | List<Mentee> mentees = menteeRepository.findAllByProgramId(id);
|
58 | 108 |
|
59 | 109 | String message = "You can check your mentor by visiting the dashboard";
|
| 110 | + |
60 | 111 | for (Mentee mentee : mentees) {
|
61 |
| - emailService.sendEmail(mentee.getProfile().getEmail(), program.get().getTitle(), message); |
| 112 | + emailService.sendEmail(mentee.getProfile().getEmail(), program.get().getTitle(), message, true); |
62 | 113 | }
|
63 | 114 | }
|
64 | 115 | }
|
0 commit comments