Re-enabled plaintext view for email notifications

Updated mail notifications to set the HTML and plaintext views since before
no plaintext version was being created.

Closes #1182
This commit is contained in:
Dan Brown 2018-12-16 20:44:57 +00:00
parent 651ae2f3be
commit 7f6929d716
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
5 changed files with 55 additions and 54 deletions

View File

@ -1,17 +1,7 @@
<?php <?php namespace BookStack\Notifications;
namespace BookStack\Notifications; class ConfirmEmail extends MailNotification
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class ConfirmEmail extends Notification implements ShouldQueue
{ {
use Queueable;
public $token; public $token;
/** /**
@ -23,17 +13,6 @@ class ConfirmEmail extends Notification implements ShouldQueue
$this->token = $token; $this->token = $token;
} }
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/** /**
* Get the mail representation of the notification. * Get the mail representation of the notification.
* *
@ -43,7 +22,7 @@ class ConfirmEmail extends Notification implements ShouldQueue
public function toMail($notifiable) public function toMail($notifiable)
{ {
$appName = ['appName' => setting('app-name')]; $appName = ['appName' => setting('app-name')];
return (new MailMessage) return $this->newMailMessage()
->subject(trans('auth.email_confirm_subject', $appName)) ->subject(trans('auth.email_confirm_subject', $appName))
->greeting(trans('auth.email_confirm_greeting', $appName)) ->greeting(trans('auth.email_confirm_greeting', $appName))
->line(trans('auth.email_confirm_text')) ->line(trans('auth.email_confirm_text'))

View File

@ -0,0 +1,35 @@
<?php namespace BookStack\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class MailNotification extends Notification implements ShouldQueue
{
use Queueable;
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Create a new mail message.
* @return MailMessage
*/
protected function newMailMessage()
{
return (new MailMessage)->view([
'html' => 'vendor.notifications.email',
'text' => 'vendor.notifications.email-plain'
]);
}
}

View File

@ -1,11 +1,7 @@
<?php <?php namespace BookStack\Notifications;
namespace BookStack\Notifications;
use Illuminate\Notifications\Messages\MailMessage; class ResetPassword extends MailNotification
use Illuminate\Notifications\Notification;
class ResetPassword extends Notification
{ {
/** /**
* The password reset token. * The password reset token.
@ -24,17 +20,6 @@ class ResetPassword extends Notification
$this->token = $token; $this->token = $token;
} }
/**
* Get the notification's channels.
*
* @param mixed $notifiable
* @return array|string
*/
public function via($notifiable)
{
return ['mail'];
}
/** /**
* Build the mail representation of the notification. * Build the mail representation of the notification.
* *
@ -42,7 +27,7 @@ class ResetPassword extends Notification
*/ */
public function toMail() public function toMail()
{ {
return (new MailMessage) return $this->newMailMessage()
->subject(trans('auth.email_reset_subject', ['appName' => setting('app-name')])) ->subject(trans('auth.email_reset_subject', ['appName' => setting('app-name')]))
->line(trans('auth.email_reset_text')) ->line(trans('auth.email_reset_text'))
->action(trans('auth.reset_password'), baseUrl('password/reset/' . $this->token)) ->action(trans('auth.reset_password'), baseUrl('password/reset/' . $this->token))

View File

@ -110,15 +110,19 @@ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Mail "Pretend" | Markdown Mail Settings
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| When this option is enabled, e-mail will not actually be sent over the | If you are using Markdown based email rendering, you may configure your
| web and will instead be written to your application's logs files so | theme and component paths here, allowing you to customize the design
| you may inspect the message. This is great for local development. | of the emails. Or, you may simply stick with the Laravel defaults!
| |
*/ */
'markdown' => [
'pretend' => env('MAIL_PRETEND', false), 'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
]; ];

View File

@ -2,8 +2,6 @@
if (! empty($greeting)) { if (! empty($greeting)) {
echo $greeting, "\n\n"; echo $greeting, "\n\n";
} else {
echo $level == 'error' ? 'Whoops!' : 'Hello!', "\n\n";
} }
if (! empty($introLines)) { if (! empty($introLines)) {