[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class FileReplyHandler extends PhabricatorMailReplyHandler { 4 5 public function validateMailReceiver($mail_receiver) { 6 if (!($mail_receiver instanceof PhabricatorFile)) { 7 throw new Exception('Mail receiver is not a PhabricatorFile.'); 8 } 9 } 10 11 public function getPrivateReplyHandlerEmailAddress( 12 PhabricatorObjectHandle $handle) { 13 return $this->getDefaultPrivateReplyHandlerEmailAddress($handle, 'F'); 14 } 15 16 public function getPublicReplyHandlerEmailAddress() { 17 return $this->getDefaultPublicReplyHandlerEmailAddress('F'); 18 } 19 20 public function getReplyHandlerInstructions() { 21 if ($this->supportsReplies()) { 22 return pht('Reply to comment or !unsubscribe.'); 23 } else { 24 return null; 25 } 26 } 27 28 protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) { 29 $actor = $this->getActor(); 30 $file = $this->getMailReceiver(); 31 32 $body_data = $mail->parseBody(); 33 $body = $body_data['body']; 34 $body = $this->enhanceBodyWithAttachments($body, $mail->getAttachments()); 35 36 $content_source = PhabricatorContentSource::newForSource( 37 PhabricatorContentSource::SOURCE_EMAIL, 38 array( 39 'id' => $mail->getID(), 40 )); 41 42 $xactions = array(); 43 $command = $body_data['body']; 44 45 switch ($command) { 46 case 'unsubscribe': 47 $xaction = id(new PhabricatorFileTransaction()) 48 ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) 49 ->setNewValue(array('-' => array($actor->getPHID()))); 50 $xactions[] = $xaction; 51 break; 52 } 53 54 $xactions[] = id(new PhabricatorFileTransaction()) 55 ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 56 ->attachComment( 57 id(new PhabricatorFileTransactionComment()) 58 ->setContent($body)); 59 60 $editor = id(new PhabricatorFileEditor()) 61 ->setActor($actor) 62 ->setContentSource($content_source) 63 ->setContinueOnNoEffect(true) 64 ->setIsPreview(false); 65 66 try { 67 $xactions = $editor->applyTransactions($file, $xactions); 68 } catch (PhabricatorApplicationTransactionNoEffectException $ex) { 69 // just do nothing, though unclear why you're sending a blank email 70 return true; 71 } 72 73 $head_xaction = head($xactions); 74 return $head_xaction->getID(); 75 } 76 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |