From 680c72eb3a2b15b620cd1b2c464f120eaab6be0d Mon Sep 17 00:00:00 2001 From: Hamza Mahjoubi Date: Fri, 11 Oct 2024 14:09:05 +0200 Subject: [PATCH] fixup! feat: fiter messages by mention Signed-off-by: Hamza Mahjoubi --- lib/IMAP/MessageMapper.php | 10 +++++++--- lib/IMAP/MessageStructureData.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/IMAP/MessageMapper.php b/lib/IMAP/MessageMapper.php index 01f00b1ecf..da8d55a837 100644 --- a/lib/IMAP/MessageMapper.php +++ b/lib/IMAP/MessageMapper.php @@ -901,7 +901,7 @@ public function getBodyStructureData(Horde_Imap_Client_Socket $client, $textBodyId = $structure->findBody() ?? $structure->findBody('text'); $htmlBodyId = $structure->findBody('html'); if ($textBodyId === null && $htmlBodyId === null) { - return new MessageStructureData($hasAttachments, $text, $isImipMessage, $isEncrypted); + return new MessageStructureData($hasAttachments, $text, $isImipMessage, $isEncrypted, false); } $partsQuery = new Horde_Imap_Client_Fetch_Query(); if ($htmlBodyId !== null) { @@ -927,7 +927,7 @@ public function getBodyStructureData(Horde_Imap_Client_Socket $client, $part = $parts[$fetchData->getUid()]; // This is sus - why does this even happen? A delete / move in the middle of this processing? if ($part === null) { - return new MessageStructureData($hasAttachments, $text, $isImipMessage, $isEncrypted); + return new MessageStructureData($hasAttachments, $text, $isImipMessage, $isEncrypted, false); } @@ -963,12 +963,16 @@ public function getBodyStructureData(Horde_Imap_Client_Socket $client, $textBody, $isImipMessage, $isEncrypted, + false, ); } - return new MessageStructureData($hasAttachments, $text, $isImipMessage, $isEncrypted); + return new MessageStructureData($hasAttachments, $text, $isImipMessage, $isEncrypted, false); }, iterator_to_array($structures->getIterator())); } private function checkLinks(string $body, string $mailAddress) : bool { + if(strlen($body) === 0) { + return false; + } $dom = new \DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($body); diff --git a/lib/IMAP/MessageStructureData.php b/lib/IMAP/MessageStructureData.php index 225878ca14..fc58ef9c84 100644 --- a/lib/IMAP/MessageStructureData.php +++ b/lib/IMAP/MessageStructureData.php @@ -26,7 +26,7 @@ public function __construct(bool $hasAttachments, string $previewText, bool $isImipMessage, bool $isEncrypted, - ?bool $mentionsMe = false) { + bool $mentionsMe) { $this->hasAttachments = $hasAttachments; $this->previewText = $previewText; $this->isImipMessage = $isImipMessage;