Search in sources :

Example 1 with ConversationMsgHitInfo

use of com.zimbra.soap.mail.type.ConversationMsgHitInfo in project zm-mailbox by Zimbra.

the class SearchResponse method doConvMsgHit.

private Element doConvMsgHit(Element el, Message msg, long numMsgsInConv) {
    // Folder ID useful when undoing a move to different folder, also determining whether in junk/trash
    ConversationMsgHitInfo cMsgHit = ConversationMsgHitInfo.fromIdAndFolderId(ifmt.formatItemId(msg), ifmt.formatItemId(new ItemId(msg.getMailbox().getAccountId(), msg.getFolderId())));
    // if it's a 1-message conversation, hand back size for the lone message
    if (numMsgsInConv == 1) {
        cMsgHit.setSize(msg.getSize());
    }
    if (msg.isDraft() && msg.getDraftAutoSendTime() != 0) {
        cMsgHit.setAutoSendTime(msg.getDraftAutoSendTime());
    }
    if (!msg.getFlagString().equalsIgnoreCase("")) {
        cMsgHit.setFlags(msg.getFlagString());
    }
    cMsgHit.setDate(msg.getDate());
    cMsgHit.toElement(el);
    return el;
}
Also used : ConversationMsgHitInfo(com.zimbra.soap.mail.type.ConversationMsgHitInfo) ItemId(com.zimbra.cs.service.util.ItemId)

Example 2 with ConversationMsgHitInfo

use of com.zimbra.soap.mail.type.ConversationMsgHitInfo in project zm-mailbox by Zimbra.

the class SearchResponse method add.

private Element add(ConversationHit hit) throws ServiceException {
    if (params.getFetchMode() == SearchParams.Fetch.IDS) {
        Element el = element.addNonUniqueElement(MailConstants.E_CONV);
        for (MessageHit mhit : hit.getMessageHits()) {
            ConversationMsgHitInfo cMsgHit = new ConversationMsgHitInfo(ifmt.formatItemId(mhit.getItemId()));
            cMsgHit.toElement(el);
        }
        return el;
    } else {
        Conversation conv = hit.getConversation();
        MessageHit mhit = hit.getFirstMessageHit();
        Element el = ToXML.encodeConversationSummary(element, ifmt, octxt, conv, mhit == null ? null : mhit.getMessage(), params.getWantRecipients());
        Collection<MessageHit> msgHits = hit.getMessageHits();
        long numMsgs = el.getAttributeLong(MailConstants.A_NUM, 0);
        if (!params.fullConversation() || numMsgs == msgHits.size()) {
            for (MessageHit mh : msgHits) {
                Message msg = mh.getMessage();
                doConvMsgHit(el, msg, numMsgs);
            }
        } else {
            for (Message msg : conv.getMailbox().getMessagesByConversation(octxt, conv.getId(), SortBy.DATE_DESC, -1, /* limit */
            false)) {
                doConvMsgHit(el, msg, numMsgs);
            }
        }
        return el;
    }
}
Also used : Message(com.zimbra.cs.mailbox.Message) Element(com.zimbra.common.soap.Element) MessageHit(com.zimbra.cs.index.MessageHit) ConversationMsgHitInfo(com.zimbra.soap.mail.type.ConversationMsgHitInfo) Conversation(com.zimbra.cs.mailbox.Conversation)

Aggregations

ConversationMsgHitInfo (com.zimbra.soap.mail.type.ConversationMsgHitInfo)2 Element (com.zimbra.common.soap.Element)1 MessageHit (com.zimbra.cs.index.MessageHit)1 Conversation (com.zimbra.cs.mailbox.Conversation)1 Message (com.zimbra.cs.mailbox.Message)1 ItemId (com.zimbra.cs.service.util.ItemId)1