Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15419028
D18997.id45562.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D18997.id45562.diff
View Options
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
@@ -487,6 +487,7 @@
'DifferentialLintField' => 'applications/differential/customfield/DifferentialLintField.php',
'DifferentialLintStatus' => 'applications/differential/constants/DifferentialLintStatus.php',
'DifferentialLocalCommitsView' => 'applications/differential/view/DifferentialLocalCommitsView.php',
+ 'DifferentialMailEngineExtension' => 'applications/differential/engineextension/DifferentialMailEngineExtension.php',
'DifferentialMailView' => 'applications/differential/mail/DifferentialMailView.php',
'DifferentialManiphestTasksField' => 'applications/differential/customfield/DifferentialManiphestTasksField.php',
'DifferentialModernHunk' => 'applications/differential/storage/DifferentialModernHunk.php',
@@ -4402,7 +4403,6 @@
'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',
@@ -5612,6 +5612,7 @@
'DifferentialLintField' => 'DifferentialHarbormasterField',
'DifferentialLintStatus' => 'Phobject',
'DifferentialLocalCommitsView' => 'AphrontView',
+ 'DifferentialMailEngineExtension' => 'PhabricatorMailEngineExtension',
'DifferentialMailView' => 'Phobject',
'DifferentialManiphestTasksField' => 'DifferentialCoreCustomField',
'DifferentialModernHunk' => 'DifferentialHunk',
@@ -10152,7 +10153,6 @@
'PhabricatorVersionedDraft' => 'PhabricatorDraftDAO',
'PhabricatorVeryWowEnglishTranslation' => 'PhutilTranslation',
'PhabricatorViewerDatasource' => 'PhabricatorTypeaheadDatasource',
- 'PhabricatorViewerMailStamp' => 'PhabricatorMailStamp',
'PhabricatorWatcherHasObjectEdgeType' => 'PhabricatorEdgeType',
'PhabricatorWebContentSource' => 'PhabricatorContentSource',
'PhabricatorWebServerSetupCheck' => 'PhabricatorSetupCheck',
diff --git a/src/applications/differential/engineextension/DifferentialMailEngineExtension.php b/src/applications/differential/engineextension/DifferentialMailEngineExtension.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/engineextension/DifferentialMailEngineExtension.php
@@ -0,0 +1,80 @@
+<?php
+
+final class DifferentialMailEngineExtension
+ extends PhabricatorMailEngineExtension {
+
+ const EXTENSIONKEY = 'differential';
+
+ public function supportsObject($object) {
+ return ($object instanceof DifferentialRevision);
+ }
+
+ public function newMailStampTemplates($object) {
+ return array(
+ id(new PhabricatorPHIDMailStamp())
+ ->setKey('author')
+ ->setLabel(pht('Author')),
+ id(new PhabricatorPHIDMailStamp())
+ ->setKey('reviewer')
+ ->setLabel(pht('Reviewer')),
+ id(new PhabricatorPHIDMailStamp())
+ ->setKey('blocking-reviewer')
+ ->setLabel(pht('Reviewer')),
+ id(new PhabricatorPHIDMailStamp())
+ ->setKey('resigned-reviewer')
+ ->setLabel(pht('Reviewer')),
+ id(new PhabricatorPHIDMailStamp())
+ ->setKey('revision-repository')
+ ->setLabel(pht('Revision Repository')),
+ id(new PhabricatorPHIDMailStamp())
+ ->setKey('revision-status')
+ ->setLabel(pht('Revision Status')),
+ );
+ }
+
+ public function newMailStamps($object, array $xactions) {
+ $editor = $this->getEditor();
+ $viewer = $this->getViewer();
+
+ $revision = id(new DifferentialRevisionQuery())
+ ->setViewer($viewer)
+ ->needReviewers(true)
+ ->withPHIDs(array($object->getPHID()))
+ ->executeOne();
+
+ $reviewers = array();
+ $blocking = array();
+ $resigned = array();
+ foreach ($revision->getReviewers() as $reviewer) {
+ $reviewer_phid = $reviewer->getReviewerPHID();
+
+ if ($reviewer->isResigned()) {
+ $resigned[] = $reviewer_phid;
+ } else {
+ $reviewers[] = $reviewer_phid;
+ if ($reviewer->isBlocking()) {
+ $reviewers[] = $blocking;
+ }
+ }
+ }
+
+ $this->getMailStamp('author')
+ ->setValue($revision->getAuthorPHID());
+
+ $this->getMailStamp('reviewer')
+ ->setValue($reviewers);
+
+ $this->getMailStamp('blocking-reviewer')
+ ->setValue($blocking);
+
+ $this->getMailStamp('resigned-reviewer')
+ ->setValue($resigned);
+
+ $this->getMailStamp('revision-repository')
+ ->setValue($revision->getRepositoryPHID());
+
+ $this->getMailStamp('revision-status')
+ ->setValue($revision->getModernRevisionStatus());
+ }
+
+}
diff --git a/src/applications/differential/storage/DifferentialReviewer.php b/src/applications/differential/storage/DifferentialReviewer.php
--- a/src/applications/differential/storage/DifferentialReviewer.php
+++ b/src/applications/differential/storage/DifferentialReviewer.php
@@ -69,6 +69,11 @@
return ($this->getReviewerStatus() == $status_resigned);
}
+ public function isBlocking() {
+ $status_blocking = DifferentialReviewerStatus::STATUS_BLOCKING;
+ return ($this->getReviewerStatus() == $status_blocking);
+ }
+
public function isRejected($diff_phid) {
$status_rejected = DifferentialReviewerStatus::STATUS_REJECTED;
diff --git a/src/applications/metamta/replyhandler/PhabricatorMailTarget.php b/src/applications/metamta/replyhandler/PhabricatorMailTarget.php
--- a/src/applications/metamta/replyhandler/PhabricatorMailTarget.php
+++ b/src/applications/metamta/replyhandler/PhabricatorMailTarget.php
@@ -70,14 +70,14 @@
$body .= "\n";
$body .= pht('STAMPS');
$body .= "\n";
- $body .= implode(', ', $stamps);
+ $body .= implode(' ', $stamps);
$body .= "\n";
if ($has_html) {
$html = array();
$html[] = phutil_tag('strong', array(), pht('STAMPS'));
$html[] = phutil_tag('br');
- $html[] = phutil_implode_html(', ', $stamps);
+ $html[] = phutil_implode_html(' ', $stamps);
$html[] = phutil_tag('br');
$html = phutil_tag('div', array(), $html);
$html_body .= hsprintf('%s', $html);
diff --git a/src/applications/metamta/stamp/PhabricatorStringMailStamp.php b/src/applications/metamta/stamp/PhabricatorStringMailStamp.php
--- a/src/applications/metamta/stamp/PhabricatorStringMailStamp.php
+++ b/src/applications/metamta/stamp/PhabricatorStringMailStamp.php
@@ -6,11 +6,21 @@
const STAMPTYPE = 'string';
public function renderStamps($value) {
- if (!strlen($value)) {
+ if ($value === null || $value === '') {
return null;
}
- return $this->renderStamp($this->getKey(), $value);
+ $value = (array)$value;
+ if (!$value) {
+ return null;
+ }
+
+ $results = array();
+ foreach ($value as $v) {
+ $results[] = $this->renderStamp($this->getKey(), $v);
+ }
+
+ return $results;
}
}
diff --git a/src/applications/metamta/stamp/PhabricatorViewerMailStamp.php b/src/applications/metamta/stamp/PhabricatorViewerMailStamp.php
deleted file mode 100644
--- a/src/applications/metamta/stamp/PhabricatorViewerMailStamp.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?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/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php b/src/applications/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php
--- a/src/applications/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php
+++ b/src/applications/repository/phid/PhabricatorRepositoryRepositoryPHIDType.php
@@ -41,9 +41,11 @@
$name = $repository->getName();
$uri = $repository->getURI();
- $handle->setName($monogram);
- $handle->setFullName("{$monogram} {$name}");
- $handle->setURI($uri);
+ $handle
+ ->setName($monogram)
+ ->setFullName("{$monogram} {$name}")
+ ->setURI($uri)
+ ->setMailStampName($monogram);
}
}
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
@@ -205,6 +205,25 @@
return $this->mustEncrypt;
}
+ public function getHeraldRuleMonograms() {
+ // Convert the stored "<123>, <456>" string into a list: "H123", "H456".
+ $list = $this->heraldHeader;
+ $list = preg_split('/[, ]+/', $list);
+
+ foreach ($list as $key => $item) {
+ $item = trim($item, '<>');
+
+ if (!is_numeric($item)) {
+ unset($list[$key]);
+ continue;
+ }
+
+ $list[$key] = 'H'.$item;
+ }
+
+ return $list;
+ }
+
public function setIsInverseEdgeEditor($is_inverse_edge_editor) {
$this->isInverseEdgeEditor = $is_inverse_edge_editor;
return $this;
@@ -4109,7 +4128,7 @@
}
}
- sort($results);
+ natcasesort($results);
return $results;
}
diff --git a/src/applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php b/src/applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php
--- a/src/applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php
+++ b/src/applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php
@@ -36,13 +36,9 @@
->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'));
+ $templates[] = id(new PhabricatorStringMailStamp())
+ ->setKey('herald')
+ ->setLabel(pht('Herald Rule'));
return $templates;
}
@@ -71,11 +67,8 @@
$this->getMailStamp('mention')
->setValue($mentioned_phids);
- $this->getMailStamp('self-actor')
- ->setValue($editor->getActingAsPHID());
-
- $this->getMailStamp('self-mention')
- ->setValue($mentioned_phids);
+ $this->getMailStamp('herald')
+ ->setValue($editor->getHeraldRuleMonograms());
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 22, 2:53 AM (7 h, 42 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7587396
Default Alt Text
D18997.id45562.diff (11 KB)
Attached To
Mode
D18997: Add Differential and Herald mail stamps and some refinements
Attached
Detach File
Event Timeline
Log In to Comment