From ccdb16a068c25d40010de7b98630a67e1d12d95d Mon Sep 17 00:00:00 2001 From: Jorg K Date: Tue, 28 Apr 2020 12:32:19 +0200 Subject: [PATCH] Bug 1633205 - Pay attention to HasRe flag in nsImapMailFolder::SetPendingAttributes() and nsMsgLocalMailFolder::EndCopy(). r=benc DONTBUILD --- mailnews/imap/src/nsImapMailFolder.cpp | 13 +++++++++++-- mailnews/local/src/nsLocalMailFolder.cpp | 15 +++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index d05a863f32..429b3e613a 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -6918,6 +6918,15 @@ void nsImapMailFolder::SetPendingAttributes( sourceString.get()); } + // Carry over HasRe flag. + uint32_t flags; + uint32_t storeFlags = 0; + msgDBHdr->GetFlags(&flags); + if (flags & nsMsgMessageFlags::HasRe) { + storeFlags = nsMsgMessageFlags::HasRe; + mDatabase->SetUint32AttributeOnPendingHdr(msgDBHdr, "flags", storeFlags); + } + uint32_t messageSize; uint64_t messageOffset; nsCString storeToken; @@ -6933,8 +6942,8 @@ void nsImapMailFolder::SetPendingAttributes( // here because it can cause missing parts (inline or attachments) // when messages are moved or copied manually or by filter action. if (aSetOffline) - mDatabase->SetUint32AttributeOnPendingHdr(msgDBHdr, "flags", - nsMsgMessageFlags::Offline); + mDatabase->SetUint32AttributeOnPendingHdr( + msgDBHdr, "flags", storeFlags | nsMsgMessageFlags::Offline); mDatabase->SetAttributeOnPendingHdr(msgDBHdr, "storeToken", storeToken.get()); } diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index ca5f404807..74f01799a2 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -2248,14 +2248,17 @@ nsMsgLocalMailFolder::EndCopy(bool aCopySucceeded) { // Flags may get changed when deleting the original source message in // IMAP. We have a copy of the original flags, but parseMsgState has // already tried to decide what those flags should be. Who to believe? - // Let's only deal here with the flags that might get changed, Read - // and New, and trust upstream code for everything else. - uint32_t readAndNew = - nsMsgMessageFlags::New | nsMsgMessageFlags::Read; + // Let's deal here with the flags that might get changed, Read and + // New, and trust upstream code for everything else. However, + // we need to carry over HasRe since the subject is copied over + // from the original. + uint32_t carryOver = nsMsgMessageFlags::New | + nsMsgMessageFlags::Read | + nsMsgMessageFlags::HasRe; uint32_t newFlags; newHdr->GetFlags(&newFlags); - newHdr->SetFlags((newFlags & ~readAndNew) | - ((mCopyState->m_flags) & readAndNew)); + newHdr->SetFlags((newFlags & ~carryOver) | + ((mCopyState->m_flags) & carryOver)); // Copy other message properties. CopyPropertiesToMsgHdr(newHdr, mCopyState->m_message,