@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Maniphest + Herald - add support for assigning tasks and adding projects

Summary: This ends up living in HeraldAdapter even though its "task only" stuff. Reason being There are 4 or 5 functions that have little hooks; see diff. Ref T1638.

Test Plan: made a rule to assign tasks to me if made on web - great success. made a rule to assign tasks to other guy and add a project if title contained "foobar" - great success, including some confusion as ther two herald rules fought each other for task ownership.

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T1638

Differential Revision: https://secure.phabricator.com/D7146

+92 -18
+31 -18
src/applications/herald/adapter/HeraldAdapter.php
··· 39 39 const CONDITION_NOT_EXISTS = '!exists'; 40 40 const CONDITION_REGEXP_PAIR = 'regexp-pair'; 41 41 42 - const ACTION_ADD_CC = 'addcc'; 43 - const ACTION_REMOVE_CC = 'remcc'; 44 - const ACTION_EMAIL = 'email'; 45 - const ACTION_NOTHING = 'nothing'; 46 - const ACTION_AUDIT = 'audit'; 47 - const ACTION_FLAG = 'flag'; 42 + const ACTION_ADD_CC = 'addcc'; 43 + const ACTION_REMOVE_CC = 'remcc'; 44 + const ACTION_EMAIL = 'email'; 45 + const ACTION_NOTHING = 'nothing'; 46 + const ACTION_AUDIT = 'audit'; 47 + const ACTION_FLAG = 'flag'; 48 + const ACTION_ASSIGN_TASK = 'assigntask'; 49 + const ACTION_ADD_PROJECTS = 'addprojects'; 48 50 49 51 const VALUE_TEXT = 'text'; 50 52 const VALUE_NONE = 'none'; ··· 440 442 switch ($rule_type) { 441 443 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: 442 444 return array( 443 - self::ACTION_NOTHING => pht('Do nothing'), 444 - self::ACTION_ADD_CC => pht('Add emails to CC'), 445 - self::ACTION_REMOVE_CC => pht('Remove emails from CC'), 446 - self::ACTION_EMAIL => pht('Send an email to'), 447 - self::ACTION_AUDIT => pht('Trigger an Audit by'), 448 - self::ACTION_FLAG => pht('Mark with flag'), 445 + self::ACTION_NOTHING => pht('Do nothing'), 446 + self::ACTION_ADD_CC => pht('Add emails to CC'), 447 + self::ACTION_REMOVE_CC => pht('Remove emails from CC'), 448 + self::ACTION_EMAIL => pht('Send an email to'), 449 + self::ACTION_AUDIT => pht('Trigger an Audit by'), 450 + self::ACTION_FLAG => pht('Mark with flag'), 451 + self::ACTION_ASSIGN_TASK => pht('Assign task to'), 452 + self::ACTION_ADD_PROJECTS => pht('Add projects'), 449 453 ); 450 454 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: 451 455 return array( 452 - self::ACTION_NOTHING => pht('Do nothing'), 453 - self::ACTION_ADD_CC => pht('Add me to CC'), 454 - self::ACTION_REMOVE_CC => pht('Remove me from CC'), 455 - self::ACTION_EMAIL => pht('Send me an email'), 456 - self::ACTION_AUDIT => pht('Trigger an Audit by me'), 457 - self::ACTION_FLAG => pht('Mark with flag'), 456 + self::ACTION_NOTHING => pht('Do nothing'), 457 + self::ACTION_ADD_CC => pht('Add me to CC'), 458 + self::ACTION_REMOVE_CC => pht('Remove me from CC'), 459 + self::ACTION_EMAIL => pht('Send me an email'), 460 + self::ACTION_AUDIT => pht('Trigger an Audit by me'), 461 + self::ACTION_FLAG => pht('Mark with flag'), 462 + self::ACTION_ASSIGN_TASK => pht('Assign task to me.'), 463 + self::ACTION_ADD_PROJECTS => pht('Add projects'), 458 464 ); 459 465 default: 460 466 throw new Exception("Unknown rule type '{$rule_type}'!"); ··· 479 485 case self::ACTION_ADD_CC: 480 486 case self::ACTION_REMOVE_CC: 481 487 case self::ACTION_AUDIT: 488 + case self::ACTION_ASSIGN_TASK: 482 489 // For personal rules, force these actions to target the rule owner. 483 490 $target = array($author_phid); 484 491 break; ··· 571 578 case self::ACTION_EMAIL: 572 579 case self::ACTION_NOTHING: 573 580 case self::ACTION_AUDIT: 581 + case self::ACTION_ASSIGN_TASK: 574 582 return self::VALUE_NONE; 575 583 case self::ACTION_FLAG: 576 584 return self::VALUE_FLAG_COLOR; 585 + case self::ACTION_ADD_PROJECTS: 586 + return self::VALUE_PROJECT; 577 587 default: 578 588 throw new Exception("Unknown or invalid action '{$action}'."); 579 589 } ··· 586 596 case self::ACTION_NOTHING: 587 597 return self::VALUE_NONE; 588 598 case self::ACTION_AUDIT: 599 + case self::ACTION_ADD_PROJECTS: 589 600 return self::VALUE_PROJECT; 590 601 case self::ACTION_FLAG: 591 602 return self::VALUE_FLAG_COLOR; 603 + case self::ACTION_ASSIGN_TASK: 604 + return self::VALUE_USER; 592 605 default: 593 606 throw new Exception("Unknown or invalid action '{$action}'."); 594 607 }
+41
src/applications/herald/adapter/HeraldManiphestTaskAdapter.php
··· 7 7 8 8 private $task; 9 9 private $ccPHIDs = array(); 10 + private $assignPHID; 11 + private $projectPHIDs = array(); 10 12 11 13 public function setTask(ManiphestTask $task) { 12 14 $this->task = $task; ··· 24 26 return $this->ccPHIDs; 25 27 } 26 28 29 + public function setAssignPHID($assign_phid) { 30 + $this->assignPHID = $assign_phid; 31 + return $this; 32 + } 33 + public function getAssignPHID() { 34 + return $this->assignPHID; 35 + } 36 + 37 + public function setProjectPHIDs(array $project_phids) { 38 + $this->projectPHIDs = $project_phids; 39 + return $this; 40 + } 41 + public function getProjectPHIDs() { 42 + return $this->projectPHIDs; 43 + } 44 + 27 45 public function getAdapterContentName() { 28 46 return pht('Maniphest Tasks'); 29 47 } ··· 43 61 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: 44 62 return array( 45 63 self::ACTION_ADD_CC, 64 + self::ACTION_ASSIGN_TASK, 65 + self::ACTION_ADD_PROJECTS, 46 66 self::ACTION_NOTHING, 47 67 ); 48 68 case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: 49 69 return array( 50 70 self::ACTION_ADD_CC, 51 71 self::ACTION_FLAG, 72 + self::ACTION_ASSIGN_TASK, 52 73 self::ACTION_NOTHING, 53 74 ); 54 75 } ··· 105 126 $result[] = parent::applyFlagEffect( 106 127 $effect, 107 128 $this->getTask()->getPHID()); 129 + break; 130 + case self::ACTION_ASSIGN_TASK: 131 + $target_array = $effect->getTarget(); 132 + $assign_phid = reset($target_array); 133 + $this->setAssignPHID($assign_phid); 134 + $result[] = new HeraldApplyTranscript( 135 + $effect, 136 + true, 137 + pht('Assigned task.')); 138 + break; 139 + case self::ACTION_ADD_PROJECTS: 140 + $add_projects = array(); 141 + foreach ($effect->getTarget() as $phid) { 142 + $add_projects[$phid] = true; 143 + } 144 + $this->setProjectPHIDs(array_keys($add_projects)); 145 + $result[] = new HeraldApplyTranscript( 146 + $effect, 147 + true, 148 + pht('Added projects.')); 108 149 break; 109 150 default: 110 151 throw new Exception("No rules to handle action '{$action}'.");
+20
src/applications/maniphest/editor/ManiphestTransactionEditorPro.php
··· 217 217 HeraldAdapter $adapter, 218 218 HeraldTranscript $transcript) { 219 219 220 + $save_again = false; 220 221 $cc_phids = $adapter->getCcPHIDs(); 221 222 if ($cc_phids) { 222 223 $existing_cc = $object->getCCPHIDs(); 223 224 $new_cc = array_unique(array_merge($cc_phids, $existing_cc)); 224 225 $object->setCCPHIDs($new_cc); 226 + $save_again = true; 227 + } 228 + 229 + $assign_phid = $adapter->getAssignPHID(); 230 + if ($assign_phid) { 231 + $object->setOwnerPHID($assign_phid); 232 + $save_again = true; 233 + } 234 + 235 + $project_phids = $adapter->getProjectPHIDs(); 236 + if ($project_phids) { 237 + $existing_projects = $object->getProjectPHIDs(); 238 + $new_projects = array_unique( 239 + array_merge($project_phids, $existing_projects)); 240 + $object->setProjectPHIDs($new_projects); 241 + $save_again = true; 242 + } 243 + 244 + if ($save_again) { 225 245 $object->save(); 226 246 } 227 247 }