Skip to content

Commit

Permalink
Fall back to the normal DB when nothing is special
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Feb 11, 2022
1 parent 4753f83 commit 69537e3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\IConfig;
use OCP\IDateTimeFormatter;
use OCP\IDBConnection;
use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\IUserManager;
Expand Down Expand Up @@ -78,6 +79,18 @@ public function register(IRegistrationContext $context): void {
});

$context->registerService('ActivityConnectionAdapter', function (ContainerInterface $c) {
$systemConfig = $c->get(SystemConfig::class);
$configPrefix = 'activity_';

if ($systemConfig->getValue($configPrefix . 'dbuser', null) === null &&
$systemConfig->getValue($configPrefix . 'dbpassword', null) === null &&
$systemConfig->getValue($configPrefix . 'dbname', null) === null &&
$systemConfig->getValue($configPrefix . 'dbhost', null) === null &&
$systemConfig->getValue($configPrefix . 'dbport', null) === null &&
$systemConfig->getValue($configPrefix . 'dbdriveroptions', null) === null) {
return $c->get(IDBConnection::class);
}

return new ConnectionAdapter(
$c->get('ActivityDBConnection')
);
Expand Down

0 comments on commit 69537e3

Please sign in to comment.