diff --git a/lib/Db/MessageMapper.php b/lib/Db/MessageMapper.php index 47cf21292a..9bae7d1642 100644 --- a/lib/Db/MessageMapper.php +++ b/lib/Db/MessageMapper.php @@ -279,8 +279,9 @@ public function insertBulk(Account $account, Message ...$messages): void { $qb1->setValue('flag_notjunk', $qb1->createParameter('flag_notjunk')); $qb1->setValue('flag_important', $qb1->createParameter('flag_important')); $qb1->setValue('flag_mdnsent', $qb1->createParameter('flag_mdnsent')); - $qb2 = $this->db->getQueryBuilder(); + $qb1->setValue('imip_message', $qb1->createParameter('imip_message')); + $qb2 = $this->db->getQueryBuilder(); $qb2->insert('mail_recipients') ->setValue('message_id', $qb2->createParameter('message_id')) ->setValue('type', $qb2->createParameter('type')) @@ -309,6 +310,7 @@ public function insertBulk(Account $account, Message ...$messages): void { $qb1->setParameter('flag_notjunk', $message->getFlagNotjunk(), IQueryBuilder::PARAM_BOOL); $qb1->setParameter('flag_important', $message->getFlagImportant(), IQueryBuilder::PARAM_BOOL); $qb1->setParameter('flag_mdnsent', $message->getFlagMdnsent(), IQueryBuilder::PARAM_BOOL); + $qb1->setParameter('imip_message', $message->isImipMessage(), IQueryBuilder::PARAM_BOOL); $qb1->executeStatement(); $message->setId($qb1->getLastInsertId()); diff --git a/lib/IMAP/ImapMessageFetcher.php b/lib/IMAP/ImapMessageFetcher.php index e3cd701513..4f49718471 100644 --- a/lib/IMAP/ImapMessageFetcher.php +++ b/lib/IMAP/ImapMessageFetcher.php @@ -203,24 +203,11 @@ public function fetchMessage(?Horde_Imap_Client_Data_Fetch $fetch = null): IMAPM 'forcemime' => true, ]); } - - // debugging below - $structure_type = $structure->getPrimaryType(); - if ($structure_type === 'multipart') { - $i = 1; - foreach ($structure->getParts() as $p) { - $this->getPart($p, (string)$i++, $isEncrypted || $isSigned); - } - } else { - $bodyPartId = $structure->findBody(); - if (!is_null($bodyPartId)) { - $this->getPart($structure[$bodyPartId], $bodyPartId, $isEncrypted || $isSigned); - } - } } elseif (is_null($fetch)) { // Reuse given query or construct a new minimal one $query = new Horde_Imap_Client_Fetch_Query(); $query->envelope(); + $query->structure(); $query->flags(); $query->imapDate(); $query->headerText([ @@ -234,6 +221,29 @@ public function fetchMessage(?Horde_Imap_Client_Data_Fetch $fetch = null): IMAPM } } + // determine if message structure was already extracted + if (!isset($structure)) { + // extract message structure + $structure = $fetch->getStructure(); + } + // determine if we finally have a message structure + // and process the message parts if structure exists + if ($structure !== null) { + // debugging below + $structure_type = $structure->getPrimaryType(); + if ($structure_type === 'multipart') { + $i = 1; + foreach ($structure->getParts() as $p) { + $this->getPart($p, (string)$i++, $isEncrypted || $isSigned); + } + } else { + $bodyPartId = $structure->findBody(); + if (!is_null($bodyPartId)) { + $this->getPart($structure[$bodyPartId], $bodyPartId, $isEncrypted || $isSigned); + } + } + } + $this->parseHeaders($fetch); $envelope = $fetch->getEnvelope(); diff --git a/lib/IMAP/MessageMapper.php b/lib/IMAP/MessageMapper.php index 6738f6d963..a278c4dc2a 100644 --- a/lib/IMAP/MessageMapper.php +++ b/lib/IMAP/MessageMapper.php @@ -253,6 +253,7 @@ public function findByIds(Horde_Imap_Client_Base $client, bool $runPhishingCheck = false): array { $query = new Horde_Imap_Client_Fetch_Query(); $query->envelope(); + $query->structure(); $query->flags(); $query->uid(); $query->imapDate();