use of org.hisp.dhis.message.MessageConversationParams in project dhis2-core by dhis2.
the class SystemUpdateService method sendMessageForEachVersion.
public void sendMessageForEachVersion(Map<Semver, Map<String, String>> patchVersions) {
Set<User> recipients = getRecipients();
for (Map.Entry<Semver, Map<String, String>> entry : patchVersions.entrySet()) {
Semver version = entry.getKey();
Map<String, String> message = entry.getValue();
for (User recipient : recipients) {
// Check if message has been sent before using
// version.getValue() as extMessageId
List<MessageConversation> existingMessages = messageService.getMatchingExtId(version.getValue());
if (existingMessages.isEmpty()) {
MessageConversationParams params = new MessageConversationParams.Builder().withRecipients(ImmutableSet.of(recipient)).withSubject(NEW_VERSION_AVAILABLE_MESSAGE_SUBJECT).withText(buildMessageText(message)).withMessageType(MessageType.SYSTEM).withExtMessageId(version.getValue()).build();
messageService.sendMessage(params);
}
}
}
}
Aggregations