From 7d475eb09af74b42da52ca258d2fbf130fca6a3e Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 5 Feb 2018 11:09:36 -0800 Subject: [PATCH] Add more mail stamps: tasks, subscribers, projects, spaces Summary: Ref T13053. Adds task stamps plus the major infrastructure applications. Test Plan: {F5413058} Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13053 Differential Revision: https://secure.phabricator.com/D18996 --- src/__phutil_library_map__.php | 8 +++ .../ManiphestMailEngineExtension.php | 58 +++++++++++++++++++ .../phid/PhabricatorOwnersPackagePHIDType.php | 1 + ...PhabricatorProjectsMailEngineExtension.php | 32 ++++++++++ .../PhabricatorSpacesMailEngineExtension.php | 35 +++++++++++ .../PhabricatorSpacesNamespacePHIDType.php | 8 ++- ...icatorSubscriptionsMailEngineExtension.php | 32 ++++++++++ 7 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 src/applications/maniphest/engineextension/ManiphestMailEngineExtension.php create mode 100644 src/applications/project/engineextension/PhabricatorProjectsMailEngineExtension.php create mode 100644 src/applications/spaces/engineextension/PhabricatorSpacesMailEngineExtension.php create mode 100644 src/applications/subscriptions/engineextension/PhabricatorSubscriptionsMailEngineExtension.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 2a84849171..4742ce410e 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1528,6 +1528,7 @@ phutil_register_library_map(array( 'ManiphestGetTaskTransactionsConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestGetTaskTransactionsConduitAPIMethod.php', 'ManiphestHovercardEngineExtension' => 'applications/maniphest/engineextension/ManiphestHovercardEngineExtension.php', 'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php', + 'ManiphestMailEngineExtension' => 'applications/maniphest/engineextension/ManiphestMailEngineExtension.php', 'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php', 'ManiphestPointsConfigType' => 'applications/maniphest/config/ManiphestPointsConfigType.php', 'ManiphestPrioritiesConfigType' => 'applications/maniphest/config/ManiphestPrioritiesConfigType.php', @@ -3853,6 +3854,7 @@ phutil_register_library_map(array( 'PhabricatorProjectsEditField' => 'applications/transactions/editfield/PhabricatorProjectsEditField.php', 'PhabricatorProjectsExportEngineExtension' => 'infrastructure/export/engine/PhabricatorProjectsExportEngineExtension.php', 'PhabricatorProjectsFulltextEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsFulltextEngineExtension.php', + 'PhabricatorProjectsMailEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsMailEngineExtension.php', 'PhabricatorProjectsMembersSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsMembersSearchEngineAttachment.php', 'PhabricatorProjectsMembershipIndexEngineExtension' => 'applications/project/engineextension/PhabricatorProjectsMembershipIndexEngineExtension.php', 'PhabricatorProjectsPolicyRule' => 'applications/project/policyrule/PhabricatorProjectsPolicyRule.php', @@ -4146,6 +4148,7 @@ phutil_register_library_map(array( 'PhabricatorSpacesExportEngineExtension' => 'infrastructure/export/engine/PhabricatorSpacesExportEngineExtension.php', 'PhabricatorSpacesInterface' => 'applications/spaces/interface/PhabricatorSpacesInterface.php', 'PhabricatorSpacesListController' => 'applications/spaces/controller/PhabricatorSpacesListController.php', + 'PhabricatorSpacesMailEngineExtension' => 'applications/spaces/engineextension/PhabricatorSpacesMailEngineExtension.php', 'PhabricatorSpacesNamespace' => 'applications/spaces/storage/PhabricatorSpacesNamespace.php', 'PhabricatorSpacesNamespaceArchiveTransaction' => 'applications/spaces/xaction/PhabricatorSpacesNamespaceArchiveTransaction.php', 'PhabricatorSpacesNamespaceDatasource' => 'applications/spaces/typeahead/PhabricatorSpacesNamespaceDatasource.php', @@ -4230,6 +4233,7 @@ phutil_register_library_map(array( 'PhabricatorSubscriptionsFulltextEngineExtension' => 'applications/subscriptions/engineextension/PhabricatorSubscriptionsFulltextEngineExtension.php', 'PhabricatorSubscriptionsHeraldAction' => 'applications/subscriptions/herald/PhabricatorSubscriptionsHeraldAction.php', 'PhabricatorSubscriptionsListController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsListController.php', + 'PhabricatorSubscriptionsMailEngineExtension' => 'applications/subscriptions/engineextension/PhabricatorSubscriptionsMailEngineExtension.php', 'PhabricatorSubscriptionsRemoveSelfHeraldAction' => 'applications/subscriptions/herald/PhabricatorSubscriptionsRemoveSelfHeraldAction.php', 'PhabricatorSubscriptionsRemoveSubscribersHeraldAction' => 'applications/subscriptions/herald/PhabricatorSubscriptionsRemoveSubscribersHeraldAction.php', 'PhabricatorSubscriptionsSearchEngineAttachment' => 'applications/subscriptions/engineextension/PhabricatorSubscriptionsSearchEngineAttachment.php', @@ -6795,6 +6799,7 @@ phutil_register_library_map(array( 'ManiphestGetTaskTransactionsConduitAPIMethod' => 'ManiphestConduitAPIMethod', 'ManiphestHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension', 'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod', + 'ManiphestMailEngineExtension' => 'PhabricatorMailEngineExtension', 'ManiphestNameIndex' => 'ManiphestDAO', 'ManiphestPointsConfigType' => 'PhabricatorJSONConfigType', 'ManiphestPrioritiesConfigType' => 'PhabricatorJSONConfigType', @@ -9482,6 +9487,7 @@ phutil_register_library_map(array( 'PhabricatorProjectsEditField' => 'PhabricatorTokenizerEditField', 'PhabricatorProjectsExportEngineExtension' => 'PhabricatorExportEngineExtension', 'PhabricatorProjectsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension', + 'PhabricatorProjectsMailEngineExtension' => 'PhabricatorMailEngineExtension', 'PhabricatorProjectsMembersSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', 'PhabricatorProjectsMembershipIndexEngineExtension' => 'PhabricatorIndexEngineExtension', 'PhabricatorProjectsPolicyRule' => 'PhabricatorPolicyRule', @@ -9851,6 +9857,7 @@ phutil_register_library_map(array( 'PhabricatorSpacesExportEngineExtension' => 'PhabricatorExportEngineExtension', 'PhabricatorSpacesInterface' => 'PhabricatorPHIDInterface', 'PhabricatorSpacesListController' => 'PhabricatorSpacesController', + 'PhabricatorSpacesMailEngineExtension' => 'PhabricatorMailEngineExtension', 'PhabricatorSpacesNamespace' => array( 'PhabricatorSpacesDAO', 'PhabricatorPolicyInterface', @@ -9941,6 +9948,7 @@ phutil_register_library_map(array( 'PhabricatorSubscriptionsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension', 'PhabricatorSubscriptionsHeraldAction' => 'HeraldAction', 'PhabricatorSubscriptionsListController' => 'PhabricatorController', + 'PhabricatorSubscriptionsMailEngineExtension' => 'PhabricatorMailEngineExtension', 'PhabricatorSubscriptionsRemoveSelfHeraldAction' => 'PhabricatorSubscriptionsHeraldAction', 'PhabricatorSubscriptionsRemoveSubscribersHeraldAction' => 'PhabricatorSubscriptionsHeraldAction', 'PhabricatorSubscriptionsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment', diff --git a/src/applications/maniphest/engineextension/ManiphestMailEngineExtension.php b/src/applications/maniphest/engineextension/ManiphestMailEngineExtension.php new file mode 100644 index 0000000000..ee38bdf604 --- /dev/null +++ b/src/applications/maniphest/engineextension/ManiphestMailEngineExtension.php @@ -0,0 +1,58 @@ +setKey('author') + ->setLabel(pht('Author')), + id(new PhabricatorPHIDMailStamp()) + ->setKey('task-owner') + ->setLabel(pht('Task Owner')), + id(new PhabricatorBoolMailStamp()) + ->setKey('task-unassigned') + ->setLabel(pht('Task Unassigned')), + id(new PhabricatorStringMailStamp()) + ->setKey('task-priority') + ->setLabel(pht('Task Priority')), + id(new PhabricatorStringMailStamp()) + ->setKey('task-status') + ->setLabel(pht('Task Status')), + id(new PhabricatorStringMailStamp()) + ->setKey('subtype') + ->setLabel(pht('Subtype')), + ); + } + + public function newMailStamps($object, array $xactions) { + $editor = $this->getEditor(); + $viewer = $this->getViewer(); + + $this->getMailStamp('author') + ->setValue($object->getAuthorPHID()); + + $this->getMailStamp('task-owner') + ->setValue($object->getOwnerPHID()); + + $this->getMailStamp('task-unassigned') + ->setValue(!$object->getOwnerPHID()); + + $this->getMailStamp('task-priority') + ->setValue($object->getPriority()); + + $this->getMailStamp('task-status') + ->setValue($object->getStatus()); + + $this->getMailStamp('subtype') + ->setValue($object->getSubtype()); + } + +} diff --git a/src/applications/owners/phid/PhabricatorOwnersPackagePHIDType.php b/src/applications/owners/phid/PhabricatorOwnersPackagePHIDType.php index cfbaf6eeb2..fbff6a2103 100644 --- a/src/applications/owners/phid/PhabricatorOwnersPackagePHIDType.php +++ b/src/applications/owners/phid/PhabricatorOwnersPackagePHIDType.php @@ -45,6 +45,7 @@ final class PhabricatorOwnersPackagePHIDType extends PhabricatorPHIDType { ->setName($monogram) ->setFullName("{$monogram}: {$name}") ->setCommandLineObjectName("{$monogram} {$name}") + ->setMailStampName($monogram) ->setURI($uri); if ($package->isArchived()) { diff --git a/src/applications/project/engineextension/PhabricatorProjectsMailEngineExtension.php b/src/applications/project/engineextension/PhabricatorProjectsMailEngineExtension.php new file mode 100644 index 0000000000..6f92f87b11 --- /dev/null +++ b/src/applications/project/engineextension/PhabricatorProjectsMailEngineExtension.php @@ -0,0 +1,32 @@ +setKey('tag') + ->setLabel(pht('Tagged with Project')), + ); + } + + public function newMailStamps($object, array $xactions) { + $editor = $this->getEditor(); + $viewer = $this->getViewer(); + + $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( + $object->getPHID(), + PhabricatorProjectObjectHasProjectEdgeType::EDGECONST); + + $this->getMailStamp('tag') + ->setValue($project_phids); + } + +} diff --git a/src/applications/spaces/engineextension/PhabricatorSpacesMailEngineExtension.php b/src/applications/spaces/engineextension/PhabricatorSpacesMailEngineExtension.php new file mode 100644 index 0000000000..7ddbda05fe --- /dev/null +++ b/src/applications/spaces/engineextension/PhabricatorSpacesMailEngineExtension.php @@ -0,0 +1,35 @@ +setKey('space') + ->setLabel(pht('Space')), + ); + } + + public function newMailStamps($object, array $xactions) { + $editor = $this->getEditor(); + $viewer = $this->getViewer(); + + if (!PhabricatorSpacesNamespaceQuery::getSpacesExist()) { + return; + } + + $space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID( + $object); + + $this->getMailStamp('space') + ->setValue($space_phid); + } + +} diff --git a/src/applications/spaces/phid/PhabricatorSpacesNamespacePHIDType.php b/src/applications/spaces/phid/PhabricatorSpacesNamespacePHIDType.php index 86371d6420..1399e71c8e 100644 --- a/src/applications/spaces/phid/PhabricatorSpacesNamespacePHIDType.php +++ b/src/applications/spaces/phid/PhabricatorSpacesNamespacePHIDType.php @@ -36,9 +36,11 @@ final class PhabricatorSpacesNamespacePHIDType $monogram = $namespace->getMonogram(); $name = $namespace->getNamespaceName(); - $handle->setName($name); - $handle->setFullName(pht('%s %s', $monogram, $name)); - $handle->setURI('/'.$monogram); + $handle + ->setName($name) + ->setFullName(pht('%s %s', $monogram, $name)) + ->setURI('/'.$monogram) + ->setMailStampName($monogram); if ($namespace->getIsArchived()) { $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); diff --git a/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsMailEngineExtension.php b/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsMailEngineExtension.php new file mode 100644 index 0000000000..122fad4b0d --- /dev/null +++ b/src/applications/subscriptions/engineextension/PhabricatorSubscriptionsMailEngineExtension.php @@ -0,0 +1,32 @@ +setKey('subscriber') + ->setLabel(pht('Subscriber')), + ); + } + + public function newMailStamps($object, array $xactions) { + $editor = $this->getEditor(); + $viewer = $this->getViewer(); + + $subscriber_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( + $object->getPHID(), + PhabricatorObjectHasSubscriberEdgeType::EDGECONST); + + $this->getMailStamp('subscriber') + ->setValue($subscriber_phids); + } + +}