Page MenuHomePhabricator

D18995.diff
No OneTemporary

D18995.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2220,6 +2220,7 @@
'PhabricatorBoardResponseEngine' => 'applications/project/engine/PhabricatorBoardResponseEngine.php',
'PhabricatorBoolConfigType' => 'applications/config/type/PhabricatorBoolConfigType.php',
'PhabricatorBoolEditField' => 'applications/transactions/editfield/PhabricatorBoolEditField.php',
+ 'PhabricatorBoolMailStamp' => 'applications/metamta/stamp/PhabricatorBoolMailStamp.php',
'PhabricatorBritishEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorBritishEnglishTranslation.php',
'PhabricatorBuiltinDraftEngine' => 'applications/transactions/draft/PhabricatorBuiltinDraftEngine.php',
'PhabricatorBuiltinFileCachePurger' => 'applications/cache/purger/PhabricatorBuiltinFileCachePurger.php',
@@ -2813,6 +2814,7 @@
'PhabricatorEditPage' => 'applications/transactions/editengine/PhabricatorEditPage.php',
'PhabricatorEditType' => 'applications/transactions/edittype/PhabricatorEditType.php',
'PhabricatorEditor' => 'infrastructure/PhabricatorEditor.php',
+ 'PhabricatorEditorMailEngineExtension' => 'applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php',
'PhabricatorEditorMultipleSetting' => 'applications/settings/setting/PhabricatorEditorMultipleSetting.php',
'PhabricatorEditorSetting' => 'applications/settings/setting/PhabricatorEditorSetting.php',
'PhabricatorElasticFulltextStorageEngine' => 'applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php',
@@ -3440,6 +3442,7 @@
'PhabricatorPHIDListEditField' => 'applications/transactions/editfield/PhabricatorPHIDListEditField.php',
'PhabricatorPHIDListEditType' => 'applications/transactions/edittype/PhabricatorPHIDListEditType.php',
'PhabricatorPHIDListExportField' => 'infrastructure/export/field/PhabricatorPHIDListExportField.php',
+ 'PhabricatorPHIDMailStamp' => 'applications/metamta/stamp/PhabricatorPHIDMailStamp.php',
'PhabricatorPHIDResolver' => 'applications/phid/resolver/PhabricatorPHIDResolver.php',
'PhabricatorPHIDType' => 'applications/phid/type/PhabricatorPHIDType.php',
'PhabricatorPHIDTypeTestCase' => 'applications/phid/type/__tests__/PhabricatorPHIDTypeTestCase.php',
@@ -4395,6 +4398,7 @@
'PhabricatorVersionedDraft' => 'applications/draft/storage/PhabricatorVersionedDraft.php',
'PhabricatorVeryWowEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorVeryWowEnglishTranslation.php',
'PhabricatorViewerDatasource' => 'applications/people/typeahead/PhabricatorViewerDatasource.php',
+ 'PhabricatorViewerMailStamp' => 'applications/metamta/stamp/PhabricatorViewerMailStamp.php',
'PhabricatorWatcherHasObjectEdgeType' => 'applications/transactions/edges/PhabricatorWatcherHasObjectEdgeType.php',
'PhabricatorWebContentSource' => 'infrastructure/contentsource/PhabricatorWebContentSource.php',
'PhabricatorWebServerSetupCheck' => 'applications/config/check/PhabricatorWebServerSetupCheck.php',
@@ -7582,6 +7586,7 @@
'PhabricatorBoardResponseEngine' => 'Phobject',
'PhabricatorBoolConfigType' => 'PhabricatorTextConfigType',
'PhabricatorBoolEditField' => 'PhabricatorEditField',
+ 'PhabricatorBoolMailStamp' => 'PhabricatorMailStamp',
'PhabricatorBritishEnglishTranslation' => 'PhutilTranslation',
'PhabricatorBuiltinDraftEngine' => 'PhabricatorDraftEngine',
'PhabricatorBuiltinFileCachePurger' => 'PhabricatorCachePurger',
@@ -8267,6 +8272,7 @@
'PhabricatorEditPage' => 'Phobject',
'PhabricatorEditType' => 'Phobject',
'PhabricatorEditor' => 'Phobject',
+ 'PhabricatorEditorMailEngineExtension' => 'PhabricatorMailEngineExtension',
'PhabricatorEditorMultipleSetting' => 'PhabricatorSelectSetting',
'PhabricatorEditorSetting' => 'PhabricatorStringSetting',
'PhabricatorElasticFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine',
@@ -8973,6 +8979,7 @@
'PhabricatorPHIDListEditField' => 'PhabricatorEditField',
'PhabricatorPHIDListEditType' => 'PhabricatorEditType',
'PhabricatorPHIDListExportField' => 'PhabricatorListExportField',
+ 'PhabricatorPHIDMailStamp' => 'PhabricatorMailStamp',
'PhabricatorPHIDResolver' => 'Phobject',
'PhabricatorPHIDType' => 'Phobject',
'PhabricatorPHIDTypeTestCase' => 'PhutilTestCase',
@@ -10137,6 +10144,7 @@
'PhabricatorVersionedDraft' => 'PhabricatorDraftDAO',
'PhabricatorVeryWowEnglishTranslation' => 'PhutilTranslation',
'PhabricatorViewerDatasource' => 'PhabricatorTypeaheadDatasource',
+ 'PhabricatorViewerMailStamp' => 'PhabricatorMailStamp',
'PhabricatorWatcherHasObjectEdgeType' => 'PhabricatorEdgeType',
'PhabricatorWebContentSource' => 'PhabricatorContentSource',
'PhabricatorWebServerSetupCheck' => 'PhabricatorSetupCheck',
diff --git a/src/applications/metamta/stamp/PhabricatorBoolMailStamp.php b/src/applications/metamta/stamp/PhabricatorBoolMailStamp.php
new file mode 100644
--- /dev/null
+++ b/src/applications/metamta/stamp/PhabricatorBoolMailStamp.php
@@ -0,0 +1,16 @@
+<?php
+
+final class PhabricatorBoolMailStamp
+ extends PhabricatorMailStamp {
+
+ const STAMPTYPE = 'bool';
+
+ public function renderStamps($value) {
+ if (!$value) {
+ return null;
+ }
+
+ return $this->renderStamp($this->getKey());
+ }
+
+}
diff --git a/src/applications/metamta/stamp/PhabricatorPHIDMailStamp.php b/src/applications/metamta/stamp/PhabricatorPHIDMailStamp.php
new file mode 100644
--- /dev/null
+++ b/src/applications/metamta/stamp/PhabricatorPHIDMailStamp.php
@@ -0,0 +1,36 @@
+<?php
+
+final class PhabricatorPHIDMailStamp
+ extends PhabricatorMailStamp {
+
+ const STAMPTYPE = 'phid';
+
+ public function renderStamps($value) {
+ if ($value === null) {
+ return null;
+ }
+
+ $value = (array)$value;
+ if (!$value) {
+ return null;
+ }
+
+ $viewer = $this->getViewer();
+ $handles = $viewer->loadHandles($value);
+
+ $results = array();
+ foreach ($value as $phid) {
+ $handle = $handles[$phid];
+
+ $mail_name = $handle->getMailStampName();
+ if ($mail_name === null) {
+ $mail_name = $handle->getPHID();
+ }
+
+ $results[] = $this->renderStamp($this->getKey(), $mail_name);
+ }
+
+ return $results;
+ }
+
+}
diff --git a/src/applications/metamta/stamp/PhabricatorViewerMailStamp.php b/src/applications/metamta/stamp/PhabricatorViewerMailStamp.php
new file mode 100644
--- /dev/null
+++ b/src/applications/metamta/stamp/PhabricatorViewerMailStamp.php
@@ -0,0 +1,35 @@
+<?php
+
+final class PhabricatorViewerMailStamp
+ extends PhabricatorMailStamp {
+
+ const STAMPTYPE = 'viewer';
+
+ public function renderStamps($value) {
+ // If we're sending one mail to everyone, we never include viewer-based
+ // stamps since they'll only be accurate for one recipient. Recipients
+ // can still use the corresponding stamps with their usernames or PHIDs.
+ if (!PhabricatorMetaMTAMail::shouldMailEachRecipient()) {
+ return null;
+ }
+
+ $viewer_phid = $this->getViewer()->getPHID();
+ if (!$viewer_phid) {
+ return null;
+ }
+
+ if (!$value) {
+ return null;
+ }
+
+ $value = (array)$value;
+ $value = array_fuse($value);
+
+ if (!isset($value[$viewer_phid])) {
+ return null;
+ }
+
+ return $this->renderStamp($this->getKey());
+ }
+
+}
diff --git a/src/applications/people/phid/PhabricatorPeopleUserPHIDType.php b/src/applications/people/phid/PhabricatorPeopleUserPHIDType.php
--- a/src/applications/people/phid/PhabricatorPeopleUserPHIDType.php
+++ b/src/applications/people/phid/PhabricatorPeopleUserPHIDType.php
@@ -39,11 +39,14 @@
foreach ($handles as $phid => $handle) {
$user = $objects[$phid];
$realname = $user->getRealName();
-
- $handle->setName($user->getUsername());
- $handle->setURI('/p/'.$user->getUsername().'/');
- $handle->setFullName($user->getFullName());
- $handle->setImageURI($user->getProfileImageURI());
+ $username = $user->getUsername();
+
+ $handle
+ ->setName($username)
+ ->setURI('/p/'.$username.'/')
+ ->setFullName($user->getFullName())
+ ->setImageURI($user->getProfileImageURI())
+ ->setMailStampName('@'.$username);
if ($user->getIsMailingList()) {
$handle->setIcon('fa-envelope-o');
diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php
--- a/src/applications/phid/PhabricatorObjectHandle.php
+++ b/src/applications/phid/PhabricatorObjectHandle.php
@@ -31,6 +31,7 @@
private $subtitle;
private $tokenIcon;
private $commandLineObjectName;
+ private $mailStampName;
private $stateIcon;
private $stateColor;
@@ -134,6 +135,15 @@
return $this->objectName;
}
+ public function setMailStampName($mail_stamp_name) {
+ $this->mailStampName = $mail_stamp_name;
+ return $this;
+ }
+
+ public function getMailStampName() {
+ return $this->mailStampName;
+ }
+
public function setURI($uri) {
$this->uri = $uri;
return $this;
diff --git a/src/applications/project/phid/PhabricatorProjectProjectPHIDType.php b/src/applications/project/phid/PhabricatorProjectProjectPHIDType.php
--- a/src/applications/project/phid/PhabricatorProjectProjectPHIDType.php
+++ b/src/applications/project/phid/PhabricatorProjectProjectPHIDType.php
@@ -45,11 +45,12 @@
if (strlen($slug)) {
$handle->setObjectName('#'.$slug);
+ $handle->setMailStampName('#'.$slug);
$handle->setURI("/tag/{$slug}/");
} else {
// We set the name to the project's PHID to avoid a parse error when a
// project has no hashtag (as is the case with milestones by default).
- // See T12659 for more details
+ // See T12659 for more details.
$handle->setCommandLineObjectName($project->getPHID());
$handle->setURI("/project/view/{$id}/");
}
diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
--- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
+++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
@@ -179,7 +179,7 @@
return $this->isNewObject;
}
- protected function getMentionedPHIDs() {
+ public function getMentionedPHIDs() {
return $this->mentionedPHIDs;
}
@@ -201,6 +201,10 @@
return $this->silent;
}
+ public function getMustEncrypt() {
+ return $this->mustEncrypt;
+ }
+
public function setIsInverseEdgeEditor($is_inverse_edge_editor) {
$this->isInverseEdgeEditor = $is_inverse_edge_editor;
return $this;
diff --git a/src/applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php b/src/applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php
new file mode 100644
--- /dev/null
+++ b/src/applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php
@@ -0,0 +1,81 @@
+<?php
+
+final class PhabricatorEditorMailEngineExtension
+ extends PhabricatorMailEngineExtension {
+
+ const EXTENSIONKEY = 'editor';
+
+ public function supportsObject($object) {
+ return true;
+ }
+
+ public function newMailStampTemplates($object) {
+ $templates = array();
+
+ $templates[] = id(new PhabricatorPHIDMailStamp())
+ ->setKey('actor')
+ ->setLabel(pht('Acting User'));
+
+ $templates[] = id(new PhabricatorStringMailStamp())
+ ->setKey('via')
+ ->setLabel(pht('Via Content Source'));
+
+ $templates[] = id(new PhabricatorBoolMailStamp())
+ ->setKey('silent')
+ ->setLabel(pht('Silent Edit'));
+
+ $templates[] = id(new PhabricatorBoolMailStamp())
+ ->setKey('encrypted')
+ ->setLabel(pht('Encryption Required'));
+
+ $templates[] = id(new PhabricatorBoolMailStamp())
+ ->setKey('new')
+ ->setLabel(pht('New Object'));
+
+ $templates[] = id(new PhabricatorPHIDMailStamp())
+ ->setKey('mention')
+ ->setLabel(pht('Mentioned User'));
+
+ $templates[] = id(new PhabricatorViewerMailStamp())
+ ->setKey('self-actor')
+ ->setLabel(pht('You Acted'));
+
+ $templates[] = id(new PhabricatorViewerMailStamp())
+ ->setKey('self-mention')
+ ->setLabel(pht('You Were Mentioned'));
+
+ return $templates;
+ }
+
+ public function newMailStamps($object, array $xactions) {
+ $editor = $this->getEditor();
+ $viewer = $this->getViewer();
+
+ $this->getMailStamp('actor')
+ ->setValue($editor->getActingAsPHID());
+
+ $content_source = $editor->getContentSource();
+ $this->getMailStamp('via')
+ ->setValue($content_source->getSourceTypeConstant());
+
+ $this->getMailStamp('silent')
+ ->setValue($editor->getIsSilent());
+
+ $this->getMailStamp('encrypted')
+ ->setValue($editor->getMustEncrypt());
+
+ $this->getMailStamp('new')
+ ->setValue($editor->getIsNewObject());
+
+ $mentioned_phids = $editor->getMentionedPHIDs();
+ $this->getMailStamp('mention')
+ ->setValue($mentioned_phids);
+
+ $this->getMailStamp('self-actor')
+ ->setValue($editor->getActingAsPHID());
+
+ $this->getMailStamp('self-mention')
+ ->setValue($mentioned_phids);
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Tue, May 21, 3:02 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276926
Default Alt Text
D18995.diff (13 KB)

Event Timeline