Skip to content

Commit

Permalink
language override fixes #997 (#1003)
Browse files Browse the repository at this point in the history
* language override fixes #997

* remove debugging code

* better handling of the status column

* migration updates

* force migrations to run
  • Loading branch information
dgershman authored Apr 5, 2024
1 parent 4a46837 commit 64df640
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 105 deletions.
1 change: 1 addition & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### 4.3.3 (UNRELEASED)
* Fix for reports where they are always recursing service bodies regardless of the setting [#980]
* Fix for metrics counts summaries.
* Fix for language word overrides. [#997]
* Removing `file_get_contents()` usage to support some cases where servers may be misconfigured.
* Using native Laravel database migrations.

Expand Down
12 changes: 6 additions & 6 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
.PHONY: run
run:
cd src; composer install
cd src; npm install
cd src; env ENVIRONMENT=test php artisan serve
composer install
npm install
env ENVIRONMENT=test php artisan serve

.PHONY: lint
lint:
cd src; find . -name "*.php" ! -path '*/vendor/*' -print0 | xargs -0 -n1 -P8 php -l
cd src; composer install
cd src; vendor/squizlabs/php_codesniffer/bin/phpcs
find . -name "*.php" ! -path '*/vendor/*' -print0 | xargs -0 -n1 -P8 php -l
composer install
vendor/squizlabs/php_codesniffer/bin/phpcs

.PHONY: lint-fix
lint-fix:
Expand Down
2 changes: 1 addition & 1 deletion src/app/Http/Middleware/DatabaseMigrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(SettingsService $settings)
public function handle(Request $request, Closure $next)
{
if ($this->settings->has('mysql_hostname')) {
Artisan::call("migrate");
Artisan::call("migrate", array('--force' => true));
}

return $next($request);
Expand Down
8 changes: 8 additions & 0 deletions src/app/Services/SettingsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ public function __construct()
}

$this->shortLanguage = $this->getWordLanguage() === "da-DK" ? "dk" : explode("-", $this->getWordLanguage())[0];

foreach ($_SESSION ?? [] as $session_key => $session_value) {
$language = $this->getWordLanguage();
$stripped_key_test = str_replace("override_", "", $session_key);
if (isset($this->localizations->getLocalization($language)[$stripped_key_test])) {
$this->localizations->getLocalization($language)[$session_key] = $session_value;
}
}
}

public function getShortLanguage(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
*/
public function up()
{
Schema::create('alerts', function (Blueprint $table) {
$table->integer('id', true);
$table->timestamp('timestamp')->nullable();
$table->integer('alert_id');
$table->longText('payload')->nullable();
$table->integer('status')->nullable();
});
if (!Schema::hasTable('alerts')) {
Schema::create('alerts', function (Blueprint $table) {
$table->integer('id', true);
$table->timestamp('timestamp')->nullable();
$table->integer('alert_id');
$table->longText('payload')->nullable();
$table->integer('status')->nullable();
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
*/
public function up()
{
Schema::create('cache_records_conference_participants', function (Blueprint $table) {
$table->string('parent_callsid', 100)->nullable()->index('idx_rcp_parent_parent_callsid');
$table->string('callsid', 100)->nullable()->index('idx_rcp_parent_callsid');
$table->string('guid', 36)->nullable();
$table->integer('service_body_id')->nullable();
});
if (!Schema::hasTable('cache_records_conference_participants')) {
Schema::create('cache_records_conference_participants', function (Blueprint $table) {
$table->string('parent_callsid', 100)->nullable()->index('idx_rcp_parent_parent_callsid');
$table->string('callsid', 100)->nullable()->index('idx_rcp_parent_callsid');
$table->string('guid', 36)->nullable();
$table->integer('service_body_id')->nullable();
});
}
}

/**
Expand Down
14 changes: 8 additions & 6 deletions src/database/migrations/2024_03_24_035821_create_cache_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
*/
public function up()
{
Schema::create('cache', function (Blueprint $table) {
$table->bigInteger('id', true);
$table->longText('key')->nullable();
$table->longText('value')->nullable();
$table->integer('expiry')->nullable();
});
if (!Schema::hasTable('cache')) {
Schema::create('cache', function (Blueprint $table) {
$table->bigInteger('id', true);
$table->longText('key')->nullable();
$table->longText('value')->nullable();
$table->integer('expiry')->nullable();
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
*/
public function up()
{
Schema::create('conference_participants', function (Blueprint $table) {
$table->integer('id', true);
$table->timestamp('timestamp')->useCurrent();
$table->string('conferencesid', 100)->index('idx_conference_participants_conferencesid');
$table->string('callsid', 100)->index('idx_conference_participants_callsid');
$table->string('friendlyname', 100);
$table->integer('role');
if (!Schema::hasTable('conference_participants')) {
Schema::create('conference_participants', function (Blueprint $table) {
$table->integer('id', true);
$table->timestamp('timestamp')->useCurrent();
$table->string('conferencesid', 100)->index('idx_conference_participants_conferencesid');
$table->string('callsid', 100)->index('idx_conference_participants_callsid');
$table->string('friendlyname', 100);
$table->integer('role');

///$table->primary(['id']);
});
///$table->primary(['id']);
});
}
}

/**
Expand Down
19 changes: 10 additions & 9 deletions src/database/migrations/2024_03_24_035821_create_config_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
*/
public function up()
{
Schema::create('config', function (Blueprint $table) {
$table->integer('id', true);
$table->unsignedInteger('service_body_id');
$table->mediumText('data');
$table->string('data_type', 45);
$table->unsignedInteger('parent_id')->nullable();
$table->integer('status')->nullable();
if (!Schema::hasTable('config')) {
Schema::create('config', function (Blueprint $table) {
$table->integer('id', true);
$table->unsignedInteger('service_body_id');
$table->mediumText('data');
$table->string('data_type', 45);
$table->unsignedInteger('parent_id')->nullable();

$table->unique(['service_body_id', 'data_type', 'parent_id'], 'service_body_id_data_type_parent_id_unique');
});
$table->unique(['service_body_id', 'data_type', 'parent_id'], 'service_body_id_data_type_parent_id_unique');
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
*/
public function up()
{
Schema::create('event_status', function (Blueprint $table) {
$table->bigInteger('id', true)->unique('id_unique');
$table->string('callsid')->nullable();
$table->integer('status')->nullable();
$table->integer('event_id')->nullable();
$table->timestamps();
if (!Schema::hasTable('event_status')) {
Schema::create('event_status', function (Blueprint $table) {
$table->bigInteger('id', true)->unique('id_unique');
$table->string('callsid')->nullable();
$table->integer('status')->nullable();
$table->integer('event_id')->nullable();
$table->timestamps();

//$table->primary(['id']);
});
//$table->primary(['id']);
});
}
}

/**
Expand Down
14 changes: 8 additions & 6 deletions src/database/migrations/2024_03_24_035821_create_flags_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
*/
public function up()
{
Schema::create('flags', function (Blueprint $table) {
$table->integer('id', true);
$table->string('flag_name', 50)->unique('flag_name_unique');
$table->integer('flag_setting');
$table->timestamp('timestamp')->useCurrent();
});
if (!Schema::hasTable('flags')) {
Schema::create('flags', function (Blueprint $table) {
$table->integer('id', true);
$table->string('flag_name', 50)->unique('flag_name_unique');
$table->integer('flag_setting');
$table->timestamp('timestamp')->useCurrent();
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
*/
public function up()
{
Schema::create('metrics', function (Blueprint $table) {
$table->integer('id', true)->unique('id_metrics_unique');
$table->timestamp('timestamp')->useCurrent();
$table->text('data');
$table->unsignedInteger('service_body_id')->nullable();
if (!Schema::hasTable('metrics')) {
Schema::create('metrics', function (Blueprint $table) {
$table->integer('id', true)->unique('id_metrics_unique');
$table->timestamp('timestamp')->useCurrent();
$table->text('data');
$table->unsignedInteger('service_body_id')->nullable();

//$table->primary(['id']);
});
//$table->primary(['id']);
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
*/
public function up()
{
Schema::create('migrations', function (Blueprint $table) {
$table->integer('id', true);
$table->string('version', 45)->nullable();
$table->timestamp('timestamp')->useCurrent();
});
if (!Schema::hasTable('migrations')) {
Schema::create('migrations', function (Blueprint $table) {
$table->integer('id', true);
$table->string('version', 45)->nullable();
$table->timestamp('timestamp')->useCurrent();
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
*/
public function up()
{
Schema::create('records_events', function (Blueprint $table) {
$table->integer('id', true);
$table->string('callsid')->index('idx_records_events_callsid');
$table->timestamp('event_time')->nullable();
$table->integer('event_id');
$table->integer('service_body_id')->nullable()->index('idx_records_events_service_body_id');
$table->text('meta')->nullable();
$table->integer('type')->nullable();
});
if (!Schema::hasTable('records_events')) {
Schema::create('records_events', function (Blueprint $table) {
$table->integer('id', true);
$table->string('callsid')->index('idx_records_events_callsid');
$table->timestamp('event_time')->nullable();
$table->integer('event_id');
$table->integer('service_body_id')->nullable()->index('idx_records_events_service_body_id');
$table->text('meta')->nullable();
$table->integer('type')->nullable();
});
}
}

/**
Expand Down
24 changes: 13 additions & 11 deletions src/database/migrations/2024_03_24_035821_create_records_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@
*/
public function up()
{
Schema::create('records', function (Blueprint $table) {
$table->integer('id', true);
$table->string('callsid')->index('idx_records_callsid');
$table->timestamp('start_time')->nullable();
$table->timestamp('end_time')->nullable();
$table->string('from_number');
$table->string('to_number');
$table->longText('payload')->nullable();
$table->integer('duration');
$table->integer('type')->nullable();
});
if (!Schema::hasTable('records')) {
Schema::create('records', function (Blueprint $table) {
$table->integer('id', true);
$table->string('callsid')->index('idx_records_callsid');
$table->timestamp('start_time')->nullable();
$table->timestamp('end_time')->nullable();
$table->string('from_number');
$table->string('to_number');
$table->longText('payload')->nullable();
$table->integer('duration');
$table->integer('type')->nullable();
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
*/
public function up()
{
Schema::create('sessions', function (Blueprint $table) {
$table->string('callsid');
$table->timestamp('timestamp')->useCurrent();
$table->integer('pin');
});
if (!Schema::hasTable('sessions')) {
Schema::create('sessions', function (Blueprint $table) {
$table->string('callsid');
$table->timestamp('timestamp')->useCurrent();
$table->integer('pin');
});
}
}

/**
Expand Down
22 changes: 12 additions & 10 deletions src/database/migrations/2024_03_24_035821_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->integer('id', true);
$table->string('name');
$table->string('username', 45)->unique('username_unique');
$table->string('password');
$table->integer('permissions')->default(0);
$table->integer('is_admin')->nullable();
$table->timestamp('created_on')->useCurrent();
$table->text('service_bodies')->nullable();
});
if (!Schema::hasTable('users')) {
Schema::create('users', function (Blueprint $table) {
$table->integer('id', true);
$table->string('name');
$table->string('username', 45)->unique('username_unique');
$table->string('password');
$table->integer('permissions')->default(0);
$table->integer('is_admin')->nullable();
$table->timestamp('created_on')->useCurrent();
$table->text('service_bodies')->nullable();
});
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::whenTableDoesntHaveColumn('config', 'status', function (Blueprint $table) {
$table->addColumn('integer', 'status')->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::whenTableHasColumn('config', 'status', function (Blueprint $table) {
$table->removeColumn('status');
});
}
};
Loading

0 comments on commit 64df640

Please sign in to comment.