use of org.hisp.dhis.message.MessageConversation in project dhis2-core by dhis2.
the class GetMessageAction method execute.
// -------------------------------------------------------------------------
// Action Implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
MessageConversation conversation = messageService.getMessageConversation(conversationId);
subject = conversation.getSubject();
messages = new ArrayList<>(conversation.getMessages());
Collections.reverse(messages);
conversation.markRead(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() {
String metaData = MessageService.META_USER_AGENT + ServletActionContext.getRequest().getHeader(ContextUtils.HEADER_USER_AGENT);
MessageConversation conversation = messageService.getMessageConversation(id);
messageService.sendReply(conversation, text, metaData, (internal && messageService.hasAccessToManageFeedbackMessages(currentUserService.getCurrentUser())));
return SUCCESS;
}
use of org.hisp.dhis.message.MessageConversation in project dhis2-core by dhis2.
the class UnreadMessageAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
MessageConversation conversation = messageService.getMessageConversation(id);
conversation.markUnread(currentUserService.getCurrentUser());
messageService.updateMessageConversation(conversation);
return SUCCESS;
}
use of org.hisp.dhis.message.MessageConversation in project dhis2-core by dhis2.
the class RemoveMessageAction method execute.
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
MessageConversation conversation = messageService.getMessageConversation(id);
conversation.remove(currentUserService.getCurrentUser());
messageService.updateMessageConversation(conversation);
return SUCCESS;
}
use of org.hisp.dhis.message.MessageConversation in project dhis2-core by dhis2.
the class CurrentUserController method getInbox.
@RequestMapping(value = "/inbox", produces = { "application/json", "text/*" })
public void getInbox(HttpServletResponse response) throws Exception {
User user = currentUserService.getCurrentUser();
if (user == null) {
throw new NotAuthenticatedException();
}
Inbox inbox = new Inbox();
inbox.setMessageConversations(new ArrayList<>(messageService.getMessageConversations(0, MAX_OBJECTS)));
inbox.setInterpretations(new ArrayList<>(interpretationService.getInterpretations(0, MAX_OBJECTS)));
for (org.hisp.dhis.message.MessageConversation messageConversation : inbox.getMessageConversations()) {
messageConversation.setAccess(aclService.getAccess(messageConversation, user));
}
for (Interpretation interpretation : inbox.getInterpretations()) {
interpretation.setAccess(aclService.getAccess(interpretation, user));
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
renderService.toJson(response.getOutputStream(), inbox);
}
Aggregations