mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-29 17:00:59 +01:00
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
This commit is contained in:
parent
ca042df6de
commit
7a93b443c3
3 changed files with 14 additions and 10 deletions
|
@ -45,7 +45,7 @@ final class FileInfoConduitAPIMethod extends FileConduitAPIMethod {
|
||||||
throw new ConduitException('ERR-NOT-FOUND');
|
throw new ConduitException('ERR-NOT-FOUND');
|
||||||
}
|
}
|
||||||
|
|
||||||
$uri = $file->getBestURI();
|
$uri = $file->getInfoURI();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'id' => $file->getID(),
|
'id' => $file->getID(),
|
||||||
|
|
|
@ -29,23 +29,20 @@ final class FileUploadConduitAPIMethod extends FileConduitAPIMethod {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function execute(ConduitAPIRequest $request) {
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
$data = $request->getValue('data_base64');
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
$name = $request->getValue('name');
|
$name = $request->getValue('name');
|
||||||
$can_cdn = $request->getValue('canCDN');
|
$can_cdn = $request->getValue('canCDN');
|
||||||
$view_policy = $request->getValue('viewPolicy');
|
$view_policy = $request->getValue('viewPolicy');
|
||||||
|
|
||||||
$user = $request->getUser();
|
$data = $request->getValue('data_base64');
|
||||||
$data = base64_decode($data, $strict = true);
|
$data = $this->decodeBase64($data);
|
||||||
|
|
||||||
if (!$view_policy) {
|
|
||||||
$view_policy = PhabricatorPolicies::getMostOpenPolicy();
|
|
||||||
}
|
|
||||||
|
|
||||||
$file = PhabricatorFile::newFromFileData(
|
$file = PhabricatorFile::newFromFileData(
|
||||||
$data,
|
$data,
|
||||||
array(
|
array(
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'authorPHID' => $user->getPHID(),
|
'authorPHID' => $viewer->getPHID(),
|
||||||
'viewPolicy' => $view_policy,
|
'viewPolicy' => $view_policy,
|
||||||
'canCDN' => $can_cdn,
|
'canCDN' => $can_cdn,
|
||||||
'isExplicitUpload' => true,
|
'isExplicitUpload' => true,
|
||||||
|
|
|
@ -23,12 +23,19 @@ final class PhabricatorGlobalUploadTargetView extends AphrontView {
|
||||||
|
|
||||||
require_celerity_resource('global-drag-and-drop-css');
|
require_celerity_resource('global-drag-and-drop-css');
|
||||||
|
|
||||||
|
// Use the configured default view policy. Drag and drop uploads use
|
||||||
|
// a more restrictive view policy if we don't specify a policy explicitly,
|
||||||
|
// as the more restrictive policy is correct for most drop targets (like
|
||||||
|
// Pholio uploads and Remarkup text areas).
|
||||||
|
|
||||||
|
$view_policy = PhabricatorFile::initializeNewFile()->getViewPolicy();
|
||||||
|
|
||||||
Javelin::initBehavior('global-drag-and-drop', array(
|
Javelin::initBehavior('global-drag-and-drop', array(
|
||||||
'ifSupported' => $this->showIfSupportedID,
|
'ifSupported' => $this->showIfSupportedID,
|
||||||
'instructions' => $instructions_id,
|
'instructions' => $instructions_id,
|
||||||
'uploadURI' => '/file/dropupload/',
|
'uploadURI' => '/file/dropupload/',
|
||||||
'browseURI' => '/file/query/authored/',
|
'browseURI' => '/file/query/authored/',
|
||||||
'viewPolicy' => PhabricatorPolicies::getMostOpenPolicy(),
|
'viewPolicy' => $view_policy,
|
||||||
'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(),
|
'chunkThreshold' => PhabricatorFileStorageEngine::getChunkThreshold(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue