mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
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:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user