Path: blob/master/src/applications/notification/controller/PhabricatorNotificationIndividualController.php
12256 views
<?php12final class PhabricatorNotificationIndividualController3extends PhabricatorNotificationController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();78$stories = id(new PhabricatorNotificationQuery())9->setViewer($viewer)10->withUserPHIDs(array($viewer->getPHID()))11->withKeys(array($request->getStr('key')))12->execute();1314if (!$stories) {15return $this->buildEmptyResponse();16}1718$story = head($stories);19if ($story->getAuthorPHID() === $viewer->getPHID()) {20// Don't show the user individual notifications about their own21// actions. Primarily, this stops pages from showing notifications22// immediately after you click "Submit" on a comment form if the23// notification server returns faster than the web server.2425// TODO: It would be nice to retain the "page updated" bubble on copies26// of the page that are open in other tabs, but there isn't an obvious27// way to do this easily.2829return $this->buildEmptyResponse();30}3132$builder = id(new PhabricatorNotificationBuilder(array($story)))33->setUser($viewer)34->setShowTimestamps(false);3536$content = $builder->buildView()->render();37$dict = $builder->buildDict();38$data = $dict[0];3940$response = $data + array(41'pertinent' => true,42'primaryObjectPHID' => $story->getPrimaryObjectPHID(),43'content' => hsprintf('%s', $content),44'uniqueID' => 'story/'.$story->getChronologicalKey(),45);4647return id(new AphrontAjaxResponse())->setContent($response);48}4950private function buildEmptyResponse() {51return id(new AphrontAjaxResponse())->setContent(52array(53'pertinent' => false,54));55}5657}585960