Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/engine/PhabricatorMailEmailEngine.php
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | public function newMessage() { | ||||
$must_encrypt = $mail->getMustEncrypt(); | $must_encrypt = $mail->getMustEncrypt(); | ||||
$raw_body = $mail->getBody(); | $raw_body = $mail->getBody(); | ||||
$body = $raw_body; | $body = $raw_body; | ||||
if ($must_encrypt) { | if ($must_encrypt) { | ||||
$parts = array(); | $parts = array(); | ||||
$encrypt_uri = $mail->getMustEncryptURI(); | $encrypt_uri = $mail->getMustEncryptURI(); | ||||
if (!strlen($encrypt_uri)) { | if ($encrypt_uri === null || !strlen($encrypt_uri)) { | ||||
$encrypt_phid = $mail->getRelatedPHID(); | $encrypt_phid = $mail->getRelatedPHID(); | ||||
if ($encrypt_phid) { | if ($encrypt_phid) { | ||||
$encrypt_uri = urisprintf( | $encrypt_uri = urisprintf( | ||||
'/object/%s/', | '/object/%s/', | ||||
$encrypt_phid); | $encrypt_phid); | ||||
} | } | ||||
} | } | ||||
if (strlen($encrypt_uri)) { | if ($encrypt_uri !== null && strlen($encrypt_uri)) { | ||||
$parts[] = pht( | $parts[] = pht( | ||||
'This secure message is notifying you of a change to this object:'); | 'This secure message is notifying you of a change to this object:'); | ||||
$parts[] = PhabricatorEnv::getProductionURI($encrypt_uri); | $parts[] = PhabricatorEnv::getProductionURI($encrypt_uri); | ||||
} | } | ||||
$parts[] = pht( | $parts[] = pht( | ||||
'The content for this message can only be transmitted over a '. | 'The content for this message can only be transmitted over a '. | ||||
'secure channel. To view the message content, follow this '. | 'secure channel. To view the message content, follow this '. | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | private function newReplyToEmailAddress() { | ||||
// If we have a sending object, change the display name. | // If we have a sending object, change the display name. | ||||
$from_phid = $mail->getFrom(); | $from_phid = $mail->getFrom(); | ||||
$actor = $this->getActor($from_phid); | $actor = $this->getActor($from_phid); | ||||
if ($actor) { | if ($actor) { | ||||
$reply_address->setDisplayName($actor->getName()); | $reply_address->setDisplayName($actor->getName()); | ||||
} | } | ||||
// If we don't have a display name, fill in a default. | // If we don't have a display name, fill in a default. | ||||
if (!strlen($reply_address->getDisplayName())) { | $reply_display_name = $reply_address->getDisplayName(); | ||||
if ($reply_display_name === null || !strlen($reply_display_name)) { | |||||
$reply_address->setDisplayName(PlatformSymbols::getPlatformServerName()); | $reply_address->setDisplayName(PlatformSymbols::getPlatformServerName()); | ||||
} | } | ||||
return $reply_address; | return $reply_address; | ||||
} | } | ||||
private function newToEmailAddresses() { | private function newToEmailAddresses() { | ||||
$mail = $this->getMail(); | $mail = $this->getMail(); | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | private function newEmailSubject() { | ||||
$subject_prefix = trim($subject_prefix); | $subject_prefix = trim($subject_prefix); | ||||
$subject[] = $subject_prefix; | $subject[] = $subject_prefix; | ||||
// If mail content must be encrypted, we replace the subject with | // If mail content must be encrypted, we replace the subject with | ||||
// a generic one. | // a generic one. | ||||
if ($must_encrypt) { | if ($must_encrypt) { | ||||
$encrypt_subject = $mail->getMustEncryptSubject(); | $encrypt_subject = $mail->getMustEncryptSubject(); | ||||
if (!strlen($encrypt_subject)) { | if ($encrypt_subject === null || !strlen($encrypt_subject)) { | ||||
$encrypt_subject = pht('Object Updated'); | $encrypt_subject = pht('Object Updated'); | ||||
} | } | ||||
$subject[] = $encrypt_subject; | $subject[] = $encrypt_subject; | ||||
} else { | } else { | ||||
$vary_prefix = $mail->getVarySubjectPrefix(); | $vary_prefix = $mail->getVarySubjectPrefix(); | ||||
if (phutil_nonempty_string($vary_prefix)) { | if (phutil_nonempty_string($vary_prefix)) { | ||||
if ($this->shouldVarySubject()) { | if ($this->shouldVarySubject()) { | ||||
$subject[] = $vary_prefix; | $subject[] = $vary_prefix; | ||||
▲ Show 20 Lines • Show All 167 Lines • ▼ Show 20 Lines | return id(new PhabricatorMailHeader()) | ||||
->setName($name) | ->setName($name) | ||||
->setValue($value); | ->setValue($value); | ||||
} | } | ||||
private function newEmailAddress($address, $name = null) { | private function newEmailAddress($address, $name = null) { | ||||
$object = id(new PhutilEmailAddress()) | $object = id(new PhutilEmailAddress()) | ||||
->setAddress($address); | ->setAddress($address); | ||||
if (strlen($name)) { | if ($name !== null && strlen($name)) { | ||||
$object->setDisplayName($name); | $object->setDisplayName($name); | ||||
} | } | ||||
return $object; | return $object; | ||||
} | } | ||||
public function newDefaultEmailAddress() { | public function newDefaultEmailAddress() { | ||||
$raw_address = PhabricatorEnv::getEnvConfig('metamta.default-address'); | $raw_address = PhabricatorEnv::getEnvConfig('metamta.default-address'); | ||||
if (!strlen($raw_address)) { | if ($raw_address == null || !strlen($raw_address)) { | ||||
$domain = $this->newMailDomain(); | $domain = $this->newMailDomain(); | ||||
$raw_address = "noreply@{$domain}"; | $raw_address = "noreply@{$domain}"; | ||||
} | } | ||||
$address = new PhutilEmailAddress($raw_address); | $address = new PhutilEmailAddress($raw_address); | ||||
if (!phutil_nonempty_string($address->getDisplayName())) { | if (!phutil_nonempty_string($address->getDisplayName())) { | ||||
$address->setDisplayName(PlatformSymbols::getPlatformServerName()); | $address->setDisplayName(PlatformSymbols::getPlatformServerName()); | ||||
} | } | ||||
return $address; | return $address; | ||||
} | } | ||||
public function newVoidEmailAddress() { | public function newVoidEmailAddress() { | ||||
return $this->newDefaultEmailAddress(); | return $this->newDefaultEmailAddress(); | ||||
} | } | ||||
private function newMailDomain() { | private function newMailDomain() { | ||||
$domain = PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain'); | $domain = PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain'); | ||||
if (strlen($domain)) { | if ($domain !== null && strlen($domain)) { | ||||
return $domain; | return $domain; | ||||
} | } | ||||
$install_uri = PhabricatorEnv::getURI('/'); | $install_uri = PhabricatorEnv::getURI('/'); | ||||
$install_uri = new PhutilURI($install_uri); | $install_uri = new PhutilURI($install_uri); | ||||
return $install_uri->getDomain(); | return $install_uri->getDomain(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines |