fix notifications (#109)

This commit is contained in:
Saeed Vaziry
2024-02-16 21:54:51 +01:00
committed by GitHub
parent f70963d6bb
commit 9db310a06b
14 changed files with 20 additions and 12 deletions

View File

@ -3,6 +3,7 @@
namespace App\NotificationChannels;
use App\Contracts\Notification;
use App\Models\NotificationChannel;
use Illuminate\Support\Facades\Http;
class Discord extends AbstractNotificationChannel
@ -60,6 +61,8 @@ private function checkConnection(string $subject, string $text): bool
public function send(object $notifiable, Notification $notification): void
{
/** @var NotificationChannel $notifiable */
$this->notificationChannel = $notifiable;
$data = $this->notificationChannel->data;
Http::post($data['webhook_url'], [
'content' => $notification->toSlack($notifiable),

View File

@ -51,8 +51,7 @@ public function send(object $notifiable, Notification $notification): void
{
/** @var NotificationChannel $notifiable */
$this->notificationChannel = $notifiable;
$message = $notification->toMail($notifiable);
$message = $notification->toEmail($notifiable);
Mail::to($this->data()['email'])->send(
new NotificationMail($message->subject, $message->render())
);

View File

@ -3,6 +3,7 @@
namespace App\NotificationChannels;
use App\Contracts\Notification;
use App\Models\NotificationChannel;
use Illuminate\Support\Facades\Http;
class Slack extends AbstractNotificationChannel
@ -60,6 +61,8 @@ private function checkConnection(string $subject, string $text): bool
public function send(object $notifiable, Notification $notification): void
{
/** @var NotificationChannel $notifiable */
$this->notificationChannel = $notifiable;
$data = $this->notificationChannel->data;
Http::post($data['webhook_url'], [
'text' => $notification->toSlack($notifiable),

View File

@ -3,6 +3,7 @@
namespace App\NotificationChannels;
use App\Contracts\Notification;
use App\Models\NotificationChannel;
use Illuminate\Support\Facades\Http;
use Throwable;
@ -47,6 +48,8 @@ public function connect(): bool
public function send(object $notifiable, Notification $notification): void
{
/** @var NotificationChannel $notifiable */
$this->notificationChannel = $notifiable;
$this->sendToTelegram($notification->toTelegram($notifiable));
}