Path: blob/master/src/applications/files/mail/FileCreateMailReceiver.php
12242 views
<?php12final class FileCreateMailReceiver3extends PhabricatorApplicationMailReceiver {45protected function newApplication() {6return new PhabricatorFilesApplication();7}89protected function processReceivedMail(10PhabricatorMetaMTAReceivedMail $mail,11PhutilEmailAddress $target) {12$author = $this->getAuthor();1314$attachment_phids = $mail->getAttachments();15if (empty($attachment_phids)) {16throw new PhabricatorMetaMTAReceivedMailProcessingException(17MetaMTAReceivedMailStatus::STATUS_UNHANDLED_EXCEPTION,18pht(19'Ignoring email to create files that did not include attachments.'));20}21$first_phid = head($attachment_phids);22$mail->setRelatedPHID($first_phid);2324$sender = $this->getSender();25if (!$sender) {26return;27}2829$attachment_count = count($attachment_phids);30if ($attachment_count > 1) {31$subject = pht('You successfully uploaded %d files.', $attachment_count);32} else {33$subject = pht('You successfully uploaded a file.');34}35$subject_prefix = pht('[File]');3637$file_uris = array();38foreach ($attachment_phids as $phid) {39$file_uris[] =40PhabricatorEnv::getProductionURI('/file/info/'.$phid.'/');41}4243$body = new PhabricatorMetaMTAMailBody();44$body->addRawSection($subject);45$body->addTextSection(pht('FILE LINKS'), implode("\n", $file_uris));4647id(new PhabricatorMetaMTAMail())48->addTos(array($sender->getPHID()))49->setSubject($subject)50->setSubjectPrefix($subject_prefix)51->setFrom($sender->getPHID())52->setRelatedPHID($first_phid)53->setBody($body->render())54->saveAndSend();55}5657}585960