3 final class FileCreateMailReceiver
4 extends PhabricatorApplicationMailReceiver
{
6 protected function newApplication() {
7 return new PhabricatorFilesApplication();
10 protected function processReceivedMail(
11 PhabricatorMetaMTAReceivedMail
$mail,
12 PhutilEmailAddress
$target) {
13 $author = $this->getAuthor();
15 $attachment_phids = $mail->getAttachments();
16 if (empty($attachment_phids)) {
17 throw new PhabricatorMetaMTAReceivedMailProcessingException(
18 MetaMTAReceivedMailStatus
::STATUS_UNHANDLED_EXCEPTION
,
20 'Ignoring email to create files that did not include attachments.'));
22 $first_phid = head($attachment_phids);
23 $mail->setRelatedPHID($first_phid);
25 $sender = $this->getSender();
30 $attachment_count = count($attachment_phids);
31 if ($attachment_count > 1) {
32 $subject = pht('You successfully uploaded %d files.', $attachment_count);
34 $subject = pht('You successfully uploaded a file.');
36 $subject_prefix = pht('[File]');
39 foreach ($attachment_phids as $phid) {
41 PhabricatorEnv
::getProductionURI('/file/info/'.$phid.'/');
44 $body = new PhabricatorMetaMTAMailBody();
45 $body->addRawSection($subject);
46 $body->addTextSection(pht('FILE LINKS'), implode("\n", $file_uris));
48 id(new PhabricatorMetaMTAMail())
49 ->addTos(array($sender->getPHID()))
50 ->setSubject($subject)
51 ->setSubjectPrefix($subject_prefix)
52 ->setFrom($sender->getPHID())
53 ->setRelatedPHID($first_phid)
54 ->setBody($body->render())