1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Transactions - hide "mentioned in X" story if you can't see X

Summary: ...also re-jiggers all the anchor stuff to use $xaction ID. This seemed like the simplest way once I got in the code, as well as having nice properties for if / when we want to re-add some ajax stuff since the ID is a pretty solid piece of data to key off. Fixes T6083.

Test Plan: mentioned DX in private DX+1. Could see on DX the mention as me and not as the other user. For transactions, I left a comment on Paste and it worked, and I edited an existing transaction and it worked.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T6083

Differential Revision: https://secure.phabricator.com/D10488
This commit is contained in:
Bob Trahan 2014-09-16 12:12:35 -07:00
parent 936ee22de1
commit 444ced16d9
12 changed files with 20 additions and 45 deletions

View file

@ -58,8 +58,7 @@ final class PhabricatorFileCommentController extends PhabricatorFileController {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user) ->setViewer($user)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($view_uri); ->setURI($view_uri);

View file

@ -69,8 +69,7 @@ final class LegalpadDocumentCommentController extends LegalpadController {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user) ->setViewer($user)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse())->setURI($document_uri); return id(new AphrontRedirectResponse())->setURI($document_uri);
} }

View file

@ -59,8 +59,7 @@ final class PhabricatorMacroCommentController
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user) ->setViewer($user)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($view_uri); ->setURI($view_uri);

View file

@ -59,8 +59,7 @@ final class PhabricatorPasteCommentController
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user) ->setViewer($user)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($view_uri); ->setURI($view_uri);

View file

@ -81,8 +81,7 @@ final class PholioMockCommentController extends PholioController {
->setViewer($user) ->setViewer($user)
->setTransactions($xactions) ->setTransactions($xactions)
->setTransactionView($xaction_view) ->setTransactionView($xaction_view)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse())->setURI($mock_uri); return id(new AphrontRedirectResponse())->setURI($mock_uri);
} }

View file

@ -60,8 +60,7 @@ final class PonderAnswerCommentController extends PonderController {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($view_uri); ->setURI($view_uri);

View file

@ -59,8 +59,7 @@ final class PonderQuestionCommentController extends PonderController {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($view_uri); ->setURI($view_uri);

View file

@ -59,8 +59,7 @@ final class ReleephRequestCommentController
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($view_uri); ->setURI($view_uri);

View file

@ -59,8 +59,7 @@ final class PhabricatorSlowvoteCommentController
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setViewer($user) ->setViewer($user)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview);
->setAnchorOffset($request->getStr('anchor'));
} else { } else {
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($view_uri); ->setURI($view_uri);

View file

@ -5,7 +5,6 @@ final class PhabricatorApplicationTransactionResponse
private $viewer; private $viewer;
private $transactions; private $transactions;
private $anchorOffset;
private $isPreview; private $isPreview;
private $transactionView; private $transactionView;
@ -22,15 +21,6 @@ final class PhabricatorApplicationTransactionResponse
return new AphrontAjaxResponse(); return new AphrontAjaxResponse();
} }
public function setAnchorOffset($anchor_offset) {
$this->anchorOffset = $anchor_offset;
return $this;
}
public function getAnchorOffset() {
return $this->anchorOffset;
}
public function setTransactions($transactions) { public function setTransactions($transactions) {
assert_instances_of($transactions, 'PhabricatorApplicationTransaction'); assert_instances_of($transactions, 'PhabricatorApplicationTransaction');
@ -71,10 +61,6 @@ final class PhabricatorApplicationTransactionResponse
->setTransactions($this->getTransactions()) ->setTransactions($this->getTransactions())
->setIsPreview($this->isPreview); ->setIsPreview($this->isPreview);
if ($this->getAnchorOffset()) {
$view->setAnchorOffset($this->getAnchorOffset());
}
if ($this->isPreview) { if ($this->isPreview) {
$xactions = mpull($view->buildEvents(), 'render'); $xactions = mpull($view->buildEvents(), 'render');
} else { } else {

View file

@ -445,6 +445,14 @@ abstract class PhabricatorApplicationTransaction
return true; return true;
break; break;
case PhabricatorObjectMentionedByObject::EDGECONST: case PhabricatorObjectMentionedByObject::EDGECONST:
$new = ipull($this->getNewValue(), 'dst');
$old = ipull($this->getOldValue(), 'dst');
$add = array_diff($new, $old);
$add_value = reset($add);
$add_handle = $this->getHandle($add_value);
if ($add_handle->getPolicyFiltered()) {
return true;
}
return false; return false;
break; break;
default: default:

View file

@ -7,7 +7,6 @@ class PhabricatorApplicationTransactionView extends AphrontView {
private $transactions; private $transactions;
private $engine; private $engine;
private $anchorOffset = 1;
private $showEditActions = true; private $showEditActions = true;
private $isPreview; private $isPreview;
private $objectPHID; private $objectPHID;
@ -56,11 +55,6 @@ class PhabricatorApplicationTransactionView extends AphrontView {
return $this->showEditActions; return $this->showEditActions;
} }
public function setAnchorOffset($anchor_offset) {
$this->anchorOffset = $anchor_offset;
return $this;
}
public function setMarkupEngine(PhabricatorMarkupEngine $engine) { public function setMarkupEngine(PhabricatorMarkupEngine $engine) {
$this->engine = $engine; $this->engine = $engine;
return $this; return $this;
@ -80,8 +74,6 @@ class PhabricatorApplicationTransactionView extends AphrontView {
public function buildEvents($with_hiding = false) { public function buildEvents($with_hiding = false) {
$user = $this->getUser(); $user = $this->getUser();
$anchor = $this->anchorOffset;
$xactions = $this->transactions; $xactions = $this->transactions;
$xactions = $this->filterHiddenTransactions($xactions); $xactions = $this->filterHiddenTransactions($xactions);
@ -130,9 +122,8 @@ class PhabricatorApplicationTransactionView extends AphrontView {
$group_event = null; $group_event = null;
foreach ($group as $xaction) { foreach ($group as $xaction) {
$event = $this->renderEvent($xaction, $group, $anchor); $event = $this->renderEvent($xaction, $group);
$event->setHideByDefault($hide_by_default); $event->setHideByDefault($hide_by_default);
$anchor++;
if (!$group_event) { if (!$group_event) {
$group_event = $event; $group_event = $event;
} else { } else {
@ -325,8 +316,7 @@ class PhabricatorApplicationTransactionView extends AphrontView {
private function renderEvent( private function renderEvent(
PhabricatorApplicationTransaction $xaction, PhabricatorApplicationTransaction $xaction,
array $group, array $group) {
$anchor) {
$viewer = $this->getUser(); $viewer = $this->getUser();
$event = id(new PHUITimelineEventView()) $event = id(new PHUITimelineEventView())
@ -370,7 +360,7 @@ class PhabricatorApplicationTransactionView extends AphrontView {
$event $event
->setDateCreated($xaction->getDateCreated()) ->setDateCreated($xaction->getDateCreated())
->setContentSource($xaction->getContentSource()) ->setContentSource($xaction->getContentSource())
->setAnchor($anchor); ->setAnchor($xaction->getID());
} }
$transaction_type = $xaction->getTransactionType(); $transaction_type = $xaction->getTransactionType();