Search in sources :

Example 1 with IcalHandler

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);
    }
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) MailMessage(org.apache.openmeetings.db.entity.basic.MailMessage) IApplication(org.apache.openmeetings.IApplication) User(org.apache.openmeetings.db.entity.user.User) ArrayList(java.util.ArrayList) IcalHandler(org.apache.openmeetings.util.mail.IcalHandler) Map(java.util.Map)

Example 2 with IcalHandler

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);
    }
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ArrayList(java.util.ArrayList) IcalHandler(org.apache.openmeetings.util.mail.IcalHandler) Map(java.util.Map) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 IcalHandler (org.apache.openmeetings.util.mail.IcalHandler)2 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 IApplication (org.apache.openmeetings.IApplication)1 MailMessage (org.apache.openmeetings.db.entity.basic.MailMessage)1 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)1 User (org.apache.openmeetings.db.entity.user.User)1 Test (org.junit.Test)1