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

Support feed and email in Fund

Summary: Ref T5835. Make fund stories publish to feed and send email.

Test Plan: Made edits, etc., saw them in feed and outbound email.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5835

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

+138 -1
+2
resources/sql/autopatches/20141010.fundmailkey.sql
··· 1 + ALTER TABLE {$NAMESPACE}_fund.fund_initiative 2 + ADD mailKey BINARY(20) NOT NULL;
+2
src/__phutil_library_map__.php
··· 688 688 'FundInitiativePHIDType' => 'applications/fund/phid/FundInitiativePHIDType.php', 689 689 'FundInitiativeQuery' => 'applications/fund/query/FundInitiativeQuery.php', 690 690 'FundInitiativeRemarkupRule' => 'applications/fund/remarkup/FundInitiativeRemarkupRule.php', 691 + 'FundInitiativeReplyHandler' => 'applications/fund/mail/FundInitiativeReplyHandler.php', 691 692 'FundInitiativeSearchEngine' => 'applications/fund/query/FundInitiativeSearchEngine.php', 692 693 'FundInitiativeTransaction' => 'applications/fund/storage/FundInitiativeTransaction.php', 693 694 'FundInitiativeTransactionQuery' => 'applications/fund/query/FundInitiativeTransactionQuery.php', ··· 3579 3580 'FundInitiativePHIDType' => 'PhabricatorPHIDType', 3580 3581 'FundInitiativeQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 3581 3582 'FundInitiativeRemarkupRule' => 'PhabricatorObjectRemarkupRule', 3583 + 'FundInitiativeReplyHandler' => 'PhabricatorMailReplyHandler', 3582 3584 'FundInitiativeSearchEngine' => 'PhabricatorApplicationSearchEngine', 3583 3585 'FundInitiativeTransaction' => 'PhabricatorApplicationTransaction', 3584 3586 'FundInitiativeTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
+47
src/applications/fund/editor/FundInitiativeEditor.php
··· 231 231 return $errors; 232 232 } 233 233 234 + protected function shouldSendMail( 235 + PhabricatorLiskDAO $object, 236 + array $xactions) { 237 + return true; 238 + } 239 + 240 + public function getMailTagsMap() { 241 + return array( 242 + FundInitiativeTransaction::MAILTAG_BACKER => 243 + pht('Someone backs an initiative.'), 244 + FundInitiativeTransaction::MAILTAG_STATUS => 245 + pht("An initiative's status changes."), 246 + FundInitiativeTransaction::MAILTAG_OTHER => 247 + pht('Other initiative activity not listed above occurs.'), 248 + ); 249 + } 250 + 251 + protected function buildMailTemplate(PhabricatorLiskDAO $object) { 252 + $monogram = $object->getMonogram(); 253 + $name = $object->getName(); 254 + 255 + return id(new PhabricatorMetaMTAMail()) 256 + ->setSubject("{$monogram}: {$name}") 257 + ->addHeader('Thread-Topic', $monogram); 258 + } 259 + 260 + 261 + protected function getMailTo(PhabricatorLiskDAO $object) { 262 + return array($object->getOwnerPHID()); 263 + } 264 + 265 + protected function getMailSubjectPrefix() { 266 + return 'Fund'; 267 + } 268 + 269 + protected function buildReplyHandler(PhabricatorLiskDAO $object) { 270 + return id(new FundInitiativeReplyHandler()) 271 + ->setMailReceiver($object); 272 + } 273 + 274 + protected function shouldPublishFeedStory( 275 + PhabricatorLiskDAO $object, 276 + array $xactions) { 277 + return true; 278 + } 279 + 280 + 234 281 235 282 }
+38
src/applications/fund/mail/FundInitiativeReplyHandler.php
··· 1 + <?php 2 + 3 + final class FundInitiativeReplyHandler extends PhabricatorMailReplyHandler { 4 + 5 + public function validateMailReceiver($mail_receiver) { 6 + if (!($mail_receiver instanceof FundInitiative)) { 7 + throw new Exception('Mail receiver is not a FundInitiative!'); 8 + } 9 + } 10 + 11 + public function getPrivateReplyHandlerEmailAddress( 12 + PhabricatorObjectHandle $handle) { 13 + return $this->getDefaultPrivateReplyHandlerEmailAddress($handle, 'I'); 14 + } 15 + 16 + public function getPublicReplyHandlerEmailAddress() { 17 + return $this->getDefaultPublicReplyHandlerEmailAddress('I'); 18 + } 19 + 20 + public function getReplyHandlerDomain() { 21 + return PhabricatorEnv::getEnvConfig('metamta.reply-handler-domain'); 22 + } 23 + 24 + public function getReplyHandlerInstructions() { 25 + if ($this->supportsReplies()) { 26 + // TODO: Implement. 27 + return null; 28 + } else { 29 + return null; 30 + } 31 + } 32 + 33 + protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) { 34 + // TODO: Implement. 35 + return null; 36 + } 37 + 38 + }
+9
src/applications/fund/storage/FundInitiative.php
··· 20 20 protected $editPolicy; 21 21 protected $status; 22 22 protected $totalAsCurrency; 23 + protected $mailKey; 23 24 24 25 private $projectPHIDs = self::ATTACHABLE; 25 26 ··· 59 60 'status' => 'text32', 60 61 'merchantPHID' => 'phid?', 61 62 'totalAsCurrency' => 'text64', 63 + 'mailKey' => 'bytes20', 62 64 ), 63 65 self::CONFIG_APPLICATION_SERIALIZERS => array( 64 66 'totalAsCurrency' => new PhortuneCurrencySerializer(), ··· 93 95 94 96 public function isClosed() { 95 97 return ($this->getStatus() == self::STATUS_CLOSED); 98 + } 99 + 100 + public function save() { 101 + if (!$this->mailKey) { 102 + $this->mailKey = Filesystem::readRandomCharacters(20); 103 + } 104 + return parent::save(); 96 105 } 97 106 98 107
+40 -1
src/applications/fund/storage/FundInitiativeTransaction.php
··· 11 11 const TYPE_REFUND = 'fund:refund'; 12 12 const TYPE_MERCHANT = 'fund:merchant'; 13 13 14 + const MAILTAG_BACKER = 'fund.backer'; 15 + const MAILTAG_STATUS = 'fund.status'; 16 + const MAILTAG_OTHER = 'fund.other'; 17 + 14 18 const PROPERTY_AMOUNT = 'fund.amount'; 15 19 const PROPERTY_BACKER = 'fund.backer'; 16 20 ··· 172 176 } 173 177 break; 174 178 case FundInitiativeTransaction::TYPE_BACKER: 179 + $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); 180 + $amount = PhortuneCurrency::newFromString($amount); 175 181 return pht( 176 - '%s backed %s.', 182 + '%s backed %s with %s.', 183 + $this->renderHandleLink($author_phid), 184 + $this->renderHandleLink($object_phid), 185 + $amount->formatForDisplay()); 186 + case FundInitiativeTransaction::TYPE_REFUND: 187 + $amount = $this->getMetadataValue(self::PROPERTY_AMOUNT); 188 + $amount = PhortuneCurrency::newFromString($amount); 189 + 190 + $backer_phid = $this->getMetadataValue(self::PROPERTY_BACKER); 191 + 192 + return pht( 193 + '%s refunded %s to %s for %s.', 177 194 $this->renderHandleLink($author_phid), 195 + $amount->formatForDisplay(), 196 + $this->renderHandleLink($backer_phid), 178 197 $this->renderHandleLink($object_phid)); 179 198 } 180 199 181 200 return parent::getTitleForFeed($story); 182 201 } 202 + 203 + public function getMailTags() { 204 + $tags = parent::getMailTags(); 205 + 206 + switch ($this->getTransactionType()) { 207 + case self::TYPE_STATUS: 208 + $tags[] = self::MAILTAG_STATUS; 209 + break; 210 + case self::TYPE_BACKER: 211 + case self::TYPE_REFUND: 212 + $tags[] = self::MAILTAG_BACKER; 213 + break; 214 + default: 215 + $tags[] = self::MAILTAG_OTHER; 216 + break; 217 + } 218 + 219 + return $tags; 220 + } 221 + 183 222 184 223 public function shouldHide() { 185 224 $old = $this->getOldValue();