@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.

Herald - add support for "content source" conditions

Summary: ...and deploy on Maniphest. Ref T1638.

Test Plan: created a herald rule to be cc'd for tasks created via web. made a task via web and another via email and was cc'd appropriately. edited the herald to be cc'd for tasks created via not web. made 2 tasks again and got cc'd appropriately

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T1638

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

+53 -3
+29 -2
src/applications/herald/adapter/HeraldAdapter.php
··· 19 19 const FIELD_RULE = 'rule'; 20 20 const FIELD_AFFECTED_PACKAGE = 'affected-package'; 21 21 const FIELD_AFFECTED_PACKAGE_OWNER = 'affected-package-owner'; 22 + const FIELD_CONTENT_SOURCE = 'contentsource'; 22 23 23 24 const CONDITION_CONTAINS = 'contains'; 24 25 const CONDITION_NOT_CONTAINS = '!contains'; ··· 55 56 const VALUE_OWNERS_PACKAGE = 'package'; 56 57 const VALUE_PROJECT = 'project'; 57 58 const VALUE_FLAG_COLOR = 'flagcolor'; 59 + const VALUE_CONTENT_SOURCE = 'contentsource'; 60 + 61 + private $contentSource; 62 + 63 + public function setContentSource(PhabricatorContentSource $content_source) { 64 + $this->contentSource = $content_source; 65 + return $this; 66 + } 67 + public function getContentSource() { 68 + return $this->contentSource; 69 + } 58 70 59 71 abstract public function getPHID(); 60 72 abstract public function getHeraldName(); ··· 63 75 switch ($field_name) { 64 76 case self::FIELD_RULE: 65 77 return null; 78 + case self::FIELD_CONTENT_SOURCE: 79 + return $this->getContentSource()->getSource(); 66 80 default: 67 81 throw new Exception( 68 82 "Unknown field '{$field_name}'!"); ··· 108 122 self::FIELD_AFFECTED_PACKAGE => pht('Any affected package'), 109 123 self::FIELD_AFFECTED_PACKAGE_OWNER => 110 124 pht("Any affected package's owner"), 125 + self:: FIELD_CONTENT_SOURCE => pht('Content Source') 111 126 ); 112 127 } 113 128 ··· 185 200 return array( 186 201 self::CONDITION_INCLUDE_ANY, 187 202 self::CONDITION_INCLUDE_NONE, 203 + ); 204 + case self::FIELD_CONTENT_SOURCE: 205 + return array( 206 + self::CONDITION_IS, 207 + self::CONDITION_IS_NOT, 188 208 ); 189 209 default: 190 210 throw new Exception( ··· 491 511 switch ($condition) { 492 512 case self::CONDITION_CONTAINS: 493 513 case self::CONDITION_NOT_CONTAINS: 494 - case self::CONDITION_IS: 495 - case self::CONDITION_IS_NOT: 496 514 case self::CONDITION_REGEXP: 497 515 case self::CONDITION_REGEXP_PAIR: 498 516 return self::VALUE_TEXT; 517 + case self::CONDITION_IS: 518 + case self::CONDITION_IS_NOT: 519 + switch ($field) { 520 + case self::FIELD_CONTENT_SOURCE: 521 + return self::VALUE_CONTENT_SOURCE; 522 + default: 523 + return self::VALUE_TEXT; 524 + } 525 + break; 499 526 case self::CONDITION_IS_ANY: 500 527 case self::CONDITION_IS_NOT_ANY: 501 528 switch ($field) {
+1
src/applications/herald/adapter/HeraldManiphestTaskAdapter.php
··· 34 34 self::FIELD_BODY, 35 35 self::FIELD_AUTHOR, 36 36 self::FIELD_CC, 37 + self::FIELD_CONTENT_SOURCE, 37 38 ); 38 39 } 39 40
+2
src/applications/herald/controller/HeraldRuleController.php
··· 413 413 'rules' => $all_rules, 414 414 'colors' => PhabricatorFlagColor::getColorNameMap(), 415 415 'defaultColor' => PhabricatorFlagColor::COLOR_BLUE, 416 + 'contentSources' => PhabricatorContentSource::getSourceNameMap(), 417 + 'defaultSource' => PhabricatorContentSource::SOURCE_WEB 416 418 ), 417 419 'author' => array($rule->getAuthorPHID() => 418 420 $handles[$rule->getAuthorPHID()]->getName()),
+1 -1
src/applications/herald/storage/HeraldRule.php
··· 13 13 protected $repetitionPolicy; 14 14 protected $ruleType; 15 15 16 - protected $configVersion = 9; 16 + protected $configVersion = 10; 17 17 18 18 private $ruleApplied = self::ATTACHABLE; // phids for which this rule has been applied 19 19 private $validAuthor = self::ATTACHABLE;
+13
src/applications/metamta/contentsource/PhabricatorContentSource.php
··· 53 53 array()); 54 54 } 55 55 56 + public static function getSourceNameMap() { 57 + return array( 58 + self::SOURCE_WEB => pht('Web'), 59 + self::SOURCE_EMAIL => pht('Email'), 60 + self::SOURCE_CONDUIT => pht('Conduit'), 61 + self::SOURCE_MOBILE => pht('Mobile'), 62 + self::SOURCE_TABLET => pht('Tablet'), 63 + self::SOURCE_FAX => pht('Fax'), 64 + self::SOURCE_LEGACY => pht('Legacy'), 65 + self::SOURCE_UNKNOWN => pht('Other'), 66 + ); 67 + } 68 + 56 69 public function serialize() { 57 70 return json_encode(array( 58 71 'source' => $this->getSource(),
+1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 1496 1496 array $xactions) { 1497 1497 1498 1498 $adapter = $this->buildHeraldAdapter($object, $xactions); 1499 + $adapter->setContentSource($this->getContentSource()); 1499 1500 $xscript = HeraldEngine::loadAndApplyRules($adapter); 1500 1501 1501 1502 $this->setHeraldAdapter($adapter);
+6
webroot/rsrc/js/application/herald/HeraldRuleEditor.js
··· 225 225 get_fn = JX.bag; 226 226 set_fn = JX.bag; 227 227 break; 228 + case 'contentsource': 229 + input = this._renderSelect(this._config.template.contentSources); 230 + get_fn = function() { return input.value; }; 231 + set_fn = function(v) { input.value = v; }; 232 + set_fn(this._config.template.defaultSource); 233 + break; 228 234 case 'flagcolor': 229 235 input = this._renderSelect(this._config.template.colors); 230 236 get_fn = function() { return input.value; };