use of org.hisp.dhis.message.MessageConversation 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);
}
}
}
}
use of org.hisp.dhis.message.MessageConversation in project dhis2-core by dhis2.
the class CurrentUserController method getInboxMessageConversations.
@RequestMapping(value = "/inbox/messageConversations", produces = { "application/json", "text/*" })
public void getInboxMessageConversations(HttpServletResponse response) throws Exception {
User user = currentUserService.getCurrentUser();
if (user == null) {
throw new NotAuthenticatedException();
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
List<MessageConversation> messageConversations = new ArrayList<>(messageService.getMessageConversations(0, MAX_OBJECTS));
for (org.hisp.dhis.message.MessageConversation messageConversation : messageConversations) {
messageConversation.setAccess(aclService.getAccess(messageConversation, user));
}
renderService.toJson(response.getOutputStream(), messageConversations);
}
use of org.hisp.dhis.message.MessageConversation in project dhis2-core by dhis2.
the class ToggleFollowUpAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
MessageConversation conversation = messageService.getMessageConversation(id);
message = String.valueOf(conversation.toggleFollowUp(currentUserService.getCurrentUser()));
messageService.updateMessageConversation(conversation);
return SUCCESS;
}
use of org.hisp.dhis.message.MessageConversation in project dhis2-core by dhis2.
the class SendReplyAction method execute.
// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
Assert.hasText(text, "Text must be defined");
String metaData = MessageService.META_USER_AGENT + ServletActionContext.getRequest().getHeader(ContextUtils.HEADER_USER_AGENT);
MessageConversation conversation = messageService.getMessageConversation(conversationId);
messageService.sendReply(conversation, text, metaData, false);
return SUCCESS;
}
use of org.hisp.dhis.message.MessageConversation in project dhis2-core by dhis2.
the class HibernateMessageConversationStore method mapRowToMessageConversations.
private MessageConversation mapRowToMessageConversations(Object[] row) {
MessageConversation mc = (MessageConversation) row[0];
UserMessage um = (UserMessage) row[1];
User ui = (User) row[2];
User ls = (User) row[3];
mc.setRead(um.isRead());
mc.setFollowUp(um.isFollowUp());
if (ui != null) {
mc.setUserFirstname(ui.getFirstName());
mc.setUserSurname(ui.getSurname());
}
if (ls != null) {
mc.setLastSenderFirstname(ls.getFirstName());
mc.setLastSenderSurname(ls.getSurname());
}
return mc;
}
Aggregations