[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/conpherence/mail/ -> ConpherenceReplyHandler.php (source)

   1  <?php
   2  
   3  final class ConpherenceReplyHandler extends PhabricatorMailReplyHandler {
   4  
   5    private $mailAddedParticipantPHIDs;
   6  
   7    public function setMailAddedParticipantPHIDs(array $phids) {
   8      $this->mailAddedParticipantPHIDs = $phids;
   9      return $this;
  10    }
  11    public function getMailAddedParticipantPHIDs() {
  12      return $this->mailAddedParticipantPHIDs;
  13    }
  14  
  15    public function validateMailReceiver($mail_receiver) {
  16      if (!($mail_receiver instanceof ConpherenceThread)) {
  17        throw new Exception('Mail receiver is not a ConpherenceThread!');
  18      }
  19    }
  20  
  21    public function getPrivateReplyHandlerEmailAddress(
  22      PhabricatorObjectHandle $handle) {
  23      return $this->getDefaultPrivateReplyHandlerEmailAddress($handle, 'E');
  24    }
  25  
  26    public function getPublicReplyHandlerEmailAddress() {
  27      return $this->getDefaultPublicReplyHandlerEmailAddress('E');
  28    }
  29  
  30    public function getReplyHandlerInstructions() {
  31      if ($this->supportsReplies()) {
  32        return pht('Reply to comment and attach files.');
  33      } else {
  34        return null;
  35      }
  36    }
  37  
  38    protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) {
  39      $conpherence = $this->getMailReceiver();
  40      $user = $this->getActor();
  41      if (!$conpherence->getPHID()) {
  42        $conpherence
  43          ->attachParticipants(array())
  44          ->attachFilePHIDs(array());
  45      } else {
  46        $edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_FILE;
  47        $file_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
  48          $conpherence->getPHID(),
  49          $edge_type);
  50        $conpherence->attachFilePHIDs($file_phids);
  51        $participants = id(new ConpherenceParticipant())
  52          ->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID());
  53        $participants = mpull($participants, null, 'getParticipantPHID');
  54        $conpherence->attachParticipants($participants);
  55      }
  56  
  57      $content_source = PhabricatorContentSource::newForSource(
  58        PhabricatorContentSource::SOURCE_EMAIL,
  59        array(
  60          'id' => $mail->getID(),
  61        ));
  62  
  63      $editor = id(new ConpherenceEditor())
  64        ->setActor($user)
  65        ->setContentSource($content_source)
  66        ->setParentMessageID($mail->getMessageID());
  67  
  68      $body = $mail->getCleanTextBody();
  69      $file_phids = $mail->getAttachments();
  70      $body = $this->enhanceBodyWithAttachments(
  71        $body,
  72        $file_phids,
  73        '{F%d}');
  74  
  75      $xactions = array();
  76      if ($this->getMailAddedParticipantPHIDs()) {
  77        $xactions[] = id(new ConpherenceTransaction())
  78          ->setTransactionType(ConpherenceTransactionType::TYPE_PARTICIPANTS)
  79          ->setNewValue(array('+' => $this->getMailAddedParticipantPHIDs()));
  80      }
  81  
  82      $xactions = array_merge(
  83        $xactions,
  84        $editor->generateTransactionsFromText(
  85          $user,
  86          $conpherence,
  87          $body));
  88  
  89      $editor->applyTransactions($conpherence, $xactions);
  90  
  91      return $conpherence;
  92    }
  93  
  94  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1