mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Allow encrypted mail to be more specific about which object is affected
Summary: Depends on D19487. Ref T13151. See PHI647. For some objects, like revisions, we can build slightly more useful secure email without actually disclosing anything. In the general case, the object monogram may disclose information (`#acquire-competitor`) but most do not, so applications can whitelist an acceptable nondisclosing subject and link. Support doing this, and make Differential do it. When we don't have a whitelisted URI but do know the object the mail is about, include a generic PHID-based URI; these are always nondisclosing. Test Plan: - Without the Differential changes, sent normal mail (no changes) and secure mail (new generic PHID-based link). - With the Differential changes, sent secure mail; got richer subject and body link. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13151 Differential Revision: https://secure.phabricator.com/D19488
This commit is contained in:
parent
94752278f4
commit
62a402491a
2 changed files with 44 additions and 8 deletions
|
@ -592,12 +592,13 @@ final class DifferentialTransactionEditor
|
|||
}
|
||||
|
||||
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
|
||||
$id = $object->getID();
|
||||
$monogram = $object->getMonogram();
|
||||
$title = $object->getTitle();
|
||||
$subject = "D{$id}: {$title}";
|
||||
|
||||
return id(new PhabricatorMetaMTAMail())
|
||||
->setSubject($subject);
|
||||
->setSubject(pht('%s: %s', $monogram, $title))
|
||||
->setMustEncryptSubject(pht('%s: Revision Updated', $monogram))
|
||||
->setMustEncryptURI($object->getURI());
|
||||
}
|
||||
|
||||
protected function getTransactionsForMail(
|
||||
|
|
|
@ -291,17 +291,31 @@ final class PhabricatorMetaMTAMail
|
|||
}
|
||||
|
||||
public function setMustEncrypt($bool) {
|
||||
$this->setParam('mustEncrypt', $bool);
|
||||
return $this;
|
||||
return $this->setParam('mustEncrypt', $bool);
|
||||
}
|
||||
|
||||
public function getMustEncrypt() {
|
||||
return $this->getParam('mustEncrypt', false);
|
||||
}
|
||||
|
||||
public function setMustEncryptURI($uri) {
|
||||
return $this->setParam('mustEncrypt.uri', $uri);
|
||||
}
|
||||
|
||||
public function getMustEncryptURI() {
|
||||
return $this->getParam('mustEncrypt.uri');
|
||||
}
|
||||
|
||||
public function setMustEncryptSubject($subject) {
|
||||
return $this->setParam('mustEncrypt.subject', $subject);
|
||||
}
|
||||
|
||||
public function getMustEncryptSubject() {
|
||||
return $this->getParam('mustEncrypt.subject');
|
||||
}
|
||||
|
||||
public function setMustEncryptReasons(array $reasons) {
|
||||
$this->setParam('mustEncryptReasons', $reasons);
|
||||
return $this;
|
||||
return $this->setParam('mustEncryptReasons', $reasons);
|
||||
}
|
||||
|
||||
public function getMustEncryptReasons() {
|
||||
|
@ -787,7 +801,11 @@ final class PhabricatorMetaMTAMail
|
|||
// If mail content must be encrypted, we replace the subject with
|
||||
// a generic one.
|
||||
if ($must_encrypt) {
|
||||
$subject[] = pht('Object Updated');
|
||||
$encrypt_subject = $this->getMustEncryptSubject();
|
||||
if (!strlen($encrypt_subject)) {
|
||||
$encrypt_subject = pht('Object Updated');
|
||||
}
|
||||
$subject[] = $encrypt_subject;
|
||||
} else {
|
||||
$vary_prefix = idx($params, 'vary-subject-prefix');
|
||||
if ($vary_prefix != '') {
|
||||
|
@ -845,6 +863,23 @@ final class PhabricatorMetaMTAMail
|
|||
$body = $raw_body;
|
||||
if ($must_encrypt) {
|
||||
$parts = array();
|
||||
|
||||
$encrypt_uri = $this->getMustEncryptURI();
|
||||
if (!strlen($encrypt_uri)) {
|
||||
$encrypt_phid = $this->getRelatedPHID();
|
||||
if ($encrypt_phid) {
|
||||
$encrypt_uri = urisprintf(
|
||||
'/object/%s/',
|
||||
$encrypt_phid);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen($encrypt_uri)) {
|
||||
$parts[] = pht(
|
||||
'This secure message is notifying you of a change to this object:');
|
||||
$parts[] = PhabricatorEnv::getProductionURI($encrypt_uri);
|
||||
}
|
||||
|
||||
$parts[] = pht(
|
||||
'The content for this message can only be transmitted over a '.
|
||||
'secure channel. To view the message content, follow this '.
|
||||
|
|
Loading…
Reference in a new issue