Fix email for news not going out (#1131)

This commit is contained in:
Nabeel S
2021-04-11 14:32:58 -04:00
committed by GitHub
parent 648e7a261d
commit fdab4ee530
3 changed files with 15 additions and 15 deletions

View File

@@ -50,10 +50,16 @@ class EventHandler extends Listener
{ {
$admin_users = User::whereRoleIs('admin')->get(); $admin_users = User::whereRoleIs('admin')->get();
try { foreach ($admin_users as $user) {
Notification::send($admin_users, $notification); if (empty($user->email)) {
} catch (Exception $e) { continue;
Log::emergency('Error emailing admins, malformed email='.$e->getMessage()); }
try {
Notification::send([$user], $notification);
} catch (Exception $e) {
Log::emergency('Error emailing admin ('.$user->email.'). Error='.$e->getMessage());
}
} }
} }
@@ -66,7 +72,7 @@ class EventHandler extends Listener
try { try {
$user->notify($notification); $user->notify($notification);
} catch (Exception $e) { } catch (Exception $e) {
Log::emergency('Error emailing admins, malformed email='.$e->getMessage()); Log::emergency('Error emailing user, '.$user->ident.'='.$user->email.', error='.$e->getMessage());
} }
} }
@@ -91,10 +97,8 @@ class EventHandler extends Listener
Log::info('Sending notification to '.$users->count().' users'); Log::info('Sending notification to '.$users->count().' users');
try { foreach ($users as $user) {
Notification::send($users, $notification); $this->notifyUser($user, $notification);
} catch (Exception $e) {
Log::emergency('Error emailing admins, malformed email='.$e->getMessage());
} }
} }

View File

@@ -22,7 +22,7 @@ class NewsAdded extends Notification
$this->news = $news; $this->news = $news;
$this->setMailable( $this->setMailable(
$news->subject, $news->subject,
'notifications.mail.news', 'notifications.mail.news.news',
['news' => $news] ['news' => $news]
); );
} }

View File

@@ -1,11 +1,7 @@
@component('mail::message') @component('mail::message')
# {{ $news->subject }} # {{ $news->subject }}
$news->body {{ $news->body }}
@component('mail::button', ['url' => route('frontend.pireps.show', [$pirep->id])])
View PIREP
@endcomponent
Thanks,<br> Thanks,<br>
{{ config('app.name') }} {{ config('app.name') }}