@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make file upload policies more consistent

Summary:
Ref T7149. Currently, global drag and drop always uses the most open visibility policy on the install. This was appropriate before the application preference was introduced, but default to the application preference now.

In particular, this supports a default value of "Administrators" in the Phacility cluster.

Also simplify/clean up some code.

Test Plan:
- Set application default policy to "Adminstrators".
- Uploaded file via drag-and-drop, saw "administrators" policy.
- Uploaded file via `arc upload`, saw "administrators" policy.
- Saw better URI for a text file upload after patch.
- Uploaded file via drag-and-drop-to-textarea, saw "only viewer" policy.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7149

Differential Revision: https://secure.phabricator.com/D12093

+14 -10
+1 -1
src/applications/files/conduit/FileInfoConduitAPIMethod.php
··· 45 45 throw new ConduitException('ERR-NOT-FOUND'); 46 46 } 47 47 48 - $uri = $file->getBestURI(); 48 + $uri = $file->getInfoURI(); 49 49 50 50 return array( 51 51 'id' => $file->getID(),
+5 -8
src/applications/files/conduit/FileUploadConduitAPIMethod.php
··· 29 29 } 30 30 31 31 protected function execute(ConduitAPIRequest $request) { 32 - $data = $request->getValue('data_base64'); 32 + $viewer = $request->getUser(); 33 + 33 34 $name = $request->getValue('name'); 34 35 $can_cdn = $request->getValue('canCDN'); 35 36 $view_policy = $request->getValue('viewPolicy'); 36 37 37 - $user = $request->getUser(); 38 - $data = base64_decode($data, $strict = true); 39 - 40 - if (!$view_policy) { 41 - $view_policy = PhabricatorPolicies::getMostOpenPolicy(); 42 - } 38 + $data = $request->getValue('data_base64'); 39 + $data = $this->decodeBase64($data); 43 40 44 41 $file = PhabricatorFile::newFromFileData( 45 42 $data, 46 43 array( 47 44 'name' => $name, 48 - 'authorPHID' => $user->getPHID(), 45 + 'authorPHID' => $viewer->getPHID(), 49 46 'viewPolicy' => $view_policy, 50 47 'canCDN' => $can_cdn, 51 48 'isExplicitUpload' => true,
+8 -1
src/applications/files/view/PhabricatorGlobalUploadTargetView.php
··· 23 23 24 24 require_celerity_resource('global-drag-and-drop-css'); 25 25 26 + // Use the configured default view policy. Drag and drop uploads use 27 + // a more restrictive view policy if we don't specify a policy explicitly, 28 + // as the more restrictive policy is correct for most drop targets (like 29 + // Pholio uploads and Remarkup text areas). 30 + 31 + $view_policy = PhabricatorFile::initializeNewFile()->getViewPolicy(); 32 + 26 33 Javelin::initBehavior('global-drag-and-drop', array( 27 34 'ifSupported' => $this->showIfSupportedID, 28 35 'instructions' => $instructions_id, 29 36 'uploadURI' => '/file/dropupload/', 30 37 'browseURI' => '/file/query/authored/', 31 - 'viewPolicy' => PhabricatorPolicies::getMostOpenPolicy(), 38 + 'viewPolicy' => $view_policy, 32 39 'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(), 33 40 )); 34 41