Moved notification settings to DB

This commit is contained in:
Henry Whitaker
2020-07-07 20:51:57 +01:00
parent f543e1345c
commit 4ef0303dff
25 changed files with 837 additions and 112 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Console\Commands;
use App\Helpers\SettingsHelper;
use Illuminate\Console\Command;
class GetConfig extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'speedtest:config';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Get the application configuration';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$this->info(json_encode(SettingsHelper::getConfig(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Console\Commands;
use App\Helpers\SettingsHelper;
use Illuminate\Console\Command;
class SetSlackWebhook extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'speedtest:slack {webhook : The slack webhook to store}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Set the slack webhook setting';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$webhook = $this->argument('webhook');
SettingsHelper::set('slack_webhook', $webhook);
$this->info('Slack webhook updated');
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Console\Commands;
use App\Helpers\SettingsHelper;
use Illuminate\Console\Command;
class SetTelegramOptions extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'speedtest:telegram
{--bot= : The telegram bot token}
{--chat= : The telegram chat ID}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Set the telegram settings';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$bot = $this->option('bot');
$chat = $this->option('chat');
SettingsHelper::set('telegram_bot_token', $bot);
SettingsHelper::set('telegram_chat_id', $chat);
$this->info('Telegram options updated');
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Console\Commands;
use App\Helpers\SettingsHelper;
use Illuminate\Console\Command;
class TestNotification extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'speedtest:notification';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send test notifications to all notification agents';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
SettingsHelper::testNotification();
}
}