protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) { $conpherence = $this->getMailReceiver(); $user = $this->getActor(); if (!$conpherence->getPHID()) { $conpherence->attachParticipants(array())->attachFilePHIDs(array()); } else { $edge_type = PhabricatorObjectHasFileEdgeType::EDGECONST; $file_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($conpherence->getPHID(), $edge_type); $conpherence->attachFilePHIDs($file_phids); $participants = id(new ConpherenceParticipant())->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID()); $participants = mpull($participants, null, 'getParticipantPHID'); $conpherence->attachParticipants($participants); } $content_source = $mail->newContentSource(); $editor = id(new ConpherenceEditor())->setActor($user)->setContentSource($content_source)->setParentMessageID($mail->getMessageID()); $body = $mail->getCleanTextBody(); $body = $this->enhanceBodyWithAttachments($body, $mail->getAttachments()); $xactions = array(); if ($this->getMailAddedParticipantPHIDs()) { $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PARTICIPANTS)->setNewValue(array('+' => $this->getMailAddedParticipantPHIDs())); } $xactions = array_merge($xactions, $editor->generateTransactionsFromText($user, $conpherence, $body)); $editor->applyTransactions($conpherence, $xactions); return $conpherence; }
private function newEditor(PhabricatorMetaMTAReceivedMail $mail) { $content_source = $mail->newContentSource(); $editor = $this->getMailReceiver()->getApplicationTransactionEditor()->setActor($this->getActor())->setContentSource($content_source)->setContinueOnMissingFields(true)->setParentMessageID($mail->getMessageID())->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs()); if ($this->getApplicationEmail()) { $editor->setApplicationEmail($this->getApplicationEmail()); } return $editor; }
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender) { $title = $mail->getSubject(); if (!strlen($title)) { $title = pht('New Question'); } $xactions = array(); $xactions[] = id(new PonderQuestionTransaction())->setTransactionType(PonderQuestionTransaction::TYPE_TITLE)->setNewValue($title); $xactions[] = id(new PonderQuestionTransaction())->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT)->setNewValue($mail->getCleanTextBody()); $question = PonderQuestion::initializeNewQuestion($sender); $content_source = $mail->newContentSource(); $editor = id(new PonderQuestionEditor())->setActor($sender)->setContentSource($content_source)->setContinueOnNoEffect(true); $xactions = $editor->applyTransactions($question, $xactions); $mail->setRelatedPHID($question->getPHID()); }
protected function processReceivedMail(PhabricatorMetaMTAReceivedMail $mail, PhabricatorUser $sender) { $title = $mail->getSubject(); if (!$title) { $title = pht('Email Paste'); } $xactions = array(); $xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorPasteContentTransaction::TRANSACTIONTYPE)->setNewValue($mail->getCleanTextBody()); $xactions[] = id(new PhabricatorPasteTransaction())->setTransactionType(PhabricatorPasteTitleTransaction::TRANSACTIONTYPE)->setNewValue($title); $paste = PhabricatorPaste::initializeNewPaste($sender); $content_source = $mail->newContentSource(); $editor = id(new PhabricatorPasteEditor())->setActor($sender)->setContentSource($content_source)->setContinueOnNoEffect(true); $xactions = $editor->applyTransactions($paste, $xactions); $mail->setRelatedPHID($paste->getPHID()); $subject_prefix = PhabricatorEnv::getEnvConfig('metamta.paste.subject-prefix'); $subject = pht('You successfully created a paste.'); $paste_uri = PhabricatorEnv::getProductionURI($paste->getURI()); $body = new PhabricatorMetaMTAMailBody(); $body->addRawSection($subject); $body->addTextSection(pht('PASTE LINK'), $paste_uri); id(new PhabricatorMetaMTAMail())->addTos(array($sender->getPHID()))->setSubject($subject)->setSubjectPrefix($subject_prefix)->setFrom($sender->getPHID())->setRelatedPHID($paste->getPHID())->setBody($body->render())->saveAndSend(); }