@@ -238,15 +238,19 @@ private function toExternalFolderId(int $internal): int {
238238 */
239239 public function getSingleBookmark ($ id ): JSONResponse {
240240 if (!Authorizer::hasPermission (Authorizer::PERM_READ , $ this ->authorizer ->getPermissionsForBookmark ((int )$ id , $ this ->request ))) {
241- return new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_NOT_FOUND );
241+ $ res = new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_NOT_FOUND );
242+ $ res ->throttle ();
243+ return $ res ;
242244 }
243245 try {
244246 /**
245247 * @var Bookmark $bm
246248 */
247249 $ bm = $ this ->bookmarkMapper ->find ((int )$ id );
248250 } catch (DoesNotExistException $ e ) {
249- return new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_NOT_FOUND );
251+ $ res = new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_NOT_FOUND );
252+ $ res ->throttle ();
253+ return $ res ;
250254 } catch (MultipleObjectsReturnedException $ e ) {
251255 return new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_NOT_FOUND );
252256 }
@@ -370,7 +374,9 @@ public function getBookmarks(
370374
371375 if ($ folder !== null ) {
372376 if (!Authorizer::hasPermission (Authorizer::PERM_READ , $ this ->authorizer ->getPermissionsForFolder ($ folder , $ this ->request ))) {
373- return new DataResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_BAD_REQUEST );
377+ $ res = new DataResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_BAD_REQUEST );
378+ $ res ->throttle ();
379+ return $ res ;
374380 }
375381 try {
376382 /** @var Folder $folderEntity */
@@ -380,7 +386,9 @@ public function getBookmarks(
380386 // to theirs
381387 $ userId = $ folderEntity ->getUserId ();
382388 } catch (DoesNotExistException |MultipleObjectsReturnedException $ e ) {
383- return new DataResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_BAD_REQUEST );
389+ $ res = new DataResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_BAD_REQUEST );
390+ $ res ->throttle ();
391+ return $ res ;
384392 }
385393 $ params ->setFolder ($ this ->toInternalFolderId ($ folder ));
386394 $ params ->setRecursive ($ recursive );
@@ -431,7 +439,9 @@ public function newBookmark($url = '', $title = null, $description = null, $tags
431439 $ permissions &= $ this ->authorizer ->getPermissionsForFolder ($ folder , $ this ->request );
432440 }
433441 if (!Authorizer::hasPermission (Authorizer::PERM_WRITE , $ permissions ) || $ this ->authorizer ->getUserId () === null ) {
434- return new JSONResponse (['status ' => 'error ' , 'data ' => ['Could not add bookmark ' ]], Http::STATUS_BAD_REQUEST );
442+ $ res = new JSONResponse (['status ' => 'error ' , 'data ' => ['Could not add bookmark ' ]], Http::STATUS_BAD_REQUEST );
443+ $ res ->throttle ();
444+ return $ res ;
435445 }
436446
437447 try {
@@ -474,7 +484,9 @@ public function newBookmark($url = '', $title = null, $description = null, $tags
474484 */
475485 public function editBookmark ($ id = null , $ url = null , $ title = null , $ description = null , $ tags = null , $ folders = null , $ target = null ): JSONResponse {
476486 if (!Authorizer::hasPermission (Authorizer::PERM_EDIT , $ this ->authorizer ->getPermissionsForBookmark ($ id , $ this ->request ))) {
477- return new JSONResponse (['status ' => 'error ' , 'data ' => ['Could not edit bookmark ' ]], Http::STATUS_NOT_FOUND );
487+ $ res = new JSONResponse (['status ' => 'error ' , 'data ' => ['Could not edit bookmark ' ]], Http::STATUS_NOT_FOUND );
488+ $ res ->throttle ();
489+ return $ res ;
478490 }
479491
480492 try {
@@ -522,13 +534,17 @@ public function editBookmark($id = null, $url = null, $title = null, $descriptio
522534 */
523535 public function deleteBookmark ($ id ): JSONResponse {
524536 if (!Authorizer::hasPermission (Authorizer::PERM_EDIT , $ this ->authorizer ->getPermissionsForBookmark ($ id , $ this ->request ))) {
525- return new JSONResponse (['status ' => 'success ' ]);
537+ $ res = new JSONResponse (['status ' => 'success ' ]);
538+ $ res ->throttle ();
539+ return $ res ;
526540 }
527541
528542 try {
529543 $ this ->bookmarkMapper ->find ($ id );
530544 } catch (DoesNotExistException |MultipleObjectsReturnedException ) {
531- return new JSONResponse (['status ' => 'success ' ]);
545+ $ res = new JSONResponse (['status ' => 'success ' ]);
546+ $ res ->throttle ();
547+ return $ res ;
532548 }
533549
534550 try {
@@ -550,6 +566,7 @@ public function deleteBookmark($id): JSONResponse {
550566 *
551567 * @NoAdminRequired
552568 * @NoCSRFRequired
569+ * @BruteForceProtection
553570 *
554571 * @PublicPage
555572 */
@@ -561,13 +578,17 @@ public function clickBookmark($url = ''): JSONResponse {
561578 try {
562579 $ bookmark = $ this ->bookmarks ->findByUrl ($ this ->authorizer ->getUserId (), $ url );
563580 } catch (DoesNotExistException $ e ) {
564- return new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_BAD_REQUEST );
581+ $ res = new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_BAD_REQUEST );
582+ $ res ->throttle ();
583+ return $ res ;
565584 } catch (UrlParseError $ e ) {
566585 return new JSONResponse (['status ' => 'error ' , 'data ' => ['Failed to parse URL ' ]], Http::STATUS_BAD_REQUEST );
567586 }
568587
569588 if ($ bookmark ->getUserId () !== $ this ->authorizer ->getUserId ()) {
570- return new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_BAD_REQUEST );
589+ $ res = new JSONResponse (['status ' => 'error ' , 'data ' => ['Not found ' ]], Http::STATUS_BAD_REQUEST );
590+ $ res ->throttle ();
591+ return $ res ;
571592 }
572593
573594 try {
@@ -591,7 +612,7 @@ public function clickBookmark($url = ''): JSONResponse {
591612 * @NoCSRFRequired
592613 *
593614 * @PublicPage
594- * @BruteForceProtection(action=bookmarks#getBookmarkImage)
615+ * @BruteForceProtection
595616 * @return DataDisplayResponse|NotFoundResponse|RedirectResponse
596617 */
597618 public function getBookmarkImage ($ id ) {
@@ -617,7 +638,7 @@ public function getBookmarkImage($id) {
617638 *
618639 * @NoAdminRequired
619640 * @NoCSRFRequired
620- * @BruteForceProtection(action=bookmarks#getBookmarkFavicon)
641+ * @BruteForceProtection
621642 * @PublicPage
622643 * @return DataDisplayResponse|NotFoundResponse|DataResponse
623644 */
@@ -670,7 +691,7 @@ public function doImageResponse(?IImage $image) {
670691 *
671692 * @NoAdminRequired
672693 * @NoCSRFRequired
673- * @BruteForceProtection(action=bookmarks#importBookmark)
694+ * @BruteForceProtection
674695 * @PublicPage
675696 */
676697 public function importBookmark ($ folder = null ): JSONResponse {
@@ -712,7 +733,9 @@ public function importBookmark($folder = null): JSONResponse {
712733 $ res ->throttle ();
713734 return $ res ;
714735 } catch (DoesNotExistException $ e ) {
715- return new JSONResponse (['status ' => 'error ' , 'data ' => ['Folder not found ' ]], Http::STATUS_BAD_REQUEST );
736+ $ res = new JSONResponse (['status ' => 'error ' , 'data ' => ['Folder not found ' ]], Http::STATUS_BAD_REQUEST );
737+ $ res ->throttle ();
738+ return $ res ;
716739 } catch (MultipleObjectsReturnedException $ e ) {
717740 return new JSONResponse (['status ' => 'error ' , 'data ' => ['Multiple objects found ' ]], Http::STATUS_INTERNAL_SERVER_ERROR );
718741 } catch (HtmlParseError $ e ) {
@@ -739,7 +762,7 @@ public function importBookmark($folder = null): JSONResponse {
739762 * @return ExportResponse|JSONResponse
740763 * @NoAdminRequired
741764 * @NoCSRFRequired
742- * @BruteForceProtection(action=bookmarks#exportBookmark)
765+ * @BruteForceProtection
743766 * @PublicPage
744767 */
745768 public function exportBookmark () {
@@ -769,7 +792,7 @@ public function exportBookmark() {
769792 * @return JSONResponse
770793 * @NoAdminRequired
771794 * @NoCSRFRequired
772- * @BruteForceProtection(action=bookmarks#countBookmarks)
795+ * @BruteForceProtection
773796 * @PublicPage
774797 * @throws UnauthenticatedError
775798 */
@@ -794,7 +817,7 @@ public function countBookmarks(int $folder): JSONResponse {
794817 * @return JSONResponse
795818 * @NoAdminRequired
796819 * @NoCSRFRequired
797- * @BruteForceProtection(action=bookmarks#countUnavailable)
820+ * @BruteForceProtection
798821 * @PublicPage
799822 * @throws UnauthenticatedError
800823 */
@@ -817,7 +840,7 @@ public function countUnavailable(): JSONResponse {
817840 * @return JSONResponse
818841 * @NoAdminRequired
819842 * @NoCSRFRequired
820- * @BruteForceProtection(action=bookmarks#countArchived)
843+ * @BruteForceProtection
821844 * @PublicPage
822845 * @throws UnauthenticatedError
823846 */
@@ -836,7 +859,7 @@ public function countArchived(): JSONResponse {
836859 * @return JSONResponse
837860 * @NoAdminRequired
838861 * @NoCSRFRequired
839- * @BruteForceProtection(action=bookmarks#countDuplicated)
862+ * @BruteForceProtection
840863 * @PublicPage
841864 * @throws UnauthenticatedError
842865 */
@@ -855,7 +878,7 @@ public function countDuplicated(): JSONResponse {
855878 * @return JSONResponse
856879 * @NoAdminRequired
857880 * @NoCSRFRequired
858- * @BruteForceProtection(action=bookmarks#acquireLock)
881+ * @BruteForceProtection
859882 * @PublicPage
860883 * @throws UnauthenticatedError
861884 */
@@ -883,7 +906,7 @@ public function acquireLock(): JSONResponse {
883906 * @return JSONResponse
884907 * @NoAdminRequired
885908 * @NoCSRFRequired
886- * @BruteForceProtection(action=bookmarks#releaseLock)
909+ * @BruteForceProtection
887910 * @PublicPage
888911 * @throws UnauthenticatedError
889912 */
@@ -911,7 +934,7 @@ public function releaseLock(): JSONResponse {
911934 * @return Http\DataResponse
912935 * @NoAdminRequired
913936 * @NoCSRFRequired
914- * @BruteForceProtection(action=bookmarks#getDeletedBookmarks)
937+ * @BruteForceProtection
915938 * @PublicPage
916939 */
917940 public function getDeletedBookmarks (): DataResponse {
@@ -933,7 +956,7 @@ public function getDeletedBookmarks(): DataResponse {
933956 /**
934957 * @NoAdminRequired
935958 * @NoCSRFRequired
936- * @BruteForceProtection(action=bookmarks#countAllClicks)
959+ * @BruteForceProtection
937960 * @return DataResponse
938961 */
939962 public function countAllClicks (): DataResponse {
@@ -954,7 +977,7 @@ public function countAllClicks(): DataResponse {
954977 /**
955978 * @NoAdminRequired
956979 * @NoCSRFRequired
957- * @BruteForceProtection(action=bookmarks#countWithClicks)
980+ * @BruteForceProtection
958981 * @return DataResponse
959982 */
960983 public function countWithClicks (): DataResponse {
0 commit comments