mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Don't show notifications about your own actions
Summary: Ref T6559. See discussion in D11143. At least locally, WebSockets are too fast and create immediate local notifications on page submit. To mitigate this, don't notify about your own actions. This isn't perfect (we get the other-copies-of-the-window-open-in-other-tabs case wrong) but I think the case we get wrong is rare / not very important. Test Plan: Submitted stuff, saw other users get notifications but not me. Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T6559 Differential Revision: https://secure.phabricator.com/D11275
This commit is contained in:
parent
c0e15f2c65
commit
6a7469e1aa
1 changed files with 28 additions and 9 deletions
|
@ -5,30 +5,49 @@ final class PhabricatorNotificationIndividualController
|
|||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$stories = id(new PhabricatorNotificationQuery())
|
||||
->setViewer($user)
|
||||
->withUserPHIDs(array($user->getPHID()))
|
||||
->setViewer($viewer)
|
||||
->withUserPHIDs(array($viewer->getPHID()))
|
||||
->withKeys(array($request->getStr('key')))
|
||||
->execute();
|
||||
|
||||
if (!$stories) {
|
||||
return id(new AphrontAjaxResponse())->setContent(
|
||||
array(
|
||||
'pertinent' => false,
|
||||
));
|
||||
return $this->buildEmptyResponse();
|
||||
}
|
||||
|
||||
$builder = new PhabricatorNotificationBuilder($stories);
|
||||
$story = head($stories);
|
||||
if ($story->getAuthorPHID() === $viewer->getPHID()) {
|
||||
// Don't show the user individual notifications about their own
|
||||
// actions. Primarily, this stops pages from showing notifications
|
||||
// immediately after you click "Submit" on a comment form if the
|
||||
// notification server returns faster than the web server.
|
||||
|
||||
// TODO: It would be nice to retain the "page updated" bubble on copies
|
||||
// of the page that are open in other tabs, but there isn't an obvious
|
||||
// way to do this easily.
|
||||
|
||||
return $this->buildEmptyResponse();
|
||||
}
|
||||
|
||||
$builder = new PhabricatorNotificationBuilder(array($story));
|
||||
$content = $builder->buildView()->render();
|
||||
|
||||
$response = array(
|
||||
'pertinent' => true,
|
||||
'primaryObjectPHID' => head($stories)->getPrimaryObjectPHID(),
|
||||
'primaryObjectPHID' => $story->getPrimaryObjectPHID(),
|
||||
'content' => hsprintf('%s', $content),
|
||||
);
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent($response);
|
||||
}
|
||||
|
||||
private function buildEmptyResponse() {
|
||||
return id(new AphrontAjaxResponse())->setContent(
|
||||
array(
|
||||
'pertinent' => false,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue