@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.

Update Subscriptions for handleRequest

Summary: Modernizes Subscriptions

Test Plan: Subscribe/Unsubscribe... anything else?

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T8628

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

+27 -44
+18 -27
src/applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php
··· 3 3 final class PhabricatorSubscriptionsEditController 4 4 extends PhabricatorController { 5 5 6 - private $phid; 7 - private $action; 8 - 9 - public function willProcessRequest(array $data) { 10 - $this->phid = idx($data, 'phid'); 11 - $this->action = idx($data, 'action'); 12 - } 13 - 14 - public function processRequest() { 15 - $request = $this->getRequest(); 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $phid = $request->getURIData('phid'); 9 + $action = $request->getURIData('action'); 16 10 17 11 if (!$request->isFormPost()) { 18 12 return new Aphront400Response(); 19 13 } 20 14 21 - switch ($this->action) { 15 + switch ($action) { 22 16 case 'add': 23 17 $is_add = true; 24 18 break; ··· 29 23 return new Aphront400Response(); 30 24 } 31 25 32 - $user = $request->getUser(); 33 - $phid = $this->phid; 34 - 35 26 $handle = id(new PhabricatorHandleQuery()) 36 - ->setViewer($user) 27 + ->setViewer($viewer) 37 28 ->withPHIDs(array($phid)) 38 29 ->executeOne(); 39 30 ··· 45 36 // to become more clear? 46 37 47 38 $object = id(new PhabricatorProjectQuery()) 48 - ->setViewer($user) 39 + ->setViewer($viewer) 49 40 ->withPHIDs(array($phid)) 50 41 ->needWatchers(true) 51 42 ->executeOne(); 52 43 } else { 53 44 $object = id(new PhabricatorObjectQuery()) 54 - ->setViewer($user) 45 + ->setViewer($viewer) 55 46 ->withPHIDs(array($phid)) 56 47 ->executeOne(); 57 48 } ··· 63 54 $handle->getURI()); 64 55 } 65 56 66 - if ($object->isAutomaticallySubscribed($user->getPHID())) { 57 + if ($object->isAutomaticallySubscribed($viewer->getPHID())) { 67 58 return $this->buildErrorResponse( 68 59 pht('Automatically Subscribed'), 69 60 pht('You are automatically subscribed to this object.'), 70 61 $handle->getURI()); 71 62 } 72 63 73 - if (!$object->shouldAllowSubscription($user->getPHID())) { 64 + if (!$object->shouldAllowSubscription($viewer->getPHID())) { 74 65 return $this->buildErrorResponse( 75 66 pht('You Can Not Subscribe'), 76 67 pht('You can not subscribe to this object.'), ··· 80 71 if ($object instanceof PhabricatorApplicationTransactionInterface) { 81 72 if ($is_add) { 82 73 $xaction_value = array( 83 - '+' => array($user->getPHID()), 74 + '+' => array($viewer->getPHID()), 84 75 ); 85 76 } else { 86 77 $xaction_value = array( 87 - '-' => array($user->getPHID()), 78 + '-' => array($viewer->getPHID()), 88 79 ); 89 80 } 90 81 ··· 93 84 ->setNewValue($xaction_value); 94 85 95 86 $editor = id($object->getApplicationTransactionEditor()) 96 - ->setActor($user) 87 + ->setActor($viewer) 97 88 ->setContinueOnNoEffect(true) 98 89 ->setContinueOnMissingFields(true) 99 90 ->setContentSourceFromRequest($request); ··· 107 98 // PhabriatorApplicationTransactionInterface. 108 99 109 100 $editor = id(new PhabricatorSubscriptionsEditor()) 110 - ->setActor($user) 101 + ->setActor($viewer) 111 102 ->setObject($object); 112 103 113 104 if ($is_add) { 114 - $editor->subscribeExplicit(array($user->getPHID()), $explicit = true); 105 + $editor->subscribeExplicit(array($viewer->getPHID()), $explicit = true); 115 106 } else { 116 - $editor->unsubscribe(array($user->getPHID())); 107 + $editor->unsubscribe(array($viewer->getPHID())); 117 108 } 118 109 119 110 $editor->save(); ··· 126 117 127 118 private function buildErrorResponse($title, $message, $uri) { 128 119 $request = $this->getRequest(); 129 - $user = $request->getUser(); 120 + $viewer = $request->getUser(); 130 121 131 122 $dialog = id(new AphrontDialogView()) 132 - ->setUser($user) 123 + ->setUser($viewer) 133 124 ->setTitle($title) 134 125 ->appendChild($message) 135 126 ->addCancelButton($uri);
+2 -1
src/applications/subscriptions/controller/PhabricatorSubscriptionsListController.php
··· 8 8 } 9 9 10 10 public function handleRequest(AphrontRequest $request) { 11 - $viewer = $request->getUser(); 11 + $viewer = $request->getViewer(); 12 + 12 13 $object = id(new PhabricatorObjectQuery()) 13 14 ->setViewer($viewer) 14 15 ->withPHIDs(array($request->getURIData('phid')))
+7 -16
src/applications/subscriptions/controller/PhabricatorSubscriptionsTransactionController.php
··· 3 3 final class PhabricatorSubscriptionsTransactionController 4 4 extends PhabricatorController { 5 5 6 - private $phid; 7 - private $changeType; 8 - 9 - public function willProcessRequest(array $data) { 10 - $this->phid = idx($data, 'phid'); 11 - $this->changeType = idx($data, 'type'); 12 - } 13 - 14 - public function processRequest() { 15 - $request = $this->getRequest(); 16 - 17 - $viewer = $request->getUser(); 18 - $xaction_phid = $this->phid; 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $phid = $request->getURIData('phid'); 9 + $type = $request->getURIData('type'); 19 10 20 11 $xaction = id(new PhabricatorObjectQuery()) 21 - ->withPHIDs(array($xaction_phid)) 12 + ->withPHIDs(array($phid)) 22 13 ->setViewer($viewer) 23 14 ->executeOne(); 24 15 if (!$xaction) { ··· 27 18 28 19 $old = $xaction->getOldValue(); 29 20 $new = $xaction->getNewValue(); 30 - switch ($this->changeType) { 21 + switch ($type) { 31 22 case 'add': 32 23 $subscriber_phids = array_diff($new, $old); 33 24 break; ··· 53 44 unset($handles[$author_phid]); 54 45 } 55 46 56 - switch ($this->changeType) { 47 + switch ($type) { 57 48 case 'add': 58 49 $title = pht( 59 50 'All %d subscribers added by %s',