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

Modularize Application Email Herald field

Summary:
Ref T8726. There's no interface we can check for this, so the adapter needs to opt in.

Also fix a spelling mistake.

Test Plan: Created rules with "Application Email" fields.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8726

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

+57 -24
+5
resources/sql/autopatches/20150630.herald.1.sql
··· 1 + # NOTE: This is a spelling correction. 2 + 3 + UPDATE {$NAMESPACE}_herald.herald_condition 4 + SET fieldName = 'application-email' 5 + WHERE fieldName = 'applicaton-email';
+2
src/__phutil_library_map__.php
··· 2112 2112 'PhabricatorMetaMTAApplicationEmail' => 'applications/metamta/storage/PhabricatorMetaMTAApplicationEmail.php', 2113 2113 'PhabricatorMetaMTAApplicationEmailDatasource' => 'applications/metamta/typeahead/PhabricatorMetaMTAApplicationEmailDatasource.php', 2114 2114 'PhabricatorMetaMTAApplicationEmailEditor' => 'applications/metamta/editor/PhabricatorMetaMTAApplicationEmailEditor.php', 2115 + 'PhabricatorMetaMTAApplicationEmailHeraldField' => 'applications/metamta/herald/PhabricatorMetaMTAApplicationEmailHeraldField.php', 2115 2116 'PhabricatorMetaMTAApplicationEmailPHIDType' => 'applications/phid/PhabricatorMetaMTAApplicationEmailPHIDType.php', 2116 2117 'PhabricatorMetaMTAApplicationEmailPanel' => 'applications/metamta/applicationpanel/PhabricatorMetaMTAApplicationEmailPanel.php', 2117 2118 'PhabricatorMetaMTAApplicationEmailQuery' => 'applications/metamta/query/PhabricatorMetaMTAApplicationEmailQuery.php', ··· 5800 5801 ), 5801 5802 'PhabricatorMetaMTAApplicationEmailDatasource' => 'PhabricatorTypeaheadDatasource', 5802 5803 'PhabricatorMetaMTAApplicationEmailEditor' => 'PhabricatorApplicationTransactionEditor', 5804 + 'PhabricatorMetaMTAApplicationEmailHeraldField' => 'HeraldField', 5803 5805 'PhabricatorMetaMTAApplicationEmailPHIDType' => 'PhabricatorPHIDType', 5804 5806 'PhabricatorMetaMTAApplicationEmailPanel' => 'PhabricatorApplicationConfigurationPanel', 5805 5807 'PhabricatorMetaMTAApplicationEmailQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+5 -23
src/applications/herald/adapter/HeraldAdapter.php
··· 29 29 const FIELD_BRANCHES = 'branches'; 30 30 const FIELD_AUTHOR_RAW = 'author-raw'; 31 31 const FIELD_COMMITTER_RAW = 'committer-raw'; 32 - const FIELD_APPLICATION_EMAIL = 'applicaton-email'; 33 32 const FIELD_TASK_PRIORITY = 'taskpriority'; 34 33 const FIELD_TASK_STATUS = 'taskstatus'; 35 34 const FIELD_PUSHER_IS_COMMITTER = 'pusher-is-committer'; ··· 164 163 return $this; 165 164 } 166 165 166 + public function supportsApplicationEmail() { 167 + return false; 168 + } 169 + 167 170 public function setApplicationEmail( 168 171 PhabricatorMetaMTAApplicationEmail $email) { 169 172 $this->applicationEmail = $email; ··· 183 186 return $impl->getHeraldFieldValue($this->getObject()); 184 187 } 185 188 186 - switch ($field_name) { 187 - case self::FIELD_APPLICATION_EMAIL: 188 - $value = array(); 189 - // while there is only one match by implementation, we do set 190 - // comparisons on phids, so return an array with just the phid 191 - if ($this->getApplicationEmail()) { 192 - $value[] = $this->getApplicationEmail()->getPHID(); 193 - } 194 - return $value; 195 - default: 196 - throw new Exception(pht("Unknown field '%s'!", $field_name)); 197 - } 189 + throw new Exception(pht("Unknown field '%s'!", $field_name)); 198 190 } 199 191 200 192 abstract public function applyHeraldEffects(array $effects); ··· 391 383 self::FIELD_BRANCHES => pht('Commit\'s branches'), 392 384 self::FIELD_AUTHOR_RAW => pht('Raw author name'), 393 385 self::FIELD_COMMITTER_RAW => pht('Raw committer name'), 394 - self::FIELD_APPLICATION_EMAIL => pht('Receiving email address'), 395 386 self::FIELD_TASK_PRIORITY => pht('Task priority'), 396 387 self::FIELD_TASK_STATUS => pht('Task status'), 397 388 self::FIELD_PUSHER_IS_COMMITTER => pht('Pusher same as committer'), ··· 476 467 case self::FIELD_REPOSITORY_PROJECTS: 477 468 return array( 478 469 self::CONDITION_INCLUDE_ALL, 479 - self::CONDITION_INCLUDE_ANY, 480 - self::CONDITION_INCLUDE_NONE, 481 - self::CONDITION_EXISTS, 482 - self::CONDITION_NOT_EXISTS, 483 - ); 484 - case self::FIELD_APPLICATION_EMAIL: 485 - return array( 486 470 self::CONDITION_INCLUDE_ANY, 487 471 self::CONDITION_INCLUDE_NONE, 488 472 self::CONDITION_EXISTS, ··· 944 928 return self::VALUE_PROJECT; 945 929 case self::FIELD_REVIEWERS: 946 930 return self::VALUE_USER_OR_PROJECT; 947 - case self::FIELD_APPLICATION_EMAIL: 948 - return self::VALUE_APPLICATION_EMAIL; 949 931 default: 950 932 return self::VALUE_USER; 951 933 }
+4 -1
src/applications/herald/adapter/HeraldManiphestTaskAdapter.php
··· 21 21 $this->task = $this->newObject(); 22 22 } 23 23 24 + public function supportsApplicationEmail() { 25 + return true; 26 + } 27 + 24 28 public function getRepetitionOptions() { 25 29 return array( 26 30 HeraldRepetitionPolicyConfig::EVERY, ··· 72 76 self::FIELD_ASSIGNEE, 73 77 self::FIELD_TASK_PRIORITY, 74 78 self::FIELD_TASK_STATUS, 75 - self::FIELD_APPLICATION_EMAIL, 76 79 ), 77 80 parent::getFields()); 78 81 }
+41
src/applications/metamta/herald/PhabricatorMetaMTAApplicationEmailHeraldField.php
··· 1 + <?php 2 + 3 + final class PhabricatorMetaMTAApplicationEmailHeraldField 4 + extends HeraldField { 5 + 6 + const FIELDCONST = 'application-email'; 7 + 8 + public function getHeraldFieldName() { 9 + return pht('Receiving email address'); 10 + } 11 + 12 + public function supportsObject($object) { 13 + return $this->getAdapter()->supportsApplicationEmail(); 14 + } 15 + 16 + public function getHeraldFieldValue($object) { 17 + $phids = array(); 18 + 19 + $email = $this->getAdapter()->getApplicationEmail(); 20 + if ($email) { 21 + $phids[] = $email; 22 + } 23 + 24 + return $phids; 25 + } 26 + 27 + protected function getHeraldFieldStandardConditions() { 28 + return self::STANDARD_LIST; 29 + } 30 + 31 + public function getHeraldFieldValueType($condition) { 32 + switch ($condition) { 33 + case HeraldAdapter::CONDITION_EXISTS: 34 + case HeraldAdapter::CONDITION_NOT_EXISTS: 35 + return HeraldAdapter::VALUE_NONE; 36 + default: 37 + return HeraldAdapter::VALUE_APPLICATION_EMAIL; 38 + } 39 + } 40 + 41 + }