mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-11 07:11:04 +01:00
Don't claim logged out users are automatically subscribed to un-owned objects
Summary: The PHID for logged out users is NULL, but so is the PHID for un-owned objects. Test Plan: Browse a non-owned object (i.e. unassigned task) while logged out, notice "Automatically subscribed" before this commit. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D12788
This commit is contained in:
parent
e074be0d3f
commit
a03a488ba6
1 changed files with 5 additions and 5 deletions
|
@ -21,6 +21,7 @@ final class PhabricatorSubscriptionsUIEventListener
|
||||||
|
|
||||||
private function handleActionEvent($event) {
|
private function handleActionEvent($event) {
|
||||||
$user = $event->getUser();
|
$user = $event->getUser();
|
||||||
|
$user_phid = $user->getPHID();
|
||||||
$object = $event->getValue('object');
|
$object = $event->getValue('object');
|
||||||
|
|
||||||
if (!$object || !$object->getPHID()) {
|
if (!$object || !$object->getPHID()) {
|
||||||
|
@ -33,12 +34,12 @@ final class PhabricatorSubscriptionsUIEventListener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$object->shouldAllowSubscription($user->getPHID())) {
|
if (!$object->shouldAllowSubscription($user_phid)) {
|
||||||
// This object doesn't allow the viewer to subscribe.
|
// This object doesn't allow the viewer to subscribe.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($object->isAutomaticallySubscribed($user->getPHID())) {
|
if ($user_phid && $object->isAutomaticallySubscribed($user_phid)) {
|
||||||
$sub_action = id(new PhabricatorActionView())
|
$sub_action = id(new PhabricatorActionView())
|
||||||
->setWorkflow(true)
|
->setWorkflow(true)
|
||||||
->setDisabled(true)
|
->setDisabled(true)
|
||||||
|
@ -50,15 +51,14 @@ final class PhabricatorSubscriptionsUIEventListener
|
||||||
$subscribed = false;
|
$subscribed = false;
|
||||||
if ($user->isLoggedIn()) {
|
if ($user->isLoggedIn()) {
|
||||||
$src_phid = $object->getPHID();
|
$src_phid = $object->getPHID();
|
||||||
$dst_phid = $user->getPHID();
|
|
||||||
$edge_type = PhabricatorObjectHasSubscriberEdgeType::EDGECONST;
|
$edge_type = PhabricatorObjectHasSubscriberEdgeType::EDGECONST;
|
||||||
|
|
||||||
$edges = id(new PhabricatorEdgeQuery())
|
$edges = id(new PhabricatorEdgeQuery())
|
||||||
->withSourcePHIDs(array($src_phid))
|
->withSourcePHIDs(array($src_phid))
|
||||||
->withEdgeTypes(array($edge_type))
|
->withEdgeTypes(array($edge_type))
|
||||||
->withDestinationPHIDs(array($user->getPHID()))
|
->withDestinationPHIDs(array($user_phid))
|
||||||
->execute();
|
->execute();
|
||||||
$subscribed = isset($edges[$src_phid][$edge_type][$dst_phid]);
|
$subscribed = isset($edges[$src_phid][$edge_type][$user_phid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subscribed) {
|
if ($subscribed) {
|
||||||
|
|
Loading…
Reference in a new issue