mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Provide an "algorithm" for stripping quoted text from email replies
Summary: There's an undoubtedly-far-more-refined version of this in xmail if someone wants to crib it for me. Otherwise we can anneal this as counterexamples arise. This seems to be what mail.app and gmail do. Test Plan: Used mail receiver console to "send" some mail and verified it was correctly truncated. Reviewed By: jungejason Reviewers: aran, tuomaspelkonen, jungejason CC: aran, jungejason Differential Revision: 290
This commit is contained in:
parent
f72c1acc63
commit
8fc79035b6
1 changed files with 10 additions and 2 deletions
|
@ -96,9 +96,17 @@ class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO {
|
||||||
public function getCleanTextBody() {
|
public function getCleanTextBody() {
|
||||||
$body = idx($this->bodies, 'text');
|
$body = idx($this->bodies, 'text');
|
||||||
|
|
||||||
// TODO: Detect quoted content and exclude it.
|
// TODO: Refine this "algorithm".
|
||||||
|
|
||||||
return $body;
|
$lines = explode("\n", trim($body));
|
||||||
|
for ($ii = 0; $ii < count($lines); $ii++) {
|
||||||
|
if (preg_match('/^\s*On\b.*\bwrote:\s*$/', $lines[$ii])) {
|
||||||
|
$lines = array_slice($lines, 0, $ii);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim(implode("\n", $lines));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function loadReceiverObject($receiver_name) {
|
public static function loadReceiverObject($receiver_name) {
|
||||||
|
|
Loading…
Reference in a new issue