mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-03 06:56:15 +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,36 +2,56 @@
|
||||
|
||||
namespace App\NotificationChannels;
|
||||
|
||||
use App\Mail\NotificationChannelMessage;
|
||||
use App\Contracts\Notification;
|
||||
use App\Mail\NotificationMail;
|
||||
use App\Models\NotificationChannel;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Throwable;
|
||||
|
||||
class Email extends AbstractProvider
|
||||
class Email extends AbstractNotificationChannel
|
||||
{
|
||||
public function validationRules(): array
|
||||
public function createRules(array $input): array
|
||||
{
|
||||
return [
|
||||
'email' => 'required|email',
|
||||
];
|
||||
}
|
||||
|
||||
public function data(array $input): array
|
||||
public function createData(array $input): array
|
||||
{
|
||||
return [
|
||||
'email' => $input['email'],
|
||||
];
|
||||
}
|
||||
|
||||
public function data(): array
|
||||
{
|
||||
return [
|
||||
'email' => $this->notificationChannel->data['email'] ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
public function connect(): bool
|
||||
{
|
||||
$this->notificationChannel->connected = true;
|
||||
$this->notificationChannel->save();
|
||||
try {
|
||||
Mail::to($this->data()['email'])->send(
|
||||
new NotificationMail('Test VitoDeploy', 'This is a test email!')
|
||||
);
|
||||
} catch (Throwable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function sendMessage(string $subject, mixed $text): void
|
||||
public function send(object $notifiable, Notification $notification): void
|
||||
{
|
||||
$data = $this->notificationChannel->data;
|
||||
Mail::to($data['email'])->send(new NotificationChannelMessage($subject, $text));
|
||||
/** @var NotificationChannel $notifiable */
|
||||
$this->notificationChannel = $notifiable;
|
||||
$message = $notification->toMail($notifiable);
|
||||
|
||||
Mail::to($this->data()['email'])->send(
|
||||
new NotificationMail($message->subject, $message->render())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user