Search in sources :

Example 1 with MessageConversation

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;
}
Also used : MessageConversation(org.hisp.dhis.message.MessageConversation)

Example 2 with MessageConversation

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;
}
Also used : MessageConversation(org.hisp.dhis.message.MessageConversation)

Example 3 with MessageConversation

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;
}
Also used : MessageConversation(org.hisp.dhis.message.MessageConversation)

Example 4 with MessageConversation

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;
}
Also used : MessageConversation(org.hisp.dhis.message.MessageConversation)

Example 5 with MessageConversation

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);
}
Also used : User(org.hisp.dhis.user.User) NotAuthenticatedException(org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException) MessageConversation(org.hisp.dhis.message.MessageConversation) Interpretation(org.hisp.dhis.interpretation.Interpretation) Inbox(org.hisp.dhis.webapi.webdomain.user.Inbox) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

MessageConversation (org.hisp.dhis.message.MessageConversation)10 User (org.hisp.dhis.user.User)4 NotAuthenticatedException (org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Semver (com.vdurmont.semver4j.Semver)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Interpretation (org.hisp.dhis.interpretation.Interpretation)1 MessageConversationParams (org.hisp.dhis.message.MessageConversationParams)1 UserMessage (org.hisp.dhis.message.UserMessage)1 Inbox (org.hisp.dhis.webapi.webdomain.user.Inbox)1