mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Cover redirects to files in more cases
Summary: Ref T5894. We have a couple more similar cases. Make them all do a decision-based redirect for now. Test Plan: Did "View Raw File" and such, and also made sure thumbnails still work. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T5894 Differential Revision: https://secure.phabricator.com/D10301
This commit is contained in:
parent
eacfb5b489
commit
94cdddc211
7 changed files with 25 additions and 20 deletions
|
@ -4381,6 +4381,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSubscribableInterface',
|
||||
'PhabricatorFlaggableInterface',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
),
|
||||
'PhabricatorFileCommentController' => 'PhabricatorFileController',
|
||||
'PhabricatorFileComposeController' => 'PhabricatorFileController',
|
||||
|
|
|
@ -347,8 +347,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
|
|||
unset($unguard);
|
||||
}
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($file->getBestURI());
|
||||
return $file->getRedirectResponse();
|
||||
}
|
||||
|
||||
private function buildLintInlineComments($changeset) {
|
||||
|
|
|
@ -918,7 +918,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
|||
$revision->getPHID());
|
||||
unset($unguarded);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
|
||||
return $file->getRedirectResponse();
|
||||
}
|
||||
|
||||
private function buildTransactions(
|
||||
|
|
|
@ -887,7 +887,7 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
|
|||
|
||||
private function buildRawResponse($path, $data) {
|
||||
$file = $this->loadFileForData($path, $data);
|
||||
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
|
||||
return $file->getRedirectResponse();
|
||||
}
|
||||
|
||||
private function buildImageCorpus($file_uri) {
|
||||
|
|
|
@ -1042,7 +1042,7 @@ final class DiffusionCommitController extends DiffusionController {
|
|||
$drequest->getRepository()->getPHID());
|
||||
unset($unguarded);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($file->getBestURI());
|
||||
return $file->getRedirectResponse();
|
||||
}
|
||||
|
||||
private function renderAuditStatusView(array $audit_requests) {
|
||||
|
|
|
@ -148,22 +148,8 @@ final class PhabricatorFileTransformController
|
|||
|
||||
// TODO: We could just delegate to the file view controller instead,
|
||||
// which would save the client a roundtrip, but is slightly more complex.
|
||||
$uri = $file->getBestURI();
|
||||
|
||||
// TODO: This is a bit iffy. Sometimes, getBestURI() returns a CDN URI
|
||||
// (if the file is a viewable image) and sometimes a local URI (if not).
|
||||
// For now, just detect which one we got and configure the response
|
||||
// appropriately. In the long run, if this endpoint is served from a CDN
|
||||
// domain, we can't issue a local redirect to an info URI (which is not
|
||||
// present on the CDN domain). We probably never actually issue local
|
||||
// redirects here anyway, since we only ever transform viewable images
|
||||
// right now.
|
||||
|
||||
$is_external = strlen(id(new PhutilURI($uri))->getDomain());
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setIsExternal($is_external)
|
||||
->setURI($uri);
|
||||
return $file->getRedirectResponse();
|
||||
}
|
||||
|
||||
private function executePreviewTransform(PhabricatorFile $file, $size) {
|
||||
|
|
|
@ -967,6 +967,25 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getRedirectResponse() {
|
||||
$uri = $this->getBestURI();
|
||||
|
||||
// TODO: This is a bit iffy. Sometimes, getBestURI() returns a CDN URI
|
||||
// (if the file is a viewable image) and sometimes a local URI (if not).
|
||||
// For now, just detect which one we got and configure the response
|
||||
// appropriately. In the long run, if this endpoint is served from a CDN
|
||||
// domain, we can't issue a local redirect to an info URI (which is not
|
||||
// present on the CDN domain). We probably never actually issue local
|
||||
// redirects here anyway, since we only ever transform viewable images
|
||||
// right now.
|
||||
|
||||
$is_external = strlen(id(new PhutilURI($uri))->getDomain());
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setIsExternal($is_external)
|
||||
->setURI($uri);
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue