mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-18 08:09:56 +03:00
fix: dont fail for non-existing enabled bridge (#3589)
* fix: dont fail for non-existing enabled bridge * yup
This commit is contained in:
parent
10f7b6f4f6
commit
ed97ce8646
4 changed files with 25 additions and 12 deletions
|
@ -37,12 +37,14 @@ class ConnectivityAction implements ActionInterface
|
||||||
throw new \Exception('This action is only available in debug mode!');
|
throw new \Exception('This action is only available in debug mode!');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($request['bridge'])) {
|
$bridgeName = $request['bridge'] ?? null;
|
||||||
|
if (!$bridgeName) {
|
||||||
return render_template('connectivity.html.php');
|
return render_template('connectivity.html.php');
|
||||||
}
|
}
|
||||||
|
$bridgeClassName = $this->bridgeFactory->createBridgeClassName($bridgeName);
|
||||||
$bridgeClassName = $this->bridgeFactory->createBridgeClassName($request['bridge']);
|
if (!$bridgeClassName) {
|
||||||
|
throw new \Exception(sprintf('Bridge not found: %s', $bridgeName));
|
||||||
|
}
|
||||||
return $this->reportBridgeConnectivity($bridgeClassName);
|
return $this->reportBridgeConnectivity($bridgeClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,15 @@ class DisplayAction implements ActionInterface
|
||||||
private function createResponse(array $request)
|
private function createResponse(array $request)
|
||||||
{
|
{
|
||||||
$bridgeFactory = new BridgeFactory();
|
$bridgeFactory = new BridgeFactory();
|
||||||
$bridgeClassName = $bridgeFactory->createBridgeClassName($request['bridge'] ?? '');
|
$formatFactory = new FormatFactory();
|
||||||
|
|
||||||
|
$bridgeName = $request['bridge'] ?? null;
|
||||||
$format = $request['format'] ?? null;
|
$format = $request['format'] ?? null;
|
||||||
|
|
||||||
|
$bridgeClassName = $bridgeFactory->createBridgeClassName($bridgeName);
|
||||||
|
if (!$bridgeClassName) {
|
||||||
|
throw new \Exception(sprintf('Bridge not found: %s', $bridgeName));
|
||||||
|
}
|
||||||
if (!$format) {
|
if (!$format) {
|
||||||
throw new \Exception('You must specify a format!');
|
throw new \Exception('You must specify a format!');
|
||||||
}
|
}
|
||||||
|
@ -43,7 +49,6 @@ class DisplayAction implements ActionInterface
|
||||||
throw new \Exception('This bridge is not whitelisted');
|
throw new \Exception('This bridge is not whitelisted');
|
||||||
}
|
}
|
||||||
|
|
||||||
$formatFactory = new FormatFactory();
|
|
||||||
$format = $formatFactory->create($format);
|
$format = $formatFactory->create($format);
|
||||||
|
|
||||||
$bridge = $bridgeFactory->create($bridgeClassName);
|
$bridge = $bridgeFactory->create($bridgeClassName);
|
||||||
|
|
|
@ -23,7 +23,11 @@ class SetBridgeCacheAction implements ActionInterface
|
||||||
|
|
||||||
$bridgeFactory = new BridgeFactory();
|
$bridgeFactory = new BridgeFactory();
|
||||||
|
|
||||||
$bridgeClassName = $bridgeFactory->createBridgeClassName($request['bridge'] ?? '');
|
$bridgeName = $request['bridge'] ?? null;
|
||||||
|
$bridgeClassName = $bridgeFactory->createBridgeClassName($bridgeName);
|
||||||
|
if (!$bridgeClassName) {
|
||||||
|
throw new \Exception(sprintf('Bridge not found: %s', $bridgeName));
|
||||||
|
}
|
||||||
|
|
||||||
// whitelist control
|
// whitelist control
|
||||||
if (!$bridgeFactory->isEnabled($bridgeClassName)) {
|
if (!$bridgeFactory->isEnabled($bridgeClassName)) {
|
||||||
|
|
|
@ -23,7 +23,12 @@ final class BridgeFactory
|
||||||
$this->enabledBridges = $this->bridgeClassNames;
|
$this->enabledBridges = $this->bridgeClassNames;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$this->enabledBridges[] = $this->createBridgeClassName($enabledBridge);
|
$bridgeClassName = $this->createBridgeClassName($enabledBridge);
|
||||||
|
if ($bridgeClassName) {
|
||||||
|
$this->enabledBridges[] = $bridgeClassName;
|
||||||
|
} else {
|
||||||
|
Logger::info(sprintf('Bridge not found: %s', $enabledBridge));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +47,10 @@ final class BridgeFactory
|
||||||
$name = self::normalizeBridgeName($bridgeName);
|
$name = self::normalizeBridgeName($bridgeName);
|
||||||
$namesLoweredCase = array_map('strtolower', $this->bridgeClassNames);
|
$namesLoweredCase = array_map('strtolower', $this->bridgeClassNames);
|
||||||
$nameLoweredCase = strtolower($name);
|
$nameLoweredCase = strtolower($name);
|
||||||
|
|
||||||
if (! in_array($nameLoweredCase, $namesLoweredCase)) {
|
if (! in_array($nameLoweredCase, $namesLoweredCase)) {
|
||||||
throw new \Exception(sprintf('Bridge name invalid: %s', $bridgeName));
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$index = array_search($nameLoweredCase, $namesLoweredCase);
|
$index = array_search($nameLoweredCase, $namesLoweredCase);
|
||||||
|
|
||||||
return $this->bridgeClassNames[$index];
|
return $this->bridgeClassNames[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue