use of org.apache.openmeetings.util.mail.IcalHandler in project openmeetings by apache.
the class InvitationManager method sendInvitationLink.
@Override
public void sendInvitationLink(Invitation i, MessageType type, String subject, String message, boolean ical) throws Exception {
String invitationLink = null;
if (type != MessageType.Cancel) {
IApplication app = ensureApplication(1L);
invitationLink = app.getOmInvitationLink(i);
}
User owner = i.getInvitedBy();
String invitorName = owner.getFirstname() + " " + owner.getLastname();
String template = InvitationTemplate.getEmail(i.getInvitee(), invitorName, message, invitationLink);
String email = i.getInvitee().getAddress().getEmail();
String replyToEmail = owner.getAddress().getEmail();
if (ical) {
String username = i.getInvitee().getLogin();
boolean isOwner = owner.getId().equals(i.getInvitee().getId());
IcalHandler handler = new IcalHandler(MessageType.Cancel == type ? IcalHandler.ICAL_METHOD_CANCEL : IcalHandler.ICAL_METHOD_REQUEST);
Map<String, String> attendeeList = handler.getAttendeeData(email, username, isOwner);
List<Map<String, String>> atts = new ArrayList<>();
atts.add(attendeeList);
// Defining Organizer
Map<String, String> organizerAttendee = handler.getAttendeeData(replyToEmail, owner.getLogin(), isOwner);
Appointment a = i.getAppointment();
// Create ICal Message
String meetingId = handler.addNewMeeting(a.getStart(), a.getEnd(), a.getTitle(), atts, invitationLink, organizerAttendee, a.getIcalId(), getTimeZone(owner).getID());
// Writing back meetingUid
if (Strings.isEmpty(a.getIcalId())) {
a.setIcalId(meetingId);
}
log.debug(handler.getICalDataAsString());
mailHandler.send(new MailMessage(email, replyToEmail, subject, template, handler.getIcalAsByteArray()));
} else {
mailHandler.send(email, replyToEmail, subject, template);
}
}
use of org.apache.openmeetings.util.mail.IcalHandler in project openmeetings by apache.
the class TestSendIcalMessage method sendInvitionIcalLink.
@Test
public void sendInvitionIcalLink() {
try {
String email = "hans@webbase-design.de";
String username = "shans";
boolean invitor = false;
Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance();
IcalHandler handler = new IcalHandler(IcalHandler.ICAL_METHOD_REQUEST);
// Transforming Meeting Members
Map<String, String> attendeeList = handler.getAttendeeData(email, username, invitor);
Map<String, String> organizerAttendee = handler.getAttendeeData(recipients, "seba-test", true);
List<Map<String, String>> atts = new ArrayList<>();
atts.add(attendeeList);
// Create ICal Message
String meetingId = handler.addNewMeeting(start.getTime(), end.getTime(), "test event", atts, "localhost:5080/link_openmeetings", organizerAttendee, "", java.util.TimeZone.getDefault().getID());
log.debug("meetingId " + meetingId);
iCalMimeBody = handler.getIcalAsByteArray();
sendIcalMessage();
// return MailHandler.sendMail(email, subject, template);
} catch (Exception err) {
log.error("sendInvitionIcalLink", err);
}
}
Aggregations