WIP notifications and other refactors (#88)

* WIP notifications and other refactors
- refactor notification channels
- send notifications on events related to the servers and sites
- delete server log files on server deletion
- add telegram notification channel
- add new icons
- cache configs and icons on installation and updates
- new navbar for dark mode and settings

* discord channel

* build assets

* pint
This commit is contained in:
Saeed Vaziry
2024-01-07 09:54:08 +01:00
committed by GitHub
parent f06b8f7d20
commit e997d0deea
72 changed files with 1153 additions and 480 deletions

View File

@ -2,19 +2,21 @@
namespace App\Models;
use App\Contracts\Notification;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Notifications\Notifiable;
/**
* @property string $provider
* @property string $label
* @property array $data
* @property bool $connected
* @property bool $is_default
* @property User $user
* @property int $id
* @property string provider
* @property array data
* @property string label
* @property bool connected
*/
class NotificationChannel extends AbstractModel
{
use HasFactory;
use Notifiable;
protected $fillable = [
'provider',
@ -25,15 +27,24 @@ class NotificationChannel extends AbstractModel
];
protected $casts = [
'data' => 'json',
'project_id' => 'integer',
'data' => 'array',
'connected' => 'boolean',
'is_default' => 'boolean',
];
public function provider(): \App\Contracts\NotificationChannel
{
$provider = config('core.notification_channels_providers_class')[$this->provider];
$class = config('core.notification_channels_providers_class')[$this->provider];
return new $provider($this);
return new $class($this);
}
public static function notifyAll(Notification $notification): void
{
$channels = self::all();
foreach ($channels as $channel) {
$channel->notify($notification);
}
}
}