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

Add Editor-based mail stamps: actor, via, silent, encrypted, new, mention, self-actor, self-mention

Summary: Ref T13053. Adds more mail tags with information available on the Editor object.

Test Plan: Banged around in Maniphest, viewed the resulting mail, all the stamps seemed to align with reality.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13053

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

+200 -6
+8
src/__phutil_library_map__.php
··· 2220 2220 'PhabricatorBoardResponseEngine' => 'applications/project/engine/PhabricatorBoardResponseEngine.php', 2221 2221 'PhabricatorBoolConfigType' => 'applications/config/type/PhabricatorBoolConfigType.php', 2222 2222 'PhabricatorBoolEditField' => 'applications/transactions/editfield/PhabricatorBoolEditField.php', 2223 + 'PhabricatorBoolMailStamp' => 'applications/metamta/stamp/PhabricatorBoolMailStamp.php', 2223 2224 'PhabricatorBritishEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorBritishEnglishTranslation.php', 2224 2225 'PhabricatorBuiltinDraftEngine' => 'applications/transactions/draft/PhabricatorBuiltinDraftEngine.php', 2225 2226 'PhabricatorBuiltinFileCachePurger' => 'applications/cache/purger/PhabricatorBuiltinFileCachePurger.php', ··· 2813 2814 'PhabricatorEditPage' => 'applications/transactions/editengine/PhabricatorEditPage.php', 2814 2815 'PhabricatorEditType' => 'applications/transactions/edittype/PhabricatorEditType.php', 2815 2816 'PhabricatorEditor' => 'infrastructure/PhabricatorEditor.php', 2817 + 'PhabricatorEditorMailEngineExtension' => 'applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php', 2816 2818 'PhabricatorEditorMultipleSetting' => 'applications/settings/setting/PhabricatorEditorMultipleSetting.php', 2817 2819 'PhabricatorEditorSetting' => 'applications/settings/setting/PhabricatorEditorSetting.php', 2818 2820 'PhabricatorElasticFulltextStorageEngine' => 'applications/search/fulltextstorage/PhabricatorElasticFulltextStorageEngine.php', ··· 3440 3442 'PhabricatorPHIDListEditField' => 'applications/transactions/editfield/PhabricatorPHIDListEditField.php', 3441 3443 'PhabricatorPHIDListEditType' => 'applications/transactions/edittype/PhabricatorPHIDListEditType.php', 3442 3444 'PhabricatorPHIDListExportField' => 'infrastructure/export/field/PhabricatorPHIDListExportField.php', 3445 + 'PhabricatorPHIDMailStamp' => 'applications/metamta/stamp/PhabricatorPHIDMailStamp.php', 3443 3446 'PhabricatorPHIDResolver' => 'applications/phid/resolver/PhabricatorPHIDResolver.php', 3444 3447 'PhabricatorPHIDType' => 'applications/phid/type/PhabricatorPHIDType.php', 3445 3448 'PhabricatorPHIDTypeTestCase' => 'applications/phid/type/__tests__/PhabricatorPHIDTypeTestCase.php', ··· 4395 4398 'PhabricatorVersionedDraft' => 'applications/draft/storage/PhabricatorVersionedDraft.php', 4396 4399 'PhabricatorVeryWowEnglishTranslation' => 'infrastructure/internationalization/translation/PhabricatorVeryWowEnglishTranslation.php', 4397 4400 'PhabricatorViewerDatasource' => 'applications/people/typeahead/PhabricatorViewerDatasource.php', 4401 + 'PhabricatorViewerMailStamp' => 'applications/metamta/stamp/PhabricatorViewerMailStamp.php', 4398 4402 'PhabricatorWatcherHasObjectEdgeType' => 'applications/transactions/edges/PhabricatorWatcherHasObjectEdgeType.php', 4399 4403 'PhabricatorWebContentSource' => 'infrastructure/contentsource/PhabricatorWebContentSource.php', 4400 4404 'PhabricatorWebServerSetupCheck' => 'applications/config/check/PhabricatorWebServerSetupCheck.php', ··· 7582 7586 'PhabricatorBoardResponseEngine' => 'Phobject', 7583 7587 'PhabricatorBoolConfigType' => 'PhabricatorTextConfigType', 7584 7588 'PhabricatorBoolEditField' => 'PhabricatorEditField', 7589 + 'PhabricatorBoolMailStamp' => 'PhabricatorMailStamp', 7585 7590 'PhabricatorBritishEnglishTranslation' => 'PhutilTranslation', 7586 7591 'PhabricatorBuiltinDraftEngine' => 'PhabricatorDraftEngine', 7587 7592 'PhabricatorBuiltinFileCachePurger' => 'PhabricatorCachePurger', ··· 8267 8272 'PhabricatorEditPage' => 'Phobject', 8268 8273 'PhabricatorEditType' => 'Phobject', 8269 8274 'PhabricatorEditor' => 'Phobject', 8275 + 'PhabricatorEditorMailEngineExtension' => 'PhabricatorMailEngineExtension', 8270 8276 'PhabricatorEditorMultipleSetting' => 'PhabricatorSelectSetting', 8271 8277 'PhabricatorEditorSetting' => 'PhabricatorStringSetting', 8272 8278 'PhabricatorElasticFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine', ··· 8973 8979 'PhabricatorPHIDListEditField' => 'PhabricatorEditField', 8974 8980 'PhabricatorPHIDListEditType' => 'PhabricatorEditType', 8975 8981 'PhabricatorPHIDListExportField' => 'PhabricatorListExportField', 8982 + 'PhabricatorPHIDMailStamp' => 'PhabricatorMailStamp', 8976 8983 'PhabricatorPHIDResolver' => 'Phobject', 8977 8984 'PhabricatorPHIDType' => 'Phobject', 8978 8985 'PhabricatorPHIDTypeTestCase' => 'PhutilTestCase', ··· 10137 10144 'PhabricatorVersionedDraft' => 'PhabricatorDraftDAO', 10138 10145 'PhabricatorVeryWowEnglishTranslation' => 'PhutilTranslation', 10139 10146 'PhabricatorViewerDatasource' => 'PhabricatorTypeaheadDatasource', 10147 + 'PhabricatorViewerMailStamp' => 'PhabricatorMailStamp', 10140 10148 'PhabricatorWatcherHasObjectEdgeType' => 'PhabricatorEdgeType', 10141 10149 'PhabricatorWebContentSource' => 'PhabricatorContentSource', 10142 10150 'PhabricatorWebServerSetupCheck' => 'PhabricatorSetupCheck',
+16
src/applications/metamta/stamp/PhabricatorBoolMailStamp.php
··· 1 + <?php 2 + 3 + final class PhabricatorBoolMailStamp 4 + extends PhabricatorMailStamp { 5 + 6 + const STAMPTYPE = 'bool'; 7 + 8 + public function renderStamps($value) { 9 + if (!$value) { 10 + return null; 11 + } 12 + 13 + return $this->renderStamp($this->getKey()); 14 + } 15 + 16 + }
+36
src/applications/metamta/stamp/PhabricatorPHIDMailStamp.php
··· 1 + <?php 2 + 3 + final class PhabricatorPHIDMailStamp 4 + extends PhabricatorMailStamp { 5 + 6 + const STAMPTYPE = 'phid'; 7 + 8 + public function renderStamps($value) { 9 + if ($value === null) { 10 + return null; 11 + } 12 + 13 + $value = (array)$value; 14 + if (!$value) { 15 + return null; 16 + } 17 + 18 + $viewer = $this->getViewer(); 19 + $handles = $viewer->loadHandles($value); 20 + 21 + $results = array(); 22 + foreach ($value as $phid) { 23 + $handle = $handles[$phid]; 24 + 25 + $mail_name = $handle->getMailStampName(); 26 + if ($mail_name === null) { 27 + $mail_name = $handle->getPHID(); 28 + } 29 + 30 + $results[] = $this->renderStamp($this->getKey(), $mail_name); 31 + } 32 + 33 + return $results; 34 + } 35 + 36 + }
+35
src/applications/metamta/stamp/PhabricatorViewerMailStamp.php
··· 1 + <?php 2 + 3 + final class PhabricatorViewerMailStamp 4 + extends PhabricatorMailStamp { 5 + 6 + const STAMPTYPE = 'viewer'; 7 + 8 + public function renderStamps($value) { 9 + // If we're sending one mail to everyone, we never include viewer-based 10 + // stamps since they'll only be accurate for one recipient. Recipients 11 + // can still use the corresponding stamps with their usernames or PHIDs. 12 + if (!PhabricatorMetaMTAMail::shouldMailEachRecipient()) { 13 + return null; 14 + } 15 + 16 + $viewer_phid = $this->getViewer()->getPHID(); 17 + if (!$viewer_phid) { 18 + return null; 19 + } 20 + 21 + if (!$value) { 22 + return null; 23 + } 24 + 25 + $value = (array)$value; 26 + $value = array_fuse($value); 27 + 28 + if (!isset($value[$viewer_phid])) { 29 + return null; 30 + } 31 + 32 + return $this->renderStamp($this->getKey()); 33 + } 34 + 35 + }
+7 -4
src/applications/people/phid/PhabricatorPeopleUserPHIDType.php
··· 39 39 foreach ($handles as $phid => $handle) { 40 40 $user = $objects[$phid]; 41 41 $realname = $user->getRealName(); 42 + $username = $user->getUsername(); 42 43 43 - $handle->setName($user->getUsername()); 44 - $handle->setURI('/p/'.$user->getUsername().'/'); 45 - $handle->setFullName($user->getFullName()); 46 - $handle->setImageURI($user->getProfileImageURI()); 44 + $handle 45 + ->setName($username) 46 + ->setURI('/p/'.$username.'/') 47 + ->setFullName($user->getFullName()) 48 + ->setImageURI($user->getProfileImageURI()) 49 + ->setMailStampName('@'.$username); 47 50 48 51 if ($user->getIsMailingList()) { 49 52 $handle->setIcon('fa-envelope-o');
+10
src/applications/phid/PhabricatorObjectHandle.php
··· 31 31 private $subtitle; 32 32 private $tokenIcon; 33 33 private $commandLineObjectName; 34 + private $mailStampName; 34 35 35 36 private $stateIcon; 36 37 private $stateColor; ··· 132 133 return $this->getName(); 133 134 } 134 135 return $this->objectName; 136 + } 137 + 138 + public function setMailStampName($mail_stamp_name) { 139 + $this->mailStampName = $mail_stamp_name; 140 + return $this; 141 + } 142 + 143 + public function getMailStampName() { 144 + return $this->mailStampName; 135 145 } 136 146 137 147 public function setURI($uri) {
+2 -1
src/applications/project/phid/PhabricatorProjectProjectPHIDType.php
··· 45 45 46 46 if (strlen($slug)) { 47 47 $handle->setObjectName('#'.$slug); 48 + $handle->setMailStampName('#'.$slug); 48 49 $handle->setURI("/tag/{$slug}/"); 49 50 } else { 50 51 // We set the name to the project's PHID to avoid a parse error when a 51 52 // project has no hashtag (as is the case with milestones by default). 52 - // See T12659 for more details 53 + // See T12659 for more details. 53 54 $handle->setCommandLineObjectName($project->getPHID()); 54 55 $handle->setURI("/project/view/{$id}/"); 55 56 }
+5 -1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 179 179 return $this->isNewObject; 180 180 } 181 181 182 - protected function getMentionedPHIDs() { 182 + public function getMentionedPHIDs() { 183 183 return $this->mentionedPHIDs; 184 184 } 185 185 ··· 199 199 200 200 public function getIsSilent() { 201 201 return $this->silent; 202 + } 203 + 204 + public function getMustEncrypt() { 205 + return $this->mustEncrypt; 202 206 } 203 207 204 208 public function setIsInverseEdgeEditor($is_inverse_edge_editor) {
+81
src/applications/transactions/engineextension/PhabricatorEditorMailEngineExtension.php
··· 1 + <?php 2 + 3 + final class PhabricatorEditorMailEngineExtension 4 + extends PhabricatorMailEngineExtension { 5 + 6 + const EXTENSIONKEY = 'editor'; 7 + 8 + public function supportsObject($object) { 9 + return true; 10 + } 11 + 12 + public function newMailStampTemplates($object) { 13 + $templates = array(); 14 + 15 + $templates[] = id(new PhabricatorPHIDMailStamp()) 16 + ->setKey('actor') 17 + ->setLabel(pht('Acting User')); 18 + 19 + $templates[] = id(new PhabricatorStringMailStamp()) 20 + ->setKey('via') 21 + ->setLabel(pht('Via Content Source')); 22 + 23 + $templates[] = id(new PhabricatorBoolMailStamp()) 24 + ->setKey('silent') 25 + ->setLabel(pht('Silent Edit')); 26 + 27 + $templates[] = id(new PhabricatorBoolMailStamp()) 28 + ->setKey('encrypted') 29 + ->setLabel(pht('Encryption Required')); 30 + 31 + $templates[] = id(new PhabricatorBoolMailStamp()) 32 + ->setKey('new') 33 + ->setLabel(pht('New Object')); 34 + 35 + $templates[] = id(new PhabricatorPHIDMailStamp()) 36 + ->setKey('mention') 37 + ->setLabel(pht('Mentioned User')); 38 + 39 + $templates[] = id(new PhabricatorViewerMailStamp()) 40 + ->setKey('self-actor') 41 + ->setLabel(pht('You Acted')); 42 + 43 + $templates[] = id(new PhabricatorViewerMailStamp()) 44 + ->setKey('self-mention') 45 + ->setLabel(pht('You Were Mentioned')); 46 + 47 + return $templates; 48 + } 49 + 50 + public function newMailStamps($object, array $xactions) { 51 + $editor = $this->getEditor(); 52 + $viewer = $this->getViewer(); 53 + 54 + $this->getMailStamp('actor') 55 + ->setValue($editor->getActingAsPHID()); 56 + 57 + $content_source = $editor->getContentSource(); 58 + $this->getMailStamp('via') 59 + ->setValue($content_source->getSourceTypeConstant()); 60 + 61 + $this->getMailStamp('silent') 62 + ->setValue($editor->getIsSilent()); 63 + 64 + $this->getMailStamp('encrypted') 65 + ->setValue($editor->getMustEncrypt()); 66 + 67 + $this->getMailStamp('new') 68 + ->setValue($editor->getIsNewObject()); 69 + 70 + $mentioned_phids = $editor->getMentionedPHIDs(); 71 + $this->getMailStamp('mention') 72 + ->setValue($mentioned_phids); 73 + 74 + $this->getMailStamp('self-actor') 75 + ->setValue($editor->getActingAsPHID()); 76 + 77 + $this->getMailStamp('self-mention') 78 + ->setValue($mentioned_phids); 79 + } 80 + 81 + }