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

Define available Herald rule repetition options in terms of "isSingleEventAdapter()"

Summary:
Depends on D18924. Ref T13048. Each adapter defines which repetition options ("every time", "only the first time") users may select for rules.

Currently, this is all explicit and hard-coded. However, every adapter really just implements this rule (except for some bugs, see below):

> You can pick "only the first time" if this adapter fires more than once on the same object.

Since we already have a `isSingleEventAdapter()` method which lets us tell if an adapter fires more than once, just write this rule in the base class and delete all the copy/pasting.

This also fixes two bugs because of the copy/pasting: Pholio Mocks and Phriction Documents did not allow you to write "only the first time" rules. There's no reason for this, they just didn't copy/paste enough methods when they were implemented.

This will make a future diff (which introduces an "if the rule did not match last time" policy) cleaner.

Test Plan:
- Checked several different types of rules, saw appropriate options in the dropdown (pre-commit: no options; tasks: first or every).
- Checked mocks and wiki docs, saw that you can now write "only the first time" rules.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13048

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

+13 -64
-7
src/applications/calendar/herald/PhabricatorCalendarEventHeraldAdapter.php
··· 49 49 } 50 50 } 51 51 52 - public function getRepetitionOptions() { 53 - return array( 54 - HeraldRepetitionPolicyConfig::EVERY, 55 - HeraldRepetitionPolicyConfig::FIRST, 56 - ); 57 - } 58 - 59 52 public function getHeraldName() { 60 53 return $this->getObject()->getMonogram(); 61 54 }
-6
src/applications/differential/herald/HeraldDifferentialDiffAdapter.php
··· 53 53 } 54 54 } 55 55 56 - public function getRepetitionOptions() { 57 - return array( 58 - HeraldRepetitionPolicyConfig::FIRST, 59 - ); 60 - } 61 - 62 56 public function getHeraldName() { 63 57 return pht('New Diff'); 64 58 }
-7
src/applications/differential/herald/HeraldDifferentialRevisionAdapter.php
··· 69 69 } 70 70 } 71 71 72 - public function getRepetitionOptions() { 73 - return array( 74 - HeraldRepetitionPolicyConfig::EVERY, 75 - HeraldRepetitionPolicyConfig::FIRST, 76 - ); 77 - } 78 - 79 72 public static function newLegacyAdapter( 80 73 DifferentialRevision $revision, 81 74 DifferentialDiff $diff) {
+13 -3
src/applications/herald/adapter/HeraldAdapter.php
··· 764 764 765 765 766 766 public function getRepetitionOptions() { 767 - return array( 768 - HeraldRepetitionPolicyConfig::EVERY, 769 - ); 767 + $options = array(); 768 + 769 + $options[] = HeraldRepetitionPolicyConfig::EVERY; 770 + 771 + // Some rules, like pre-commit rules, only ever fire once. It doesn't 772 + // make sense to use state-based repetition policies like "only the first 773 + // time" for these rules. 774 + 775 + if (!$this->isSingleEventAdapter()) { 776 + $options[] = HeraldRepetitionPolicyConfig::FIRST; 777 + } 778 + 779 + return $options; 770 780 } 771 781 772 782 protected function initializeNewAdapter() {
-7
src/applications/maniphest/herald/HeraldManiphestTaskAdapter.php
··· 33 33 return true; 34 34 } 35 35 36 - public function getRepetitionOptions() { 37 - return array( 38 - HeraldRepetitionPolicyConfig::EVERY, 39 - HeraldRepetitionPolicyConfig::FIRST, 40 - ); 41 - } 42 - 43 36 public function supportsRuleType($rule_type) { 44 37 switch ($rule_type) { 45 38 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
-6
src/applications/metamta/herald/PhabricatorMailOutboundMailHeraldAdapter.php
··· 49 49 return true; 50 50 } 51 51 52 - public function getRepetitionOptions() { 53 - return array( 54 - HeraldRepetitionPolicyConfig::FIRST, 55 - ); 56 - } 57 - 58 52 public function supportsRuleType($rule_type) { 59 53 switch ($rule_type) { 60 54 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
-7
src/applications/phame/herald/HeraldPhameBlogAdapter.php
··· 24 24 return true; 25 25 } 26 26 27 - public function getRepetitionOptions() { 28 - return array( 29 - HeraldRepetitionPolicyConfig::EVERY, 30 - HeraldRepetitionPolicyConfig::FIRST, 31 - ); 32 - } 33 - 34 27 public function supportsRuleType($rule_type) { 35 28 switch ($rule_type) { 36 29 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
-7
src/applications/phame/herald/HeraldPhamePostAdapter.php
··· 24 24 return true; 25 25 } 26 26 27 - public function getRepetitionOptions() { 28 - return array( 29 - HeraldRepetitionPolicyConfig::EVERY, 30 - HeraldRepetitionPolicyConfig::FIRST, 31 - ); 32 - } 33 - 34 27 public function supportsRuleType($rule_type) { 35 28 switch ($rule_type) { 36 29 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
-7
src/applications/ponder/herald/HeraldPonderQuestionAdapter.php
··· 39 39 return true; 40 40 } 41 41 42 - public function getRepetitionOptions() { 43 - return array( 44 - HeraldRepetitionPolicyConfig::EVERY, 45 - HeraldRepetitionPolicyConfig::FIRST, 46 - ); 47 - } 48 - 49 42 public function supportsRuleType($rule_type) { 50 43 switch ($rule_type) { 51 44 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
-7
src/applications/project/herald/PhabricatorProjectHeraldAdapter.php
··· 24 24 return true; 25 25 } 26 26 27 - public function getRepetitionOptions() { 28 - return array( 29 - HeraldRepetitionPolicyConfig::EVERY, 30 - HeraldRepetitionPolicyConfig::FIRST, 31 - ); 32 - } 33 - 34 27 public function supportsRuleType($rule_type) { 35 28 switch ($rule_type) { 36 29 case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: