From 1ff68376f50d5bf22212444f6918f7367f47c8ea Mon Sep 17 00:00:00 2001 From: 20after4 <20after4@deviantart.com> Date: Tue, 17 Apr 2012 12:09:04 -0700 Subject: [PATCH] New maniphest event TYPE_MANIPHEST_DIDEDITTASK Summary: This event is fired after a task is created and assigned with an id. Use case is sending an email notification to everyone in a project when a new task is submitted to said project. Test Plan: Implement the event listener, submit a new task to a project, see if the project members receive an email notification. I will submit the event handler in a separate diff once it's a bit prettier and tested more thoroughly. Reviewers: epriestley Reviewed By: epriestley CC: aran, jungejason Differential Revision: https://secure.phabricator.com/D2159 --- .../base/ConduitAPI_maniphest_Method.php | 12 ++++++++++++ .../taskedit/ManiphestTaskEditController.php | 16 +++++++++++++++- .../replyhandler/ManiphestReplyHandler.php | 11 +++++++++++ .../constant/type/PhabricatorEventType.php | 3 ++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php b/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php index 517caae2cb..a3dee43da0 100644 --- a/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php +++ b/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php @@ -169,6 +169,18 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod { $editor = new ManiphestTransactionEditor(); $editor->applyTransactions($task, $transactions); + + $event = new PhabricatorEvent( + PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK, + array( + 'task' => $task, + 'new' => $is_new, + 'transactions' => $transactions, + )); + $event->setUser($request->getUser()); + $event->setConduitRequest($request); + PhutilEventEngine::dispatchEvent($event); + } protected function buildTaskInfoDictionaries(array $tasks) { diff --git a/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php b/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php index c07e0a7820..44b1cd84c8 100644 --- a/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php +++ b/src/applications/maniphest/controller/taskedit/ManiphestTaskEditController.php @@ -214,11 +214,13 @@ final class ManiphestTaskEditController extends ManiphestController { } if ($transactions) { + $is_new = !$task->getID(); + $event = new PhabricatorEvent( PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK, array( 'task' => $task, - 'new' => !$task->getID(), + 'new' => $is_new, 'transactions' => $transactions, )); $event->setUser($user); @@ -231,8 +233,20 @@ final class ManiphestTaskEditController extends ManiphestController { $editor = new ManiphestTransactionEditor(); $editor->setAuxiliaryFields($aux_fields); $editor->applyTransactions($task, $transactions); + + $event = new PhabricatorEvent( + PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK, + array( + 'task' => $task, + 'new' => $is_new, + 'transactions' => $transactions, + )); + $event->setUser($user); + $event->setAphrontRequest($request); + PhutilEventEngine::dispatchEvent($event); } + if ($parent_task) { $type_task = PhabricatorPHIDConstants::PHID_TYPE_TASK; diff --git a/src/applications/maniphest/replyhandler/ManiphestReplyHandler.php b/src/applications/maniphest/replyhandler/ManiphestReplyHandler.php index f042007dad..52935b44f7 100644 --- a/src/applications/maniphest/replyhandler/ManiphestReplyHandler.php +++ b/src/applications/maniphest/replyhandler/ManiphestReplyHandler.php @@ -168,6 +168,17 @@ final class ManiphestReplyHandler extends PhabricatorMailReplyHandler { $editor = new ManiphestTransactionEditor(); $editor->setParentMessageID($mail->getMessageID()); $editor->applyTransactions($task, $xactions); + + $event = new PhabricatorEvent( + PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK, + array( + 'task' => $task, + 'new' => $is_new_task, + 'transactions' => $xactions, + )); + $event->setUser($user); + PhutilEventEngine::dispatchEvent($event); + } } diff --git a/src/infrastructure/events/constant/type/PhabricatorEventType.php b/src/infrastructure/events/constant/type/PhabricatorEventType.php index 9d13a84ea2..c2f96dbe24 100644 --- a/src/infrastructure/events/constant/type/PhabricatorEventType.php +++ b/src/infrastructure/events/constant/type/PhabricatorEventType.php @@ -1,7 +1,7 @@