From 779491517264b4dccbc67347dec7e2f12d70e367 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 31 May 2020 16:33:25 +0200 Subject: [PATCH] expose permission exceptions to the API --- lib/Controller.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/Controller.php b/lib/Controller.php index 21a27b2..0c039f5 100644 --- a/lib/Controller.php +++ b/lib/Controller.php @@ -196,15 +196,20 @@ class Controller */ private function _create() { - // Ensure last paste from visitors IP address was more than configured amount of seconds ago. - TrafficLimiter::setConfiguration($this->_conf); - if (!TrafficLimiter::canPass()) { - $this->_return_message( - 1, I18n::_( - 'Please wait %d seconds between each post.', - $this->_conf->getKey('limit', 'traffic') - ) - ); + try { + // Ensure last paste from visitors IP address was more than configured amount of seconds ago. + TrafficLimiter::setConfiguration($this->_conf); + if (!TrafficLimiter::canPass()) { + $this->_return_message( + 1, I18n::_( + 'Please wait %d seconds between each post.', + $this->_conf->getKey('limit', 'traffic') + ) + ); + return; + } + } catch (Exception $e) { + $this->_return_message(1, I18n::_($e->getMessage())); return; }