]> BookStack Code Mirror - bookstack/commitdiff
Re-enabled plaintext view for email notifications
authorDan Brown <redacted>
Sun, 16 Dec 2018 20:44:57 +0000 (20:44 +0000)
committerDan Brown <redacted>
Sun, 16 Dec 2018 20:44:57 +0000 (20:44 +0000)
Updated mail notifications to set the HTML and plaintext views since before
no plaintext version was being created.

Closes #1182

app/Notifications/ConfirmEmail.php
app/Notifications/MailNotification.php [new file with mode: 0644]
app/Notifications/ResetPassword.php
config/mail.php
resources/views/vendor/notifications/email-plain.blade.php

index f3797e6e228874559439de231fba034fd48d45af..7ecadc298f1f4042a7b887584ca6820bec7bb926 100644 (file)
@@ -1,17 +1,7 @@
-<?php
+<?php namespace BookStack\Notifications;
 
-namespace BookStack\Notifications;
-
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-
-class ConfirmEmail extends Notification implements ShouldQueue
+class ConfirmEmail extends MailNotification
 {
-
-    use Queueable;
-    
     public $token;
 
     /**
@@ -23,17 +13,6 @@ class ConfirmEmail extends Notification implements ShouldQueue
         $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.
      *
@@ -43,10 +22,10 @@ class ConfirmEmail extends Notification implements ShouldQueue
     public function toMail($notifiable)
     {
         $appName = ['appName' => setting('app-name')];
-        return (new MailMessage)
-                    ->subject(trans('auth.email_confirm_subject', $appName))
-                    ->greeting(trans('auth.email_confirm_greeting', $appName))
-                    ->line(trans('auth.email_confirm_text'))
-                    ->action(trans('auth.email_confirm_action'), baseUrl('/register/confirm/' . $this->token));
+        return $this->newMailMessage()
+                ->subject(trans('auth.email_confirm_subject', $appName))
+                ->greeting(trans('auth.email_confirm_greeting', $appName))
+                ->line(trans('auth.email_confirm_text'))
+                ->action(trans('auth.email_confirm_action'), baseUrl('/register/confirm/' . $this->token));
     }
 }
diff --git a/app/Notifications/MailNotification.php b/app/Notifications/MailNotification.php
new file mode 100644 (file)
index 0000000..413ac6d
--- /dev/null
@@ -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'
+        ]);
+    }
+
+}
\ No newline at end of file
index 86e93228f857a64ed5965126cfd0958180665fba..282aa335a07aed35b52c4ad2520565d567ca217f 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php namespace BookStack\Notifications;
 
-namespace BookStack\Notifications;
 
-use Illuminate\Notifications\Messages\MailMessage;
-use Illuminate\Notifications\Notification;
-
-class ResetPassword extends Notification
+class ResetPassword extends MailNotification
 {
     /**
      * The password reset token.
@@ -24,17 +20,6 @@ class ResetPassword extends Notification
         $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.
      *
@@ -42,7 +27,7 @@ class ResetPassword extends Notification
      */
     public function toMail()
     {
-        return (new MailMessage)
+            return $this->newMailMessage()
             ->subject(trans('auth.email_reset_subject', ['appName' => setting('app-name')]))
             ->line(trans('auth.email_reset_text'))
             ->action(trans('auth.reset_password'), baseUrl('password/reset/' . $this->token))
index 689be99b8f2385ba19b60b2c489bf917f0601ce1..a5aff0239886ed285417f48ad0d80ebbf0b595e2 100644 (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
-    | web and will instead be written to your application's logs files so
-    | you may inspect the message. This is great for local development.
+    | If you are using Markdown based email rendering, you may configure your
+    | theme and component paths here, allowing you to customize the design
+    | of the emails. Or, you may simply stick with the Laravel defaults!
     |
     */
-
-    'pretend' => env('MAIL_PRETEND', false),
+    'markdown' => [
+        'theme' => 'default',
+        'paths' => [
+            resource_path('views/vendor/mail'),
+        ],
+    ],
 
 ];
index 7ca1dc8d0312206acc205135560c6dff02443abd..d8e2a0acdba5ddf89b24b5cd591e8b71cbdea065 100644 (file)
@@ -2,8 +2,6 @@
 
 if (! empty($greeting)) {
     echo $greeting, "\n\n";
-} else {
-    echo $level == 'error' ? 'Whoops!' : 'Hello!', "\n\n";
 }
 
 if (! empty($introLines)) {