Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/mail/FileCreateMailReceiver.php
<?php | <?php | ||||
final class FileCreateMailReceiver | final class FileCreateMailReceiver | ||||
extends PhabricatorApplicationMailReceiver { | extends PhabricatorApplicationMailReceiver { | ||||
protected function newApplication() { | protected function newApplication() { | ||||
return new PhabricatorFilesApplication(); | return new PhabricatorFilesApplication(); | ||||
} | } | ||||
protected function processReceivedMail( | protected function processReceivedMail( | ||||
PhabricatorMetaMTAReceivedMail $mail, | PhabricatorMetaMTAReceivedMail $mail, | ||||
PhabricatorUser $sender) { | PhutilEmailAddress $target) { | ||||
$author = $this->getAuthor(); | |||||
$attachment_phids = $mail->getAttachments(); | $attachment_phids = $mail->getAttachments(); | ||||
if (empty($attachment_phids)) { | if (empty($attachment_phids)) { | ||||
throw new PhabricatorMetaMTAReceivedMailProcessingException( | throw new PhabricatorMetaMTAReceivedMailProcessingException( | ||||
MetaMTAReceivedMailStatus::STATUS_UNHANDLED_EXCEPTION, | MetaMTAReceivedMailStatus::STATUS_UNHANDLED_EXCEPTION, | ||||
pht( | pht( | ||||
'Ignoring email to create files that did not include attachments.')); | 'Ignoring email to create files that did not include attachments.')); | ||||
} | } | ||||
$first_phid = head($attachment_phids); | $first_phid = head($attachment_phids); | ||||
$mail->setRelatedPHID($first_phid); | $mail->setRelatedPHID($first_phid); | ||||
$sender = $this->getSender(); | |||||
if (!$sender) { | |||||
return; | |||||
} | |||||
$attachment_count = count($attachment_phids); | $attachment_count = count($attachment_phids); | ||||
if ($attachment_count > 1) { | if ($attachment_count > 1) { | ||||
$subject = pht('You successfully uploaded %d files.', $attachment_count); | $subject = pht('You successfully uploaded %d files.', $attachment_count); | ||||
} else { | } else { | ||||
$subject = pht('You successfully uploaded a file.'); | $subject = pht('You successfully uploaded a file.'); | ||||
} | } | ||||
$subject_prefix = | $subject_prefix = | ||||
PhabricatorEnv::getEnvConfig('metamta.files.subject-prefix'); | PhabricatorEnv::getEnvConfig('metamta.files.subject-prefix'); | ||||
Show All 22 Lines |