Skip to content

Commit

Permalink
fix(API): Remove unused variables and deprecated methods
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Dec 1, 2023
1 parent 2fbcaf2 commit 2b23a63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 0 additions & 4 deletions lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@
use OCP\DB\Exception;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Http\Client\IClientService;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Security\Bruteforce\IThrottler;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -72,7 +70,6 @@ class SignalingController extends OCSController {
public function __construct(
string $appName,
IRequest $request,
IConfig $serverConfig,
private Config $talkConfig,
private \OCA\Talk\Signaling\Manager $signalingManager,
private TalkSession $session,
Expand All @@ -86,7 +83,6 @@ public function __construct(
private IEventDispatcher $dispatcher,
private ITimeFactory $timeFactory,
private IClientService $clientService,
IThrottler $throttler,
private LoggerInterface $logger,
private ?string $userId,
) {
Expand Down
7 changes: 6 additions & 1 deletion lib/Middleware/InjectionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
use OCP\Federation\ICloudIdManager;
use OCP\IRequest;
use OCP\Security\Bruteforce\IThrottler;
use OCP\Security\Bruteforce\MaxDelayReached;

class InjectionMiddleware extends Middleware {
protected bool $isTalkFederation = false;
Expand Down Expand Up @@ -316,7 +317,11 @@ public function afterException($controller, $methodName, \Exception $exception):
$action = $protection->getAction();

if ('talkRoomToken' === $action) {
$this->throttler->sleepDelay($this->request->getRemoteAddress(), $action);
try {
$this->throttler->sleepDelayOrThrowOnMax($this->request->getRemoteAddress(), $action);
} catch (MaxDelayReached $e) {
throw new OCSException($e->getMessage(), Http::STATUS_TOO_MANY_REQUESTS);
}
$this->throttler->registerAttempt($action, $this->request->getRemoteAddress(), [
'token' => $this->request->getParam('token') ?? '',
]);
Expand Down

0 comments on commit 2b23a63

Please sign in to comment.