From e35d74be0b01bdc647316008ae8636296a205fb5 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Sun, 1 Jan 2023 17:13:04 +0100 Subject: [PATCH] Add support for search criterias ON, SENTON, SENTSINCE and SENTBEFORE --- .../libraries/MailSo/Imap/SearchCriterias.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/SearchCriterias.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/SearchCriterias.php index 1dcb6ec57..427345333 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/SearchCriterias.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/SearchCriterias.php @@ -19,8 +19,7 @@ namespace MailSo\Imap; abstract class SearchCriterias { const - RegEx = 'in|e?mail|from|to|subject|has|is|date|since|before|text|body|size|larger|bigger|smaller|maxsize|minsize|keyword|older_than|newer_than'; - + RegEx = 'in|e?mail|from|to|subject|has|is|date|since|before|text|body|size|larger|bigger|smaller|maxsize|minsize|keyword|older_than|newer_than|on|senton|sentsince|sentbefore'; /** https://datatracker.ietf.org/doc/html/rfc3501#section-6.4.4 @@ -66,22 +65,22 @@ abstract class SearchCriterias ☐ NOT Messages that do not match the specified search key. - ☐ ON + ✔ ON Messages whose internal date (disregarding time and timezone) is within the specified date. ✔ OR Messages that match either search key. - ☐ SENTBEFORE + ✔ SENTBEFORE Messages whose [RFC-2822] Date: header (disregarding time and timezone) is earlier than the specified date. - ☐ SENTON + ✔ SENTON Messages whose [RFC-2822] Date: header (disregarding time and timezone) is within the specified date. - ☐ SENTSINCE + ✔ SENTSINCE Messages whose [RFC-2822] Date: header (disregarding time and timezone) is within or later than the specified date. @@ -237,10 +236,14 @@ abstract class SearchCriterias $iTimeFilter = \max($iTimeFilter, $sValue); } break; + case 'ON': + case 'SENTON': + case 'SENTSINCE': + case 'SENTBEFORE': case 'BEFORE': $sValue = static::parseSearchDate($sRawValue); if ($sValue) { - $aCriteriasResult[] = 'BEFORE'; + $aCriteriasResult[] = $sName; $aCriteriasResult[] = \gmdate('j-M-Y', $sValue); } break; @@ -374,6 +377,10 @@ abstract class SearchCriterias case 'SMALLER': case 'LARGER': case 'SINCE': + case 'ON': + case 'SENTON': + case 'SENTSINCE': + case 'SENTBEFORE': case 'BEFORE': if (\strlen($mValue)) { $aResult[$sName] = $mValue;