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', 'domain' => 'localhost',
// subfolder for the web app, if any // subfolder for the web app, if any
'folder' => '/jilo-web/', 'folder' => '/jilo-web/',
// database with logs from Jilo
'jilo_database' => '../../jilo/jilo.db',
// set to false to disable new registrations // set to false to disable new registrations
'registration_enabled' => true, 'registration_enabled' => true,
// will be displayed on login screen // will be displayed on login screen
@ -21,6 +19,7 @@ return [
// edit only if needed for tests or debugging // edit only if needed for tests or debugging
//******************************************* //*******************************************
// database
'db' => [ 'db' => [
// DB type for the web app, currently only "sqlite" is used // DB type for the web app, currently only "sqlite" is used
'db_type' => 'sqlite', 'db_type' => 'sqlite',
@ -29,6 +28,20 @@ return [
], ],
// system info // system info
'version' => '0.1.1', '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 <?php
// connect to database // connect to database
function connectDB($config, $database = '') { function connectDB($config, $database = '', $platform_id = '') {
// connecting ti a jilo sqlite database
if ($database === 'jilo') { if ($database === 'jilo') {
try { 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([ $db = new Database([
'type' => 'sqlite', 'type' => 'sqlite',
'dbFile' => $config['jilo_database'], 'dbFile' => $dbFile,
]); ]);
} catch (Exception $e) { } catch (Exception $e) {
$error = 'Error: ' . $e->getMessage(); if ($config['environment'] === 'production') {
$error = 'There was an unexpected error. Please try again.';
} else {
$error = 'Error: ' . $e->getMessage();
}
include '../app/templates/block-message.php'; include '../app/templates/block-message.php';
exit(); exit();
} }
// connecting to a jilo-web database of the web app
} else { } else {
// sqlite database file // sqlite database file

View File

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