diff --git a/scripts/mail/mail_handler.php b/scripts/mail/mail_handler.php index 214b51ee1a..0341a0e464 100755 --- a/scripts/mail/mail_handler.php +++ b/scripts/mail/mail_handler.php @@ -77,6 +77,7 @@ foreach ($parser->getAttachments() as $attachment) { $attachment->getContent(), array( 'name' => $attachment->getFilename(), + 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, )); $attachments[] = $file->getPHID(); } diff --git a/src/applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php b/src/applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php index d6bd298504..ce27366da3 100644 --- a/src/applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php +++ b/src/applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php @@ -56,7 +56,7 @@ final class PhabricatorMetaMTAMailgunReceiveController $file = PhabricatorFile::newFromPHPUpload( $file_raw, array( - 'authorPHID' => $user->getPHID(), + 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, )); $file_phids[] = $file->getPHID(); } catch (Exception $ex) { diff --git a/src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php b/src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php index 7df1539946..11a0184ffd 100644 --- a/src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php +++ b/src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php @@ -42,7 +42,7 @@ final class PhabricatorMetaMTASendGridReceiveController $file = PhabricatorFile::newFromPHPUpload( $file_raw, array( - 'authorPHID' => $user->getPHID(), + 'viewPolicy' => PhabricatorPolicies::POLICY_NOONE, )); $file_phids[] = $file->getPHID(); } catch (Exception $ex) { diff --git a/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php b/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php index 3d32f308d3..697c0622fe 100644 --- a/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php +++ b/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php @@ -327,11 +327,8 @@ abstract class PhabricatorMailReplyHandler { return $body; } - // NOTE: This is safe, but not entirely correct. Clean it up after - // T7712. These files have the install-default policy right now, which - // may or may not be permissive. $files = id(new PhabricatorFileQuery()) - ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->setViewer($this->getActor()) ->withPHIDs($attachments) ->execute(); diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php index c157537d59..fa5ad7f752 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php @@ -121,6 +121,19 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { $this->setAuthorPHID($sender->getPHID()); + // Now that we've identified the sender, mark them as the author of + // any attached files. + $attachments = $this->getAttachments(); + if ($attachments) { + $files = id(new PhabricatorFileQuery()) + ->setViewer(PhabricatorUser::getOmnipotentUser()) + ->withPHIDs($attachments) + ->execute(); + foreach ($files as $file) { + $file->setAuthorPHID($sender->getPHID())->save(); + } + } + $receiver->receiveMail($this, $sender); } catch (PhabricatorMetaMTAReceivedMailProcessingException $ex) { switch ($ex->getStatusCode()) {