Remove product literal strings in "pht()", part 5
[phabricator.git] / src / applications / files / mail / FileCreateMailReceiver.php
blobf3f31d9130e5ac5b09f260069a4cec030d1d3c74
1 <?php
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,
19 pht(
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();
26 if (!$sender) {
27 return;
30 $attachment_count = count($attachment_phids);
31 if ($attachment_count > 1) {
32 $subject = pht('You successfully uploaded %d files.', $attachment_count);
33 } else {
34 $subject = pht('You successfully uploaded a file.');
36 $subject_prefix = pht('[File]');
38 $file_uris = array();
39 foreach ($attachment_phids as $phid) {
40 $file_uris[] =
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())
55 ->saveAndSend();