Skip to content

Commit a804f0a

Browse files
author
epriestley
committedApr 2, 2015
Make file policies for emailed files more consistent
Summary: Fixes T7712. Currently, files sent via email get default policies, like they were dragged and dropped onto the home page. User expectation is better aligned with giving files more restrictive policies, like they were draggged and dropped directly onto an object. Make files sent via email have restricted default visibility. Once we identify the sender, set them as the file author. Later, the file will become visible to other users via attachment to a task, revision, etc. Test Plan: Sent some files via email; verified they got restrictive policies, correct authorship, and appropriate object attachment. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7712 Differential Revision: https://secure.phabricator.com/D12255
1 parent e74c386 commit a804f0a

5 files changed

+17
-6
lines changed
 

‎scripts/mail/mail_handler.php

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
$attachment->getContent(),
7878
array(
7979
'name' => $attachment->getFilename(),
80+
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
8081
));
8182
$attachments[] = $file->getPHID();
8283
}

‎src/applications/metamta/controller/PhabricatorMetaMTAMailgunReceiveController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function processRequest() {
5656
$file = PhabricatorFile::newFromPHPUpload(
5757
$file_raw,
5858
array(
59-
'authorPHID' => $user->getPHID(),
59+
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
6060
));
6161
$file_phids[] = $file->getPHID();
6262
} catch (Exception $ex) {

‎src/applications/metamta/controller/PhabricatorMetaMTASendGridReceiveController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function processRequest() {
4242
$file = PhabricatorFile::newFromPHPUpload(
4343
$file_raw,
4444
array(
45-
'authorPHID' => $user->getPHID(),
45+
'viewPolicy' => PhabricatorPolicies::POLICY_NOONE,
4646
));
4747
$file_phids[] = $file->getPHID();
4848
} catch (Exception $ex) {

‎src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,8 @@ final protected function enhanceBodyWithAttachments(
327327
return $body;
328328
}
329329

330-
// NOTE: This is safe, but not entirely correct. Clean it up after
331-
// T7712. These files have the install-default policy right now, which
332-
// may or may not be permissive.
333330
$files = id(new PhabricatorFileQuery())
334-
->setViewer(PhabricatorUser::getOmnipotentUser())
331+
->setViewer($this->getActor())
335332
->withPHIDs($attachments)
336333
->execute();
337334

‎src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php

+13
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,19 @@ public function processReceivedMail() {
121121

122122
$this->setAuthorPHID($sender->getPHID());
123123

124+
// Now that we've identified the sender, mark them as the author of
125+
// any attached files.
126+
$attachments = $this->getAttachments();
127+
if ($attachments) {
128+
$files = id(new PhabricatorFileQuery())
129+
->setViewer(PhabricatorUser::getOmnipotentUser())
130+
->withPHIDs($attachments)
131+
->execute();
132+
foreach ($files as $file) {
133+
$file->setAuthorPHID($sender->getPHID())->save();
134+
}
135+
}
136+
124137
$receiver->receiveMail($this, $sender);
125138
} catch (PhabricatorMetaMTAReceivedMailProcessingException $ex) {
126139
switch ($ex->getStatusCode()) {

0 commit comments

Comments
 (0)
Failed to load comments.