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

at upstream/main 92 lines 2.4 kB view raw
1<?php 2 3final class PhabricatorApplicationObjectMailEngineExtension 4 extends PhabricatorMailEngineExtension { 5 6 const EXTENSIONKEY = 'application/object'; 7 8 public function supportsObject($object) { 9 return true; 10 } 11 12 public function newMailStampTemplates($object) { 13 $templates = array( 14 id(new PhabricatorStringMailStamp()) 15 ->setKey('application') 16 ->setLabel(pht('Application')), 17 ); 18 19 if ($this->hasMonogram($object)) { 20 $templates[] = id(new PhabricatorStringMailStamp()) 21 ->setKey('monogram') 22 ->setLabel(pht('Object Monogram')); 23 } 24 25 if ($this->hasPHID($object)) { 26 // This is a PHID, but we always want to render it as a raw string, so 27 // use a string mail stamp. 28 $templates[] = id(new PhabricatorStringMailStamp()) 29 ->setKey('phid') 30 ->setLabel(pht('Object PHID')); 31 32 $templates[] = id(new PhabricatorStringMailStamp()) 33 ->setKey('object-type') 34 ->setLabel(pht('Object Type')); 35 } 36 37 return $templates; 38 } 39 40 public function newMailStamps($object, array $xactions) { 41 $editor = $this->getEditor(); 42 $viewer = $this->getViewer(); 43 44 $application = null; 45 $class = $editor->getEditorApplicationClass(); 46 if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { 47 $application = newv($class, array()); 48 } 49 50 if ($application) { 51 $application_name = $application->getName(); 52 $this->getMailStamp('application') 53 ->setValue($application_name); 54 } 55 56 if ($this->hasMonogram($object)) { 57 $monogram = $object->getMonogram(); 58 $this->getMailStamp('monogram') 59 ->setValue($monogram); 60 } 61 62 if ($this->hasPHID($object)) { 63 $object_phid = $object->getPHID(); 64 65 $this->getMailStamp('phid') 66 ->setValue($object_phid); 67 68 $phid_type = phid_get_type($object_phid); 69 if ($phid_type != PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN) { 70 $this->getMailStamp('object-type') 71 ->setValue($phid_type); 72 } 73 } 74 } 75 76 private function hasPHID($object) { 77 if (!($object instanceof LiskDAO)) { 78 return false; 79 } 80 81 if (!$object->getConfigOption(LiskDAO::CONFIG_AUX_PHID)) { 82 return false; 83 } 84 85 return true; 86 } 87 88 private function hasMonogram($object) { 89 return method_exists($object, 'getMonogram'); 90 } 91 92}