-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue with emails not being sent (#178)
* rfr * removes try
- Loading branch information
Showing
16 changed files
with
208 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ | |
import com.google.sps.data.ScheduledInterviewDao; | ||
import com.google.sps.data.SendgridEmailSender; | ||
import com.google.sps.utils.EmailUtils; | ||
import com.google.sps.utils.SendgridEmailUtils; | ||
import com.sendgrid.helpers.mail.Mail; | ||
import com.sendgrid.helpers.mail.objects.Content; | ||
import com.sendgrid.helpers.mail.objects.Email; | ||
|
@@ -50,7 +49,6 @@ public class IntervieweeFeedbackServlet extends HttpServlet { | |
private ScheduledInterviewDao scheduledInterviewDao; | ||
private PersonDao personDao; | ||
private EmailSender emailSender; | ||
private EmailUtils emailUtils; | ||
static final Email sender = new Email("[email protected]"); | ||
private Path emailsPath = | ||
Paths.get( | ||
|
@@ -64,22 +62,14 @@ public void init() { | |
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
init( | ||
new DatastoreScheduledInterviewDao(), | ||
new DatastorePersonDao(), | ||
emailSender, | ||
new SendgridEmailUtils()); | ||
init(new DatastoreScheduledInterviewDao(), new DatastorePersonDao(), emailSender); | ||
} | ||
|
||
public void init( | ||
ScheduledInterviewDao scheduledInterviewDao, | ||
PersonDao personDao, | ||
EmailSender emailSender, | ||
EmailUtils emailUtils) { | ||
ScheduledInterviewDao scheduledInterviewDao, PersonDao personDao, EmailSender emailSender) { | ||
this.scheduledInterviewDao = scheduledInterviewDao; | ||
this.personDao = personDao; | ||
this.emailSender = emailSender; | ||
this.emailUtils = emailUtils; | ||
} | ||
|
||
@Override | ||
|
@@ -148,8 +138,8 @@ private void sendFeedback(String intervieweeEmail, HashMap<String, String> answe | |
String subject = "Your Interviewer has submitted feedback for your interview!"; | ||
Email recipient = new Email(intervieweeEmail); | ||
String contentString = | ||
emailUtils.fileContentToString(emailsPath + "/feedbackToInterviewee.txt"); | ||
Content content = new Content("text/plain", emailUtils.replaceAllPairs(answers, contentString)); | ||
EmailUtils.fileContentToString(emailsPath + "/feedbackToInterviewee.txt"); | ||
Content content = new Content("text/plain", EmailUtils.replaceAllPairs(answers, contentString)); | ||
emailSender.sendEmail(recipient, subject, content); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ | |
import com.google.sps.data.ScheduledInterviewDao; | ||
import com.google.sps.data.SendgridEmailSender; | ||
import com.google.sps.utils.EmailUtils; | ||
import com.google.sps.utils.SendgridEmailUtils; | ||
import com.sendgrid.helpers.mail.Mail; | ||
import com.sendgrid.helpers.mail.objects.Content; | ||
import com.sendgrid.helpers.mail.objects.Email; | ||
|
@@ -50,7 +49,6 @@ public class InterviewerFeedbackServlet extends HttpServlet { | |
private ScheduledInterviewDao scheduledInterviewDao; | ||
private PersonDao personDao; | ||
private EmailSender emailSender; | ||
private EmailUtils emailUtils; | ||
static final Email sender = new Email("[email protected]"); | ||
private Path emailsPath = | ||
Paths.get( | ||
|
@@ -64,22 +62,14 @@ public void init() { | |
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
init( | ||
new DatastoreScheduledInterviewDao(), | ||
new DatastorePersonDao(), | ||
emailSender, | ||
new SendgridEmailUtils()); | ||
init(new DatastoreScheduledInterviewDao(), new DatastorePersonDao(), emailSender); | ||
} | ||
|
||
public void init( | ||
ScheduledInterviewDao scheduledInterviewDao, | ||
PersonDao personDao, | ||
EmailSender emailSender, | ||
EmailUtils emailUtils) { | ||
ScheduledInterviewDao scheduledInterviewDao, PersonDao personDao, EmailSender emailSender) { | ||
this.scheduledInterviewDao = scheduledInterviewDao; | ||
this.personDao = personDao; | ||
this.emailSender = emailSender; | ||
this.emailUtils = emailUtils; | ||
} | ||
|
||
@Override | ||
|
@@ -147,8 +137,8 @@ private void sendFeedback(String interviewerEmail, HashMap<String, String> answe | |
String subject = "Your Interviewee has submitted feedback for your interview!"; | ||
Email recipient = new Email(interviewerEmail); | ||
String contentString = | ||
emailUtils.fileContentToString(emailsPath + "/feedbackToInterviewer.txt"); | ||
Content content = new Content("text/plain", emailUtils.replaceAllPairs(answers, contentString)); | ||
EmailUtils.fileContentToString(emailsPath + "/feedbackToInterviewer.txt"); | ||
Content content = new Content("text/plain", EmailUtils.replaceAllPairs(answers, contentString)); | ||
emailSender.sendEmail(recipient, subject, content); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,6 @@ | |
import com.google.sps.data.SendgridEmailSender; | ||
import com.google.sps.data.TimeRange; | ||
import com.google.sps.utils.EmailUtils; | ||
import com.google.sps.utils.SendgridEmailUtils; | ||
import com.sendgrid.Response; | ||
import com.sendgrid.SendGrid; | ||
import com.sendgrid.helpers.mail.Mail; | ||
|
@@ -81,12 +80,8 @@ public class ScheduledInterviewServlet extends HttpServlet { | |
private EmailSender emailSender; | ||
private CalendarAccess calendarAccess; | ||
private Calendar service; | ||
private EmailUtils emailUtils; | ||
private final UserService userService = UserServiceFactory.getUserService(); | ||
static final Email sender = new Email("[email protected]"); | ||
private Path emailsPath = | ||
Paths.get( | ||
System.getProperty("user.home") + "/InterviewMe/src/main/resources/templates/email"); | ||
|
||
@Override | ||
public void init() { | ||
|
@@ -113,23 +108,20 @@ public void init() { | |
new DatastoreAvailabilityDao(), | ||
new DatastorePersonDao(), | ||
calendar, | ||
emailSender, | ||
new SendgridEmailUtils()); | ||
emailSender); | ||
} | ||
|
||
public void init( | ||
ScheduledInterviewDao scheduledInterviewDao, | ||
AvailabilityDao availabilityDao, | ||
PersonDao personDao, | ||
CalendarAccess calendarAccess, | ||
EmailSender emailSender, | ||
EmailUtils emailUtils) { | ||
EmailSender emailSender) { | ||
this.scheduledInterviewDao = scheduledInterviewDao; | ||
this.availabilityDao = availabilityDao; | ||
this.personDao = personDao; | ||
this.calendarAccess = calendarAccess; | ||
this.emailSender = emailSender; | ||
this.emailUtils = emailUtils; | ||
} | ||
|
||
// Gets the current user's email and returns the ScheduledInterviews for that person. | ||
|
@@ -447,22 +439,21 @@ private void sendParticipantEmail( | |
} | ||
|
||
String subject = "You have been requested to conduct a mock interview!"; | ||
String contentString = | ||
emailUtils.fileContentToString(emailsPath + "/NewInterview_Interviewer.txt"); | ||
String contentString = EmailUtils.fileContentToString("NewInterview_Interviewer.txt"); | ||
|
||
if (participantId.equals(scheduledInterview.intervieweeId())) { | ||
subject = "You have been registered for a mock interview!"; | ||
contentString = emailUtils.fileContentToString(emailsPath + "/NewInterview_Interviewee.txt"); | ||
contentString = EmailUtils.fileContentToString("NewInterview_Interviewee.txt"); | ||
} | ||
|
||
if (participantId.equals(scheduledInterview.shadowId())) { | ||
subject = "You have been registered for a mock interview!"; | ||
contentString = emailUtils.fileContentToString(emailsPath + "/NewInterview_Shadow.txt"); | ||
contentString = EmailUtils.fileContentToString("NewInterview_Shadow.txt"); | ||
} | ||
|
||
Email recipient = new Email(recipientEmail); | ||
Content content = | ||
new Content("text/plain", emailUtils.replaceAllPairs(emailedDetails, contentString)); | ||
new Content("text/plain", EmailUtils.replaceAllPairs(emailedDetails, contentString)); | ||
emailSender.sendEmail(recipient, subject, content); | ||
} | ||
// Formats the position string that is sent in an email. For example SOFTWARE_ENGINEER -> Software | ||
|
@@ -471,7 +462,7 @@ private static String formatPositionString(String str) { | |
String splitString[] = str.split("_", 0); | ||
String formattedPositionString = ""; | ||
for (String s : splitString) { | ||
formattedPositionString += s.substring(0, 1) + s.substring(1).toLowerCase(); | ||
formattedPositionString += s.substring(0, 1) + s.substring(1).toLowerCase() + " "; | ||
} | ||
return formattedPositionString.trim(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
src/main/java/com/google/sps/utils/SendgridEmailUtils.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.