Search in sources :

Example 1 with FlashMessage

use of eu.bcvsolutions.idm.core.notification.api.dto.FlashMessage in project CzechIdMng by bcvsolutions.

the class DefaultWebsocketNotificationSender method send.

@Override
@Transactional
public IdmWebsocketLogDto send(IdmNotificationDto notification) {
    Assert.notNull(notification, "Notification is required!");
    // 
    LOG.info("Adding websocket notification to queue [{}]", notification);
    IdmWebsocketLogDto log = createLog(notification);
    // send flashmessage
    FlashMessage message = toFlashMessage(log);
    for (IdmNotificationRecipientDto recipient : log.getRecipients()) {
        if (Strings.isNullOrEmpty(recipient.getRealRecipient())) {
            LOG.warn("Real recipient is empty for notification [{}]", notification);
        } else {
            websocket.convertAndSendToUser(recipient.getRealRecipient(), // TODO: configurable
            "/queue/messages", message);
        }
    }
    return log;
}
Also used : IdmWebsocketLogDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmWebsocketLogDto) FlashMessage(eu.bcvsolutions.idm.core.notification.api.dto.FlashMessage) IdmNotificationRecipientDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with FlashMessage

use of eu.bcvsolutions.idm.core.notification.api.dto.FlashMessage in project CzechIdMng by bcvsolutions.

the class DefaultWebsocketNotificationSender method toFlashMessage.

private FlashMessage toFlashMessage(IdmWebsocketLogDto log) {
    IdmMessageDto message = this.getMessage(log, true);
    // 
    FlashMessage flashMessage = new FlashMessage();
    flashMessage.setId(log.getId());
    flashMessage.setKey(log.getTopic());
    flashMessage.setTitle(message.getSubject());
    // default message
    flashMessage.setMessage(message.getTextMessage());
    flashMessage.setDate(log.getCreated());
    flashMessage.setLevel(message.getLevel() == null ? null : message.getLevel().toString().toLowerCase());
    flashMessage.setModel(message.getModel());
    // TODO: other params
    flashMessage.setPosition("tr");
    return flashMessage;
}
Also used : IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) FlashMessage(eu.bcvsolutions.idm.core.notification.api.dto.FlashMessage)

Aggregations

FlashMessage (eu.bcvsolutions.idm.core.notification.api.dto.FlashMessage)2 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)1 IdmNotificationRecipientDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationRecipientDto)1 IdmWebsocketLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmWebsocketLogDto)1 Transactional (org.springframework.transaction.annotation.Transactional)1