mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-20 02:11:36 +00:00
- refactoring architecture - fix incomplete ssh logs - code editor for scripts in the app - remove Jobs and SSHCommands
60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\NotificationChannels;
|
|
|
|
use App\Models\NotificationChannel;
|
|
use App\NotificationChannels\Email\NotificationMail;
|
|
use App\Notifications\NotificationInterface;
|
|
use Illuminate\Support\Facades\Mail;
|
|
use Throwable;
|
|
|
|
class Email extends AbstractNotificationChannel
|
|
{
|
|
public function createRules(array $input): array
|
|
{
|
|
return [
|
|
'email' => 'required|email',
|
|
];
|
|
}
|
|
|
|
public function createData(array $input): array
|
|
{
|
|
return [
|
|
'email' => $input['email'],
|
|
];
|
|
}
|
|
|
|
public function data(): array
|
|
{
|
|
return [
|
|
'email' => $this->notificationChannel->data['email'] ?? '',
|
|
];
|
|
}
|
|
|
|
public function connect(): bool
|
|
{
|
|
try {
|
|
Mail::to($this->data()['email'])->send(
|
|
new NotificationMail(
|
|
'Connected to VitoDeploy',
|
|
'This email confirms that you have connected your email to VitoDeploy.'
|
|
)
|
|
);
|
|
} catch (Throwable) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function send(object $notifiable, NotificationInterface $notification): void
|
|
{
|
|
/** @var NotificationChannel $notifiable */
|
|
$this->notificationChannel = $notifiable;
|
|
$message = $notification->toEmail($notifiable);
|
|
Mail::to($this->data()['email'])->send(
|
|
new NotificationMail($message->subject, $message->render())
|
|
);
|
|
}
|
|
}
|