@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at upstream/main 58 lines 1.8 kB view raw
1<?php 2 3final class PhabricatorNotificationIndividualController 4 extends PhabricatorNotificationController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $request->getViewer(); 8 9 $stories = id(new PhabricatorNotificationQuery()) 10 ->setViewer($viewer) 11 ->withUserPHIDs(array($viewer->getPHID())) 12 ->withKeys(array($request->getStr('key'))) 13 ->execute(); 14 15 if (!$stories) { 16 return $this->buildEmptyResponse(); 17 } 18 19 $story = head($stories); 20 if ($story->getAuthorPHID() === $viewer->getPHID()) { 21 // Don't show the user individual notifications about their own 22 // actions. Primarily, this stops pages from showing notifications 23 // immediately after you click "Submit" on a comment form if the 24 // notification server returns faster than the web server. 25 26 // TODO: It would be nice to retain the "page updated" bubble on copies 27 // of the page that are open in other tabs, but there isn't an obvious 28 // way to do this easily. 29 30 return $this->buildEmptyResponse(); 31 } 32 33 $builder = id(new PhabricatorNotificationBuilder(array($story))) 34 ->setUser($viewer) 35 ->setShowTimestamps(false); 36 37 $content = $builder->buildView()->render(); 38 $dict = $builder->buildDict(); 39 $data = $dict[0]; 40 41 $response = $data + array( 42 'pertinent' => true, 43 'primaryObjectPHID' => $story->getPrimaryObjectPHID(), 44 'content' => hsprintf('%s', $content), 45 'uniqueID' => 'story/'.$story->getChronologicalKey(), 46 ); 47 48 return id(new AphrontAjaxResponse())->setContent($response); 49 } 50 51 private function buildEmptyResponse() { 52 return id(new AphrontAjaxResponse())->setContent( 53 array( 54 'pertinent' => false, 55 )); 56 } 57 58}