use of com.zimbra.client.ZMailbox.TagSpecifier in project zm-mailbox by Zimbra.
the class AppendMessage method store.
private int store(ImapMailboxStore mboxStore, FolderStore folderStore) throws ImapSessionClosedException, ServiceException, IOException {
if (mboxStore instanceof LocalImapMailboxStore) {
boolean idxAttach = ((LocalImapMailboxStore) mboxStore).attachmentsIndexingEnabled();
Long receivedDate = date != null ? date.getTime() : null;
ParsedMessage pm = new ParsedMessage(content, receivedDate, idxAttach);
try {
if (!pm.getSender().isEmpty()) {
InternetAddress ia = new JavaMailInternetAddress(pm.getSender());
if (mboxStore.addressMatchesAccountOrSendAs(ia.getAddress())) {
flags |= Flag.BITMASK_FROM_ME;
}
}
} catch (Exception e) {
}
int folderId = Integer.parseInt(folderStore.getFolderIdAsString());
DeliveryOptions dopt = new DeliveryOptions().setFolderId(folderId).setNoICal(true).setFlags(flags).setTags(tags);
Message msg = ((LocalImapMailboxStore) mboxStore).getMailbox().addMessage(handler.getContext(), pm, dopt, null);
if (msg != null && sflags != 0 && handler.getState() == ImapHandler.State.SELECTED) {
ImapFolder selectedFolder = handler.getSelectedFolder();
// (note that this leaves session flags unset on remote appended messages)
if (selectedFolder != null) {
ImapMessage i4msg = selectedFolder.getById(msg.getId());
if (i4msg != null) {
i4msg.setSessionFlags(sflags, selectedFolder);
}
}
}
return msg == null ? -1 : msg.getId();
}
if (mboxStore instanceof RemoteImapMailboxStore) {
String id;
try (InputStream is = content.getInputStream()) {
TagSpecifier tagSpec = tags.isEmpty() ? null : TagSpecifier.tagByName(Joiner.on(",").join(tags));
long receivedDate = date != null ? date.getTime() : 0;
id = ((RemoteImapMailboxStore) mboxStore).getZMailbox().addMessage(folderStore.getFolderIdAsString(), Flag.toString(flags), tagSpec, receivedDate, is, content.getRawSize(), true);
}
int msgId = new ItemId(id, mboxStore.getAccountId()).getId();
ImapFolder selectedFolder = handler.getSelectedFolder();
if (selectedFolder != null) {
ImapMessage i4msg = selectedFolder.getById(msgId);
if (i4msg != null) {
i4msg.setSessionFlags(sflags, selectedFolder);
}
}
return msgId;
}
return -1;
}
Aggregations