Skip to content

Commit

Permalink
Fix preview text
Browse files Browse the repository at this point in the history
Signed-off-by: hamza221 <[email protected]>
  • Loading branch information
hamza221 committed Aug 16, 2023
1 parent 5c8d239 commit f1d7729
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"christophwurst/kitinerary-sys": "^0.2.1",
"ezyang/htmlpurifier": "4.16.0",
"gravatarphp/gravatar": "dev-master#6b9f6a45477ce48285738d9d0c3f0dbf97abe263",
"html2text/html2text": "^4.3.1",
"hamza221/html2text": "^1.0",
"nextcloud/horde-managesieve": "^1.0",
"nextcloud/horde-smtp": "^1.0.2",
"phpmailer/dkimvalidator": "^0.3.0",
Expand Down
26 changes: 11 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions lib/IMAP/MessageMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -928,35 +928,36 @@ public function getBodyStructureData(Horde_Imap_Client_Socket $client,
if ($part === null) {
return new MessageStructureData($hasAttachments, $text, $isImipMessage, $isEncrypted);
}
$textBody = $part->getBodyPart($textBodyId);
if (!empty($textBody)) {
$mimeHeaders = $part->getMimeHeader($textBodyId, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);


$htmlBody = ($htmlBodyId !== null) ? $part->getBodyPart($htmlBodyId) : null;
if (!empty($htmlBody)) {
$mimeHeaders = $part->getMimeHeader($htmlBodyId, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
if ($enc = $mimeHeaders->getValue('content-transfer-encoding')) {
$structure->setTransferEncoding($enc);
$structure->setContents($textBody);
$textBody = $structure->getContents();
$structure->setContents($htmlBody);
$htmlBody = $structure->getContents();
}
$html = new Html2Text($htmlBody, array('do_links' => 'none','alt_image' => 'hide'));
return new MessageStructureData(
$hasAttachments,
$textBody,
trim($html->getText()),
$isImipMessage,
$isEncrypted,
);
}
$textBody = $part->getBodyPart($textBodyId);

$htmlBody = ($htmlBodyId !== null) ? $part->getBodyPart($htmlBodyId) : null;
if (!empty($htmlBody)) {
$mimeHeaders = $part->getMimeHeader($htmlBodyId, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
if (!empty($textBody)) {
$mimeHeaders = $part->getMimeHeader($textBodyId, Horde_Imap_Client_Data_Fetch::HEADER_PARSE);
if ($enc = $mimeHeaders->getValue('content-transfer-encoding')) {
$structure->setTransferEncoding($enc);
$structure->setContents($htmlBody);
$htmlBody = $structure->getContents();
$structure->setContents($textBody);
$textBody = $structure->getContents();
}
// TODO: add 'alt_image' => 'hide' once it's added to the Html2Text package
$html = new Html2Text($htmlBody, array('do_links' => 'none',));
return new MessageStructureData(
$hasAttachments,
trim($html->getText()),
$textBody,
$isImipMessage,
$isEncrypted,
);
Expand Down

0 comments on commit f1d7729

Please sign in to comment.