Browse Source
Move stopAllBridges to a controller without a Room
Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/4010/head
Joas Schilling
5 years ago
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
3 changed files with
20 additions and
15 deletions
-
appinfo/routes.php
-
lib/Controller/BridgeController.php
-
lib/Controller/BridgeSettingsController.php
|
|
|
@ -394,8 +394,12 @@ return [ |
|
|
|
'token' => '^[a-z0-9]{4,30}$', |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
/** |
|
|
|
* Bridge settings |
|
|
|
*/ |
|
|
|
[ |
|
|
|
'name' => 'Bridge#stopAllBridges', |
|
|
|
'name' => 'BridgeSettings#stopAllBridges', |
|
|
|
'url' => '/api/{apiVersion}/bridge', |
|
|
|
'verb' => 'DELETE', |
|
|
|
'requirements' => [ |
|
|
|
|
|
|
|
@ -100,18 +100,4 @@ class BridgeController extends AEnvironmentAwareController { |
|
|
|
} |
|
|
|
return new DataResponse($success); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Stop all bridges |
|
|
|
* |
|
|
|
* @return DataResponse |
|
|
|
*/ |
|
|
|
public function stopAllBridges(): DataResponse { |
|
|
|
try { |
|
|
|
$success = $this->bridgeManager->stopAllBridges(); |
|
|
|
} catch (ImpossibleToKillException $e) { |
|
|
|
return new DataResponse(['error' => $e->getMessage()], Http::STATUS_NOT_ACCEPTABLE); |
|
|
|
} |
|
|
|
return new DataResponse($success); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -26,6 +26,7 @@ declare(strict_types=1); |
|
|
|
namespace OCA\Talk\Controller; |
|
|
|
|
|
|
|
use OCA\Talk\BridgeManager; |
|
|
|
use OCA\Talk\Exceptions\ImpossibleToKillException; |
|
|
|
use OCP\AppFramework\Http; |
|
|
|
use OCP\AppFramework\Http\DataResponse; |
|
|
|
use OCP\AppFramework\OCSController; |
|
|
|
@ -60,4 +61,18 @@ class BridgeSettingsController extends OCSController { |
|
|
|
'version' => $version, |
|
|
|
]); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Stop all bridges |
|
|
|
* |
|
|
|
* @return DataResponse |
|
|
|
*/ |
|
|
|
public function stopAllBridges(): DataResponse { |
|
|
|
try { |
|
|
|
$success = $this->bridgeManager->stopAllBridges(); |
|
|
|
} catch (ImpossibleToKillException $e) { |
|
|
|
return new DataResponse(['error' => $e->getMessage()], Http::STATUS_NOT_ACCEPTABLE); |
|
|
|
} |
|
|
|
return new DataResponse($success); |
|
|
|
} |
|
|
|
} |