Skip to content

Commit

Permalink
Merge pull request #11102 from nextcloud/backport/11069/stable28
Browse files Browse the repository at this point in the history
[stable28] fix(API): Remove unused variables and deprecated methods
  • Loading branch information
nickvergessen committed Dec 4, 2023
2 parents 675d300 + cb29314 commit 6528701
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 0 additions & 4 deletions lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,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 @@ -76,7 +74,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 @@ -90,7 +87,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
3 changes: 0 additions & 3 deletions tests/php/Controller/SignalingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ public function setUp(): void {
$this->messages = $this->createMock(Messages::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->clientService = $this->createMock(IClientService::class);
$this->throttler = $this->createMock(IThrottler::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->recreateSignalingController();
}
Expand All @@ -145,7 +144,6 @@ private function recreateSignalingController() {
$this->controller = new CustomInputSignalingController(
'spreed',
$this->createMock(IRequest::class),
$this->serverConfig,
$this->config,
$this->signalingManager,
$this->session,
Expand All @@ -159,7 +157,6 @@ private function recreateSignalingController() {
$this->dispatcher,
$this->timeFactory,
$this->clientService,
$this->throttler,
$this->logger,
$this->userId
);
Expand Down

0 comments on commit 6528701

Please sign in to comment.