Merge pull request #7848 from annando/mail-hooks

Added hooks for the email fetch process
2022.09-rc
Hypolite Petovan 2019-11-20 16:20:57 -05:00 zatwierdzone przez GitHub
commit d48d3d1db2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 26 dodań i 3 usunięć

Wyświetl plik

@ -777,6 +777,11 @@ Here is a complete list of all hook callbacks with file locations (as of 24-Sep-
Hook::callAll('atom_feed_end', $atom);
Hook::callAll('atom_feed_end', $atom);
### src/Protocol/Email.php
Hook::callAll('email_getmessage', $message);
Hook::callAll('email_getmessage_end', $ret);
### view/js/main.js
document.dispatchEvent(new Event('postprocess_liveupdate'));

Wyświetl plik

@ -495,3 +495,8 @@ Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 01-Ap
Hook::callAll('atom_feed_end', $atom);
Hook::callAll('atom_feed_end', $atom);
### src/Protocol/Email.php
Hook::callAll('email_getmessage', $message);
Hook::callAll('email_getmessage_end', $ret);

Wyświetl plik

@ -4,6 +4,7 @@
*/
namespace Friendica\Protocol;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Content\Text\HTML;
use Friendica\Model\Item;
@ -126,6 +127,10 @@ class Email
if (trim($ret['body']) == '') {
$ret['body'] = self::messageGetPart($mbox, $uid, $struc, 0, 'plain');
} else {
$message = ['text' => '', 'html' => $ret['body']];
Hook::callAll('email_getmessage', $message);
$ret['body'] = $message['html'];
$ret['body'] = HTML::toBBCode($ret['body']);
}
} else {
@ -142,7 +147,13 @@ class Email
$html .= $x;
}
}
if (trim($html) != '') {
$message = ['text' => trim($text), 'html' => trim($html)];
Hook::callAll('email_getmessage', $message);
$html = $message['html'];
$text = $message['text'];
if (!empty($html)) {
$ret['body'] = HTML::toBBCode($html);
} else {
$ret['body'] = $text;
@ -160,12 +171,14 @@ class Email
$ret['body'] = self::unifyAttributionLine($ret['body']);
Hook::callAll('email_getmessage_end', $ret);
return $ret;
}
// At the moment - only return plain/text.
// Later we'll repackage inline images as data url's and make the HTML safe
/**
* fetch the specified message part number with the specified subtype
*
* @param resource $mbox mailbox
* @param integer $uid user id
* @param object $p parts