use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class FeedbackSessionClosedRemindersAction method execute.
@Override
public void execute() {
List<FeedbackSessionAttributes> sessions = logic.getFeedbackSessionsClosedWithinThePastHour();
for (FeedbackSessionAttributes session : sessions) {
List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionClosedEmails(session);
try {
taskQueuer.scheduleEmailsForSending(emailsToBeSent);
session.setSentClosedEmail(true);
logic.updateFeedbackSession(session);
} catch (Exception e) {
log.severe("Unexpected error: " + TeammatesException.toStringWithStackTrace(e));
}
}
}
use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class FeedbackSessionOpeningRemindersAction method execute.
@Override
public void execute() {
List<FeedbackSessionAttributes> sessions = logic.getFeedbackSessionsWhichNeedOpenEmailsToBeSent();
for (FeedbackSessionAttributes session : sessions) {
List<EmailWrapper> emailsToBeSent = new EmailGenerator().generateFeedbackSessionOpeningEmails(session);
try {
taskQueuer.scheduleEmailsForSending(emailsToBeSent);
session.setSentOpenEmail(true);
logic.updateFeedbackSession(session);
} catch (Exception e) {
log.severe("Unexpected error: " + TeammatesException.toStringWithStackTrace(e));
}
}
}
use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class FeedbackSessionRemindParticularUsersEmailWorkerAction method execute.
@Override
public void execute() {
String feedbackSessionName = getNonNullRequestParamValue(ParamsNames.SUBMISSION_FEEDBACK);
String courseId = getNonNullRequestParamValue(ParamsNames.SUBMISSION_COURSE);
String[] usersToRemind = getNonNullRequestParamValues(ParamsNames.SUBMISSION_REMIND_USERLIST);
String googleIdOfInstructorToNotify = getNonNullRequestParamValue(ParamsNames.USER_ID);
try {
FeedbackSessionAttributes session = logic.getFeedbackSession(feedbackSessionName, courseId);
List<StudentAttributes> studentsToRemindList = new ArrayList<>();
List<InstructorAttributes> instructorsToRemindList = new ArrayList<>();
InstructorAttributes instructorToNotify = logic.getInstructorForGoogleId(courseId, googleIdOfInstructorToNotify);
for (String userEmail : usersToRemind) {
StudentAttributes student = logic.getStudentForEmail(courseId, userEmail);
if (student != null) {
studentsToRemindList.add(student);
}
InstructorAttributes instructor = logic.getInstructorForEmail(courseId, userEmail);
if (instructor != null) {
instructorsToRemindList.add(instructor);
}
}
List<EmailWrapper> emails = new EmailGenerator().generateFeedbackSessionReminderEmails(session, studentsToRemindList, instructorsToRemindList, instructorToNotify);
taskQueuer.scheduleEmailsForSending(emails);
} catch (Exception e) {
log.severe("Unexpected error while sending emails: " + TeammatesException.toStringWithStackTrace(e));
}
}
use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class InstructorCourseJoinEmailWorkerAction method execute.
@Override
public void execute() {
String inviterId = getRequestParamValue(ParamsNames.INVITER_ID);
Assumption.assertPostParamNotNull(ParamsNames.INVITER_ID, inviterId);
String courseId = getRequestParamValue(ParamsNames.COURSE_ID);
Assumption.assertPostParamNotNull(ParamsNames.COURSE_ID, courseId);
String instructorEmail = getRequestParamValue(ParamsNames.INSTRUCTOR_EMAIL);
Assumption.assertPostParamNotNull(ParamsNames.INSTRUCTOR_EMAIL, instructorEmail);
AccountAttributes inviter = logic.getAccount(inviterId);
Assumption.assertNotNull(inviter);
CourseAttributes course = logic.getCourse(courseId);
Assumption.assertNotNull(course);
InstructorAttributes instructor = logic.getInstructorForEmail(courseId, instructorEmail);
Assumption.assertNotNull(instructor);
EmailWrapper email = new EmailGenerator().generateInstructorCourseJoinEmail(inviter, instructor, course);
try {
emailSender.sendEmail(email);
} catch (Exception e) {
Assumption.fail("Unexpected error while sending email" + TeammatesException.toStringWithStackTrace(e));
}
}
use of teammates.common.util.EmailWrapper in project teammates by TEAMMATES.
the class SendEmailWorkerAction method execute.
@Override
public void execute() {
String emailSubject = getRequestParamValue(ParamsNames.EMAIL_SUBJECT);
Assumption.assertPostParamNotNull(ParamsNames.EMAIL_SUBJECT, emailSubject);
String emailContent = getRequestParamValue(ParamsNames.EMAIL_CONTENT);
Assumption.assertPostParamNotNull(ParamsNames.EMAIL_CONTENT, emailContent);
String emailSenderEmail = getRequestParamValue(ParamsNames.EMAIL_SENDER);
Assumption.assertPostParamNotNull(ParamsNames.EMAIL_SENDER, emailSenderEmail);
String emailSenderName = getRequestParamValue(ParamsNames.EMAIL_SENDERNAME);
String emailReceiver = getRequestParamValue(ParamsNames.EMAIL_RECEIVER);
Assumption.assertPostParamNotNull(ParamsNames.EMAIL_RECEIVER, emailReceiver);
String emailReply = getRequestParamValue(ParamsNames.EMAIL_REPLY_TO_ADDRESS);
Assumption.assertPostParamNotNull(ParamsNames.EMAIL_REPLY_TO_ADDRESS, emailReply);
EmailWrapper message = new EmailWrapper();
message.setRecipient(emailReceiver);
message.setSenderEmail(emailSenderEmail);
if (emailSenderName != null) {
message.setSenderName(emailSenderName);
}
message.setContent(emailContent);
message.setSubject(emailSubject);
message.setReplyTo(emailReply);
try {
emailSender.sendEmail(message);
} catch (Exception e) {
log.severe("Error while sending email via servlet: " + TeammatesException.toStringWithStackTrace(e));
setForRetry();
}
}
Aggregations