Skip to content

Commit

Permalink
Merge branch '2024.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Jan 13, 2025
2 parents 99ab98f + 04f1fb6 commit 1a5c5fd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 25 deletions.
65 changes: 46 additions & 19 deletions tests/tine20/Felamimail/Frontend/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ public function testSearchFolders()
*/
public function testClearFolder()
{
$folderName = $this->_testFolderName;
$folder = $this->_getFolder($this->_testFolderName);
$folder = Felamimail_Controller_Folder::getInstance()->emptyFolder($folder->getId());

Expand Down Expand Up @@ -1020,7 +1019,7 @@ public function testMoveMessagesToTrash()
$message = $this->_sendMessage();
$this->_foldersToClear = array('INBOX', $this->_account->sent_folder, $this->_account->trash_folder);

$result = $this->_json->moveMessages(array(array(
$this->_json->moveMessages(array(array(
'field' => 'id', 'operator' => 'in', 'value' => array($message['id'])
)), Felamimail_Model_Folder::FOLDER_TRASH);

Expand Down Expand Up @@ -1056,8 +1055,6 @@ public function testMoveMessagesWithoutSelectionToTrash()
*/
public function testReplyMessage()
{
self::markTestSkipped('FIXME: fails at random');

$message = $this->_sendMessage();

$replyMessage = $this->_getReply($message);
Expand Down Expand Up @@ -1112,17 +1109,40 @@ protected function _getReply($_original)
*/
public function testReplyMessageInSentFolder()
{
self::markTestSkipped('FIXME: fails at random');

$messageInSent = $this->_sendMessage($this->_account->sent_folder);
$replyMessage = $this->_getReply($messageInSent);
$returned = $this->_json->saveMessage($replyMessage);
$this->_json->saveMessage($replyMessage);

$result = $this->_getMessages();
$sentMessage = $this->_getMessageFromSearchResult($result, $replyMessage['subject']);
$this->assertTrue(!empty($sentMessage));
}

public function testReplyForwardDeletedMessage(): void
{
$messageInSent = $this->_sendMessage($this->_account->sent_folder);
$replyMessage = $this->_getReply($messageInSent);
$this->_json->moveMessages(array(array(
'field' => 'id', 'operator' => 'in', 'value' => array($messageInSent['id'])
)), Felamimail_Model_Folder::FOLDER_TRASH);
$returned = $this->_json->saveMessage($replyMessage);
self::assertArrayHasKey('In-Reply-To', $returned['headers']);

// forward moved message
$forwardMessageData = $this->_getForwardMessageData($messageInSent['id']);
$this->_foldersToClear[] = 'INBOX';
$this->_json->saveMessage($forwardMessageData);

// now we expunge trash & try again
$folder = $this->_getFolder('TRASH');
Felamimail_Controller_Folder::getInstance()->emptyFolder($folder->getId());

$this->_json->saveMessage($replyMessage);

// NOTE: not sure if forwarding should work in all cases - receipient might wonder about some missing attachments
$this->_json->saveMessage($forwardMessageData);
}

/**
* test reply mail with long references header
*
Expand Down Expand Up @@ -1266,19 +1286,9 @@ public function testForwardMessageWithAttachment()
$message = $this->_appendMessageforForwarding();

$fwdSubject = 'Fwd: ' . $message['subject'];
$forwardMessageData = array(
'account_id' => $this->_account->getId(),
$forwardMessageData = $this->_getForwardMessageData($message['id'], [
'subject' => $fwdSubject,
'to' => array($this->_getEmailAddress()),
'body' => "aaaaaä <br>",
'headers' => array('X-Tine20TestMessage' => 'jsontest'),
'original_id' => $message['id'],
'attachments' => array(new Tinebase_Model_TempFile(array(
'type' => Felamimail_Model_Message::CONTENT_TYPE_MESSAGE_RFC822,
'name' => 'Verbessurüngsvorschlag',
), TRUE)),
'flags' => Zend_Mail_Storage::FLAG_PASSED,
);
]);

$this->_foldersToClear[] = 'INBOX';
$this->_json->saveMessage($forwardMessageData);
Expand All @@ -1301,6 +1311,23 @@ public function testForwardMessageWithAttachment()
'forwarded flag missing in flags: ' . print_r($message, TRUE));
}

protected function _getForwardMessageData(string $originalMessageId, array $data = []): array
{
return array_merge([
'account_id' => $this->_account->getId(),
'subject' => 'fwd message test',
'to' => array($this->_getEmailAddress()),
'body' => "aaaaaä <br>",
'headers' => array('X-Tine20TestMessage' => 'jsontest'),
'original_id' => $originalMessageId,
'attachments' => array(new Tinebase_Model_TempFile(array(
'type' => Felamimail_Model_Message::CONTENT_TYPE_MESSAGE_RFC822,
'name' => 'Verbessurüngsvorschlag',
), TRUE)),
'flags' => Zend_Mail_Storage::FLAG_PASSED,
], $data);
}

protected function _appendMessageforForwarding($file = 'multipart_related.eml', $subject = 'Tine 2.0 bei Metaways - Verbessurngsvorschlag')
{
$testFolder = $this->_getFolder($this->_testFolderName);
Expand Down
11 changes: 5 additions & 6 deletions tine20/Felamimail/Controller/Message/Send.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class_implements($class)
*
* @param Felamimail_Model_Message $_message
*/
protected function _resolveOriginalMessage(Felamimail_Model_Message $_message)
protected function _resolveOriginalMessage(Felamimail_Model_Message $_message): void
{
if (! $_message->original_id || $_message->original_id instanceof Felamimail_Model_Message) {
return;
Expand All @@ -259,12 +259,11 @@ protected function _resolveOriginalMessage(Felamimail_Model_Message $_message)
$originalMessage = Felamimail_Controller_Message::getInstance()->getMessageFromNode($originalMessageId);
$partId = 1;
} catch (Tinebase_Exception_NotFound $tenf) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
. ' Did not find original message (' . $originalMessageId . ')');
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__
. ' Did not find original message or file for forward/reply(' . $originalMessageId . ')');
}
$translation = Tinebase_Translation::getTranslation('Felamimail');
throw new Tinebase_Exception_NotFound($translation->_('Original message not found, email was moved or deleted'));
$originalMessage = null;
}
}

Expand Down

0 comments on commit 1a5c5fd

Please sign in to comment.