Bug 1492905 - nsMsgCompose::RememberQueuedDisposition() shouldn't hand-roll URIs to retrieve message header. r=jorgk
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 20 Sep 2018 10:03:00 +0200
changeset 33204 97064b1acf5339bb5e78fd2f90bac5a4ea332d76
parent 33203 1824f784b446e87be3d92137ed51f2fb73c3f1bd
child 33205 a01d1481ef18bb394581e01a9c5950829aae22a4
push id387
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:30:47 +0000
reviewersjorgk
bugs1492905
Bug 1492905 - nsMsgCompose::RememberQueuedDisposition() shouldn't hand-roll URIs to retrieve message header. r=jorgk
mailnews/compose/src/nsMsgCompose.cpp
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -3379,28 +3379,34 @@ NS_IMETHODIMP nsMsgCompose::RememberQueu
       draftHdr->GetStringProperty(QUEUED_DISPOSITION_PROPERTY, getter_Copies(dispositionSetting));
     }
   }
 
   nsMsgKey msgKey;
   if (mMsgSend)
   {
     mMsgSend->GetMessageKey(&msgKey);
-    nsAutoCString msgUri(m_folderName);
     nsCString identityKey;
 
     m_identity->GetKey(identityKey);
 
-    int32_t insertIndex = StringBeginsWith(msgUri, NS_LITERAL_CSTRING("mailbox")) ? 7 : 4;
-    msgUri.InsertLiteral("-message", insertIndex); // "mailbox/imap: -> "mailbox/imap-message:"
-    msgUri.Append('#');
-    msgUri.AppendInt(msgKey);
+    nsCOMPtr<nsIRDFService> rdfService(do_GetService("@mozilla.org/rdf/rdf-service;1", &rv));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    nsCOMPtr <nsIRDFResource> resource;
+    rv = rdfService->GetResource(m_folderName, getter_AddRefs(resource));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    nsCOMPtr<nsIMsgFolder> folder(do_QueryInterface(resource, &rv));
+    NS_ENSURE_SUCCESS(rv, rv);
+
     nsCOMPtr <nsIMsgDBHdr> msgHdr;
-    rv = GetMsgDBHdrFromURI(msgUri.get(), getter_AddRefs(msgHdr));
+    rv = folder->GetMessageHeader(msgKey, getter_AddRefs(msgHdr));
     NS_ENSURE_SUCCESS(rv, rv);
+
     uint32_t pseudoHdrProp = 0;
     msgHdr->GetUint32Property("pseudoHdr", &pseudoHdrProp);
     if (pseudoHdrProp)
     {
       // Use SetAttributeOnPendingHdr for IMAP pseudo headers, as those
       // will get deleted (and properties set using SetStringProperty lost.)
       nsCOMPtr<nsIMsgFolder> folder;
       rv = msgHdr->GetFolder(getter_AddRefs(folder));