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

Integrate subscriptions with ApplicationTransactions

Summary: Fixes T2214. For objects which support ApplicationTransaction, use ApplicationTransactions to apply subscription action changes. Principally, this makes clicking "Subscribe" / "Unsubscribe" appear correctly in the transaction log.

Test Plan: Clicked "Subscribe" and "Unsubscribe" a on Macros and Mocks.

Reviewers: chad

Reviewed By: chad

CC: aran

Maniphest Tasks: T2214

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

+90 -13
+2
src/__phutil_library_map__.php
··· 680 680 'PhabricatorApplicationTransactionController' => 'applications/transactions/controller/PhabricatorApplicationTransactionController.php', 681 681 'PhabricatorApplicationTransactionEditor' => 'applications/transactions/editor/PhabricatorApplicationTransactionEditor.php', 682 682 'PhabricatorApplicationTransactionFeedStory' => 'applications/transactions/feed/PhabricatorApplicationTransactionFeedStory.php', 683 + 'PhabricatorApplicationTransactionInterface' => 'applications/transactions/interface/PhabricatorApplicationTransactionInterface.php', 683 684 'PhabricatorApplicationTransactionNoEffectException' => 'applications/transactions/exception/PhabricatorApplicationTransactionNoEffectException.php', 684 685 'PhabricatorApplicationTransactionNoEffectResponse' => 'applications/transactions/response/PhabricatorApplicationTransactionNoEffectResponse.php', 685 686 'PhabricatorApplicationTransactionQuery' => 'applications/transactions/query/PhabricatorApplicationTransactionQuery.php', ··· 2390 2391 array( 2391 2392 0 => 'PhabricatorFileDAO', 2392 2393 1 => 'PhabricatorSubscribableInterface', 2394 + 2 => 'PhabricatorApplicationTransactionInterface', 2393 2395 ), 2394 2396 'PhabricatorFileInfoController' => 'PhabricatorFileController', 2395 2397 'PhabricatorFileLinkListView' => 'AphrontView',
+11 -1
src/applications/macro/storage/PhabricatorFileImageMacro.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorFileImageMacro extends PhabricatorFileDAO 4 - implements PhabricatorSubscribableInterface { 4 + implements 5 + PhabricatorSubscribableInterface, 6 + PhabricatorApplicationTransactionInterface { 5 7 6 8 protected $filePHID; 7 9 protected $phid; ··· 21 23 22 24 public function isAutomaticallySubscribed($phid) { 23 25 return false; 26 + } 27 + 28 + public function getApplicationTransactionEditor() { 29 + return new PhabricatorMacroEditor(); 30 + } 31 + 32 + public function getApplicationTransactionObject() { 33 + return new PhabricatorMacroTransaction(); 24 34 } 25 35 26 36 }
+15 -1
src/applications/pholio/storage/PholioMock.php
··· 8 8 PhabricatorMarkupInterface, 9 9 PhabricatorPolicyInterface, 10 10 PhabricatorSubscribableInterface, 11 - PhabricatorTokenReceiverInterface { 11 + PhabricatorTokenReceiverInterface, 12 + PhabricatorApplicationTransactionInterface { 12 13 13 14 const MARKUP_FIELD_DESCRIPTION = 'markup:description'; 14 15 ··· 122 123 public function shouldUseMarkupCache($field) { 123 124 return (bool)$this->getID(); 124 125 } 126 + 127 + 128 + /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 129 + 130 + 131 + public function getApplicationTransactionEditor() { 132 + return new PholioMockEditor(); 133 + } 134 + 135 + public function getApplicationTransactionObject() { 136 + return new PholioTransaction(); 137 + } 138 + 125 139 126 140 }
+40 -8
src/applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php
··· 58 58 $handle->getURI()); 59 59 } 60 60 61 - $editor = id(new PhabricatorSubscriptionsEditor()) 62 - ->setActor($user) 63 - ->setObject($object); 61 + if ($object instanceof PhabricatorApplicationTransactionInterface) { 62 + if ($is_add) { 63 + $xaction_value = array( 64 + '+' => array($user->getPHID()), 65 + ); 66 + } else { 67 + $xaction_value = array( 68 + '-' => array($user->getPHID()), 69 + ); 70 + } 64 71 65 - if ($is_add) { 66 - $editor->subscribeExplicit(array($user->getPHID()), $explicit = true); 72 + $xaction = id($object->getApplicationTransactionObject()) 73 + ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) 74 + ->setNewValue($xaction_value); 75 + 76 + $editor = id($object->getApplicationTransactionEditor()) 77 + ->setActor($user) 78 + ->setContinueOnNoEffect(true) 79 + ->setContentSource( 80 + PhabricatorContentSource::newForSource( 81 + PhabricatorContentSource::SOURCE_WEB, 82 + array( 83 + 'ip' => $request->getRemoteAddr(), 84 + ))); 85 + 86 + $editor->applyTransactions($object, array($xaction)); 67 87 } else { 68 - $editor->unsubscribe(array($user->getPHID())); 69 - } 70 88 71 - $editor->save(); 89 + // TODO: Eventually, get rid of this once everything implements 90 + // PhabriatorApplicationTransactionInterface. 91 + 92 + $editor = id(new PhabricatorSubscriptionsEditor()) 93 + ->setActor($user) 94 + ->setObject($object); 95 + 96 + if ($is_add) { 97 + $editor->subscribeExplicit(array($user->getPHID()), $explicit = true); 98 + } else { 99 + $editor->unsubscribe(array($user->getPHID())); 100 + } 101 + 102 + $editor->save(); 103 + } 72 104 73 105 // TODO: We should just render the "Unsubscribe" action and swap it out 74 106 // in the document for Ajax requests.
+14 -3
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 170 170 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 171 171 $subeditor = id(new PhabricatorSubscriptionsEditor()) 172 172 ->setObject($object) 173 - ->setActor($this->requireActor()) 174 - ->subscribeExplicit($xaction->getNewValue()) 175 - ->save(); 173 + ->setActor($this->requireActor()); 174 + 175 + $old_map = array_fuse($xaction->getOldValue()); 176 + $new_map = array_fuse($xaction->getNewValue()); 177 + 178 + $subeditor->unsubscribe( 179 + array_keys( 180 + array_diff_key($old_map, $new_map))); 181 + 182 + $subeditor->subscribeExplicit( 183 + array_keys( 184 + array_diff_key($new_map, $old_map))); 185 + 186 + $subeditor->save(); 176 187 break; 177 188 } 178 189 return $this->applyCustomExternalTransaction($object, $xaction);
+8
src/applications/transactions/interface/PhabricatorApplicationTransactionInterface.php
··· 1 + <?php 2 + 3 + interface PhabricatorApplicationTransactionInterface { 4 + 5 + public function getApplicationTransactionEditor(); 6 + public function getApplicationTransactionObject(); 7 + 8 + }