[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PasteReplyHandler extends PhabricatorMailReplyHandler { 4 5 public function validateMailReceiver($mail_receiver) { 6 if (!($mail_receiver instanceof PhabricatorPaste)) { 7 throw new Exception('Mail receiver is not a PhabricatorPaste.'); 8 } 9 } 10 11 public function getPrivateReplyHandlerEmailAddress( 12 PhabricatorObjectHandle $handle) { 13 return $this->getDefaultPrivateReplyHandlerEmailAddress($handle, 'P'); 14 } 15 16 public function getPublicReplyHandlerEmailAddress() { 17 return $this->getDefaultPublicReplyHandlerEmailAddress('P'); 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 $paste = $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 $lines = explode("\n", trim($body)); 43 $first_line = head($lines); 44 45 $xactions = array(); 46 $command = $body_data['command']; 47 48 switch ($command) { 49 case 'unsubscribe': 50 $xaction = id(new PhabricatorPasteTransaction()) 51 ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) 52 ->setNewValue(array('-' => array($actor->getPHID()))); 53 $xactions[] = $xaction; 54 break; 55 } 56 57 $xactions[] = id(new PhabricatorPasteTransaction()) 58 ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 59 ->attachComment( 60 id(new PhabricatorPasteTransactionComment()) 61 ->setContent($body)); 62 63 $editor = id(new PhabricatorPasteEditor()) 64 ->setActor($actor) 65 ->setContentSource($content_source) 66 ->setContinueOnNoEffect(true) 67 ->setIsPreview(false); 68 69 try { 70 $xactions = $editor->applyTransactions($paste, $xactions); 71 } catch (PhabricatorApplicationTransactionNoEffectException $ex) { 72 // just do nothing, though unclear why you're sending a blank email 73 return true; 74 } 75 76 $head_xaction = head($xactions); 77 return $head_xaction->getID(); 78 } 79 80 }
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 |