From a1ccee8c242e74aa35c245e3d8da206f3c48b16f Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 7 Dec 2015 11:07:15 -0800 Subject: [PATCH] Implicitly subscribe task author when they create a task Summary: Ref T9908. This is a behavioral change: - Old behavior: "Subscribers" field is default-populated with author. - New behavior: this transaction is just created no matter what. The new behavior is much easier to make work with form defaults, hidden fields, etc. For example, on the "Create Bug" form, I've hidden "Subscribers", but I still want the author to be subscribed. And if a user sets the default value of "Subscribers:" to "Alice, Bob", they almost certainly mean "Alice, Bob, and the task author". And I ended up deleting myself by accident way more often than I deleted myself on purpose -- especially with "Create Similar task", I'd sometimes delete all the CCs and delete myself by accident and then have to put myself back. Finally, technically speaking, restoring the old behavior is kind of hard/messy and this is much easier. Test Plan: - Created a task. - Was automatically added as a subscriber. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9908 Differential Revision: https://secure.phabricator.com/D14694 --- .../editor/ManiphestTransactionEditor.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index c0a763dbcb..f014e13083 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -748,6 +748,10 @@ final class ManiphestTransactionEditor protected function expandTransactions( PhabricatorLiskDAO $object, array $xactions) { + + $actor = $this->getActor(); + $actor_phid = $actor->getPHID(); + $results = parent::expandTransactions($object, $xactions); $is_unassigned = ($object->getOwnerPHID() === null); @@ -781,8 +785,6 @@ final class ManiphestTransactionEditor // being closed, try to assign the actor as the owner. if ($is_unassigned && !$any_assign && $is_open && $is_closing) { // Don't assign the actor if they aren't a real user. - $actor = $this->getActor(); - $actor_phid = $actor->getPHID(); if ($actor_phid) { $results[] = id(new ManiphestTransaction()) ->setTransactionType(ManiphestTransaction::TYPE_OWNER) @@ -790,6 +792,18 @@ final class ManiphestTransactionEditor } } + // Automatically subscribe the author when they create a task. + if ($this->getIsNewObject()) { + if ($actor_phid) { + $results[] = id(new ManiphestTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) + ->setNewValue( + array( + '+' => array($actor_phid => $actor_phid), + )); + } + } + return $results; }