Differential D18483 Diff 44402 src/applications/notification/controller/PhabricatorNotificationClearController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/notification/controller/PhabricatorNotificationClearController.php
| <?php | <?php | ||||
| final class PhabricatorNotificationClearController | final class PhabricatorNotificationClearController | ||||
| extends PhabricatorNotificationController { | extends PhabricatorNotificationController { | ||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
| $chrono_key = $request->getStr('chronoKey'); | $chrono_key = $request->getStr('chronoKey'); | ||||
| if ($request->isDialogFormPost()) { | if ($request->isDialogFormPost()) { | ||||
| $should_clear = true; | |||||
| } else { | |||||
| try { | |||||
| $request->validateCSRF(); | |||||
| $should_clear = true; | |||||
| } catch (AphrontMalformedRequestException $ex) { | |||||
| $should_clear = false; | |||||
| } | |||||
| } | |||||
| if ($should_clear) { | |||||
| $table = new PhabricatorFeedStoryNotification(); | $table = new PhabricatorFeedStoryNotification(); | ||||
| queryfx( | queryfx( | ||||
| $table->establishConnection('w'), | $table->establishConnection('w'), | ||||
| 'UPDATE %T SET hasViewed = 1 '. | 'UPDATE %T SET hasViewed = 1 '. | ||||
| 'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s', | 'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| $viewer->getPHID(), | $viewer->getPHID(), | ||||
| Show All 39 Lines | |||||