Initial support for multiple Jitsi platforms

main
Yasen Pramatarov 2024-08-17 10:01:48 +03:00
parent 8ca9643fc2
commit ea4b85ddf7
3 changed files with 32 additions and 6 deletions

View File

@ -10,8 +10,6 @@ return [
'domain' => 'localhost',
// subfolder for the web app, if any
'folder' => '/jilo-web/',
// database with logs from Jilo
'jilo_database' => '../../jilo/jilo.db',
// set to false to disable new registrations
'registration_enabled' => true,
// will be displayed on login screen
@ -21,6 +19,7 @@ return [
// edit only if needed for tests or debugging
//*******************************************
// database
'db' => [
// DB type for the web app, currently only "sqlite" is used
'db_type' => 'sqlite',
@ -29,6 +28,20 @@ return [
],
// system info
'version' => '0.1.1',
// development has verbose error messages, production has not
'environment' => 'production',
// *************************************
// Maintained by the app, edit with care
// *************************************
'platforms' => [
'0' => [
'name' => 'meet.example.com',
// database with logs from Jilo
'jilo_database' => '../../jilo/jilo.db',
],
],
];
?>

View File

@ -1,20 +1,30 @@
<?php
// connect to database
function connectDB($config, $database = '') {
function connectDB($config, $database = '', $platform_id = '') {
// connecting ti a jilo sqlite database
if ($database === 'jilo') {
try {
$dbFile = $config['platforms'][$platform_id]['jilo_database'] ?? null;
if (!$dbFile) {
throw new Exception("Invalid platform ID \"$platform_id\", database file not found.");
}
$db = new Database([
'type' => 'sqlite',
'dbFile' => $config['jilo_database'],
'dbFile' => $dbFile,
]);
} catch (Exception $e) {
if ($config['environment'] === 'production') {
$error = 'There was an unexpected error. Please try again.';
} else {
$error = 'Error: ' . $e->getMessage();
}
include '../app/templates/block-message.php';
exit();
}
// connecting to a jilo-web database of the web app
} else {
// sqlite database file

View File

@ -4,9 +4,12 @@ require_once '../app/classes/database.php';
require '../app/classes/conference.php';
require '../app/classes/participant.php';
// by default we connect ot the first configured platform
$platform_id = $_REQUEST['platform'] ?? '0';
// connect to database
require '../app/helpers/database.php';
$db = connectDB($config, 'jilo');
$db = connectDB($config, 'jilo', $platform_id);
//