Search in sources :

Example 1 with MessageType

use of de.symeda.sormas.api.messaging.MessageType in project SORMAS-Project by hzi-braunschweig.

the class MessagingService method sendManualMessage.

public void sendManualMessage(Person recipient, String subject, String messageContent, MessageType... messageTypes) throws NotificationDeliveryFailedException {
    final String emailAddress = recipient.getEmailAddress();
    final String phoneNumber = recipient.getPhone();
    final String recipientUuid = recipient.getUuid();
    final String recipientType = "person";
    for (MessageType messageType : messageTypes) {
        if (messageType == MessageType.EMAIL) {
            sendEmail(subject, messageContent, emailAddress, recipientUuid, recipientType);
        } else if (messageType == MessageType.SMS) {
            sendSms(subject, messageContent, phoneNumber, recipientUuid, recipientType);
        }
        final ManualMessageLog manualMessageLog = new ManualMessageLog();
        manualMessageLog.setMessageType(messageType);
        manualMessageLog.setRecipientPerson(recipient);
        manualMessageLog.setSendingUser(userService.getCurrentUser());
        manualMessageLog.setSentDate(new Date());
        manualMessageLogService.ensurePersisted(manualMessageLog);
    }
}
Also used : MessageType(de.symeda.sormas.api.messaging.MessageType) Date(java.util.Date)

Aggregations

MessageType (de.symeda.sormas.api.messaging.MessageType)1 Date (java.util.Date)1