feat: Add notification services for Email, Telegram, and WhatsApp
- Implement EmailNotifier for sending batch and test notifications via email. - Implement TelegramNotifier for sending batch and test notifications via Telegram. - Implement WahaNotifier for sending batch and test notifications via WhatsApp using WAHA API. - Create migration for client_categories table and update clients table to include category_id. - Create migration for notification_settings table to manage notification configurations. - Add ClientCategorySeeder to populate default client categories. - Create manifest.json for PWA support. - Implement service worker (sw.js) for caching static assets and offline support. - Add edit event view for modifying scheduled events. - Create search results view for displaying search queries. - Develop notification settings view for configuring notification channels and triggers.
This commit is contained in:
43
app/Services/Notifications/EmailNotifier.php
Normal file
43
app/Services/Notifications/EmailNotifier.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Services\Notifications;
|
||||
|
||||
use App\Models\NotificationSetting;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class EmailNotifier
|
||||
{
|
||||
public function sendBatch(NotificationSetting $setting, array $messages): void
|
||||
{
|
||||
$toEmail = $setting->config['to_email'] ?? null;
|
||||
|
||||
if (! $toEmail) {
|
||||
throw new \RuntimeException('Email to_email address is required.');
|
||||
}
|
||||
|
||||
$combined = implode("\n\n---\n\n", $messages);
|
||||
|
||||
Mail::raw($combined, function ($mail) use ($toEmail, $setting): void {
|
||||
$mail->to($toEmail)
|
||||
->subject("🐱 KOL Manager — {$setting->name} Notifications");
|
||||
});
|
||||
}
|
||||
|
||||
public function sendTest(NotificationSetting $setting): void
|
||||
{
|
||||
$toEmail = $setting->config['to_email'] ?? null;
|
||||
|
||||
if (! $toEmail) {
|
||||
throw new \RuntimeException('Email to_email address is required.');
|
||||
}
|
||||
|
||||
Mail::raw(
|
||||
"🐱 KOL Manager — Test Notification\n\nYour Email channel is configured correctly! 🎉",
|
||||
function ($mail) use ($toEmail): void {
|
||||
$mail->to($toEmail)->subject('🐱 KOL Manager — Test Notification');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user