@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 recaptime-dev/main 142 lines 3.7 kB view raw
1<?php 2 3final class PhamePostEditor 4 extends PhabricatorApplicationTransactionEditor { 5 6 public function getEditorApplicationClass() { 7 return PhabricatorPhameApplication::class; 8 } 9 10 public function getEditorObjectsDescription() { 11 return pht('Phame Posts'); 12 } 13 14 public function getCreateObjectTitle($author, $object) { 15 return pht('%s created this post.', $author); 16 } 17 18 public function getCreateObjectTitleForFeed($author, $object) { 19 return pht('%s created %s.', $author, $object); 20 } 21 22 public function getTransactionTypes() { 23 $types = parent::getTransactionTypes(); 24 25 $types[] = PhabricatorTransactions::TYPE_INTERACT_POLICY; 26 $types[] = PhabricatorTransactions::TYPE_COMMENT; 27 28 return $types; 29 } 30 31 protected function shouldSendMail( 32 PhabricatorLiskDAO $object, 33 array $xactions) { 34 if ($object->isDraft() || ($object->isArchived())) { 35 return false; 36 } 37 return true; 38 } 39 40 protected function shouldPublishFeedStory( 41 PhabricatorLiskDAO $object, 42 array $xactions) { 43 if ($object->isDraft() || $object->isArchived()) { 44 return false; 45 } 46 return true; 47 } 48 49 protected function getMailTo(PhabricatorLiskDAO $object) { 50 $phids = array(); 51 $phids[] = $object->getBloggerPHID(); 52 $phids[] = $this->requireActor()->getPHID(); 53 54 $blog_phid = $object->getBlogPHID(); 55 if ($blog_phid) { 56 $cc_phids = PhabricatorSubscribersQuery::loadSubscribersForPHID( 57 $blog_phid); 58 foreach ($cc_phids as $cc) { 59 $phids[] = $cc; 60 } 61 } 62 return $phids; 63 } 64 65 protected function buildMailTemplate(PhabricatorLiskDAO $object) { 66 $title = $object->getTitle(); 67 68 return id(new PhabricatorMetaMTAMail()) 69 ->setSubject($title); 70 } 71 72 protected function buildReplyHandler(PhabricatorLiskDAO $object) { 73 return id(new PhamePostReplyHandler()) 74 ->setMailReceiver($object); 75 } 76 77 protected function buildMailBody( 78 PhabricatorLiskDAO $object, 79 array $xactions) { 80 81 $body = parent::buildMailBody($object, $xactions); 82 83 // We don't send mail if the object is a draft, and we only want 84 // to include the full body of the post on the either the 85 // first creation or if it was created as a draft, once it goes live. 86 if ($this->getIsNewObject()) { 87 $body->addRemarkupSection(null, $object->getBody()); 88 } else { 89 foreach ($xactions as $xaction) { 90 switch ($xaction->getTransactionType()) { 91 case PhamePostVisibilityTransaction::TRANSACTIONTYPE: 92 if (!$object->isDraft() && !$object->isArchived()) { 93 $body->addRemarkupSection(null, $object->getBody()); 94 } 95 break; 96 } 97 } 98 } 99 100 $body->addLinkSection( 101 pht('POST DETAIL'), 102 PhabricatorEnv::getProductionURI($object->getViewURI())); 103 104 return $body; 105 } 106 107 public function getMailTagsMap() { 108 return array( 109 PhamePostTransaction::MAILTAG_CONTENT => 110 pht("A post's content changes."), 111 PhamePostTransaction::MAILTAG_SUBSCRIBERS => 112 pht("A post's subscribers change."), 113 PhamePostTransaction::MAILTAG_COMMENT => 114 pht('Someone comments on a post.'), 115 PhamePostTransaction::MAILTAG_OTHER => 116 pht('Other post activity not listed above occurs.'), 117 ); 118 } 119 120 protected function getMailSubjectPrefix() { 121 return '[Phame]'; 122 } 123 124 protected function supportsSearch() { 125 return true; 126 } 127 128 protected function shouldApplyHeraldRules( 129 PhabricatorLiskDAO $object, 130 array $xactions) { 131 return true; 132 } 133 134 protected function buildHeraldAdapter( 135 PhabricatorLiskDAO $object, 136 array $xactions) { 137 138 return id(new HeraldPhamePostAdapter()) 139 ->setPost($object); 140 } 141 142}