diff options
-rw-r--r-- | lib/Db/Message.php | 2 | ||||
-rw-r--r-- | tests/Integration/Db/MessageTest.php | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/lib/Db/Message.php b/lib/Db/Message.php index a8ae3a28c..adc965db5 100644 --- a/lib/Db/Message.php +++ b/lib/Db/Message.php @@ -177,7 +177,7 @@ class Message extends Entity implements JsonSerializable { } private function setMessageIdFieldIfNotEmpty(string $field, ?string $id): void { - $id = ($id !== null) ? '<' . rtrim(ltrim($id, '<'), '>') . '>' : null; + $id = (!empty($id)) ? '<' . rtrim(ltrim($id, '<'), '>') . '>' : null; $parsed = new Horde_Mail_Rfc822_Identification($id); $this->setter($field, [$parsed->ids[0] ?? null]); } diff --git a/tests/Integration/Db/MessageTest.php b/tests/Integration/Db/MessageTest.php index 1ea5e4a7b..be891eed1 100644 --- a/tests/Integration/Db/MessageTest.php +++ b/tests/Integration/Db/MessageTest.php @@ -86,4 +86,28 @@ class MessageTest extends TestCase { $this->assertEquals($expected, $message->getMessageId()); $this->assertNull($message->getThreadRootId()); } + + public function testThreadrootIdEmptyString(): void { + $expected = '<abc@123.com>'; + $message = new Message(); + + $message->setMessageId($expected); + $message->setThreadRootId(''); + + $this->assertEquals($expected, $message->getMessageId()); + $this->assertNull($message->getThreadRootId()); + } + + public function testSetInReplyToEmpty(): void { + $expected = '<abc@123.com>'; + $message = new Message(); + + $message->setMessageId($expected); + $message->setThreadRootId(''); + $message->setInReplyTo(''); + + $this->assertEquals($expected, $message->getMessageId()); + $this->assertNull($message->getThreadRootId()); + $this->assertNull($message->getInReplyTo()); + } } |