@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<?php
2
3/**
4 * Redirect to the current raw contents of a Paste.
5 *
6 * This controller provides a stable URI for getting the current contents of
7 * a paste, and slightly simplifies the view controller.
8 */
9final class PhabricatorPasteRawController
10 extends PhabricatorPasteController {
11
12 public function shouldAllowPublic() {
13 return true;
14 }
15
16 public function handleRequest(AphrontRequest $request) {
17 $viewer = $request->getViewer();
18 $id = $request->getURIData('id');
19
20 $paste = id(new PhabricatorPasteQuery())
21 ->setViewer($viewer)
22 ->withIDs(array($id))
23 ->executeOne();
24 if (!$paste) {
25 return new Aphront404Response();
26 }
27
28 $file = id(new PhabricatorFileQuery())
29 ->setViewer($viewer)
30 ->withPHIDs(array($paste->getFilePHID()))
31 ->executeOne();
32 if (!$file) {
33 return new Aphront400Response();
34 }
35
36 return $file->getRedirectResponse();
37 }
38
39}