@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 42 lines 1.1 kB view raw
1<?php 2 3final class PhabricatorRateLimitRequestExceptionHandler 4 extends PhabricatorRequestExceptionHandler { 5 6 public function getRequestExceptionHandlerPriority() { 7 return 300000; 8 } 9 10 public function getRequestExceptionHandlerDescription() { 11 return pht( 12 'Handles action rate limiting exceptions which occur when a user '. 13 'does something too frequently.'); 14 } 15 16 public function canHandleRequestThrowable( 17 AphrontRequest $request, 18 $throwable) { 19 20 if (!$this->isPhabricatorSite($request)) { 21 return false; 22 } 23 24 return ($throwable instanceof PhabricatorSystemActionRateLimitException); 25 } 26 27 public function handleRequestThrowable( 28 AphrontRequest $request, 29 $throwable) { 30 31 $viewer = $this->getViewer($request); 32 33 return id(new AphrontDialogView()) 34 ->setTitle(pht('Slow Down!')) 35 ->setUser($viewer) 36 ->setErrors(array(pht('You are being rate limited.'))) 37 ->appendParagraph($throwable->getMessage()) 38 ->appendParagraph($throwable->getRateExplanation()) 39 ->addCancelButton('/', pht('Okaaaaaaaaaaaaaay...')); 40 } 41 42}