Skip to content

Commit 97cd7a9

Browse files
author
epriestley
committedNov 18, 2016
Strip restricted and incomplete handles from the "Mentions" tab on Maniphest tasks
Summary: Ref T8345. See T8345#201048 for discussion. This rule (don't show mentions of or from restricted objects) is more consistent with how we render mentions in the timeline and I think generally a better behavior. Test Plan: - Mentioned a task on a public task and a private task. - Privileged user (foreground) sees both. - Public user (background) sees only the public mention. {F1929485} Reviewers: chad Reviewed By: chad Maniphest Tasks: T8345 Differential Revision: https://secure.phabricator.com/D16900
1 parent 8aeb7aa commit 97cd7a9

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed
 

‎src/applications/maniphest/controller/ManiphestTaskDetailController.php

+26-4
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,23 @@ private function newMentionsTab(
510510
}
511511

512512
$viewer = $this->getViewer();
513+
$in_handles = $viewer->loadHandles($in_phids);
514+
$out_handles = $viewer->loadHandles($out_phids);
515+
516+
$in_handles = $this->getCompleteHandles($in_handles);
517+
$out_handles = $this->getCompleteHandles($out_handles);
518+
519+
if (!count($in_handles) && !count($out_handles)) {
520+
return null;
521+
}
522+
513523
$view = new PHUIPropertyListView();
514524

515-
if ($in_phids) {
516-
$in_handles = $viewer->loadHandles($in_phids);
525+
if (count($in_handles)) {
517526
$view->addProperty(pht('Mentioned In'), $in_handles->renderList());
518527
}
519528

520-
if ($out_phids) {
521-
$out_handles = $viewer->loadHandles($out_phids);
529+
if (count($out_handles)) {
522530
$view->addProperty(pht('Mentioned Here'), $out_handles->renderList());
523531
}
524532

@@ -528,4 +536,18 @@ private function newMentionsTab(
528536
->appendChild($view);
529537
}
530538

539+
private function getCompleteHandles(PhabricatorHandleList $handles) {
540+
$phids = array();
541+
542+
foreach ($handles as $phid => $handle) {
543+
if (!$handle->isComplete()) {
544+
continue;
545+
}
546+
$phids[] = $phid;
547+
}
548+
549+
return $handles->newSublist($phids);
550+
}
551+
552+
531553
}

‎src/applications/phid/handle/pool/PhabricatorHandleList.php

+18
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,24 @@ public function getHandleIfExists($phid, $default = null) {
7474
}
7575

7676

77+
/**
78+
* Create a new list with a subset of the PHIDs in this list.
79+
*/
80+
public function newSublist(array $phids) {
81+
foreach ($phids as $phid) {
82+
if (!isset($this[$phid])) {
83+
throw new Exception(
84+
pht(
85+
'Trying to create a new sublist of an existsing handle list, '.
86+
'but PHID "%s" does not appear in the parent list.',
87+
$phid));
88+
}
89+
}
90+
91+
return $this->handlePool->newHandleList($phids);
92+
}
93+
94+
7795
/* -( Rendering )---------------------------------------------------------- */
7896

7997

0 commit comments

Comments
 (0)
Failed to load comments.