Path: blob/master/src/applications/paste/mail/PasteCreateMailReceiver.php
12241 views
<?php12final class PasteCreateMailReceiver3extends PhabricatorApplicationMailReceiver {45protected function newApplication() {6return new PhabricatorPasteApplication();7}89protected function processReceivedMail(10PhabricatorMetaMTAReceivedMail $mail,11PhutilEmailAddress $target) {12$author = $this->getAuthor();1314$title = $mail->getSubject();15if (!$title) {16$title = pht('Email Paste');17}1819$xactions = array();2021$xactions[] = id(new PhabricatorPasteTransaction())22->setTransactionType(PhabricatorPasteContentTransaction::TRANSACTIONTYPE)23->setNewValue($mail->getCleanTextBody());2425$xactions[] = id(new PhabricatorPasteTransaction())26->setTransactionType(PhabricatorPasteTitleTransaction::TRANSACTIONTYPE)27->setNewValue($title);2829$paste = PhabricatorPaste::initializeNewPaste($author);3031$content_source = $mail->newContentSource();3233$editor = id(new PhabricatorPasteEditor())34->setActor($author)35->setContentSource($content_source)36->setContinueOnNoEffect(true);37$xactions = $editor->applyTransactions($paste, $xactions);3839$mail->setRelatedPHID($paste->getPHID());4041$sender = $this->getSender();42if (!$sender) {43return;44}4546$subject_prefix = pht('[Paste]');47$subject = pht('You successfully created a paste.');48$paste_uri = PhabricatorEnv::getProductionURI($paste->getURI());49$body = new PhabricatorMetaMTAMailBody();50$body->addRawSection($subject);51$body->addTextSection(pht('PASTE LINK'), $paste_uri);5253id(new PhabricatorMetaMTAMail())54->addTos(array($sender->getPHID()))55->setSubject($subject)56->setSubjectPrefix($subject_prefix)57->setFrom($sender->getPHID())58->setRelatedPHID($paste->getPHID())59->setBody($body->render())60->saveAndSend();61}6263}646566