From decd810adc9b0ba7708d07f20fd48069243eafef Mon Sep 17 00:00:00 2001 From: Webklex Date: Tue, 20 Oct 2020 20:17:41 +0200 Subject: [PATCH] IMAP::FT_PEEK removing "Seen" flag issue fixed #33 --- CHANGELOG.md | 7 +++++++ src/Message.php | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1600cdd3..80289ea0 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip ### Breaking changes - NaN +## [2.2.2] - 2020-10-20 +### Fixed +- IMAP::FT_PEEK removing "Seen" flag issue fixed #33 + +### Affected Classes +- [Message::class](src/Message.php) + ## [2.2.1] - 2020-10-19 ### Fixed - Header decoding problem fixed #31 diff --git a/src/Message.php b/src/Message.php index 95f5ab22..2e0d3ee1 100755 --- a/src/Message.php +++ b/src/Message.php @@ -227,7 +227,7 @@ public function __construct($msgn, $msglist, Client $client, $fetch_options = nu $this->parseBody(); } - if ($this->getFetchFlagsOption() === true && $this->flags->count() == 0) { + if ($this->getFetchFlagsOption() === true) { $this->parseFlags(); } } @@ -395,6 +395,10 @@ private function parseFlags() { public function parseBody() { $this->client->openFolder($this->folder_path); + if ($this->fetch_options == IMAP::FT_PEEK && $this->flags->count() == 0) { + $this->parseFlags(); + } + $contents = $this->client->getConnection()->content([$this->msgn]); if (!isset($contents[$this->msgn])) { throw new MessageContentFetchingException("no content found", 0); @@ -406,8 +410,7 @@ public function parseBody() { $this->fetchStructure($this->structure); if ($this->fetch_options == IMAP::FT_PEEK) { - $this->parseFlags(); - if ($this->getFlags()->get("seen") !== null) { + if ($this->getFlags()->get("seen") == null) { $this->unsetFlag("Seen"); } }