Jelajahi Sumber

Fixed DRU notification location

Will Browning 3 tahun lalu
induk
melakukan
aca8a64d10

+ 2 - 2
app/Http/Controllers/DefaultRecipientController.php

@@ -23,12 +23,12 @@ class DefaultRecipientController extends Controller
     {
     {
         $recipient = user()->verifiedRecipients()->findOrFail($request->default_recipient);
         $recipient = user()->verifiedRecipients()->findOrFail($request->default_recipient);
 
 
-        $currentDefaultRecipient = user()->email;
+        $currentDefaultRecipient = user()->defaultRecipient;
 
 
         user()->default_recipient = $recipient;
         user()->default_recipient = $recipient;
         user()->save();
         user()->save();
 
 
-        user()->notify(new DefaultRecipientUpdated($currentDefaultRecipient));
+        $currentDefaultRecipient->notify(new DefaultRecipientUpdated($recipient->email));
 
 
         return back()->with(['status' => 'Default Recipient Updated Successfully']);
         return back()->with(['status' => 'Default Recipient Updated Successfully']);
     }
     }

+ 8 - 9
app/Notifications/DefaultRecipientUpdated.php

@@ -14,16 +14,16 @@ class DefaultRecipientUpdated extends Notification implements ShouldQueue, Shoul
 {
 {
     use Queueable;
     use Queueable;
 
 
-    protected $previousDefaultRecipient;
+    protected $newDefaultRecipient;
 
 
     /**
     /**
      * Create a new notification instance.
      * Create a new notification instance.
      *
      *
      * @return void
      * @return void
      */
      */
-    public function __construct($previousDefaultRecipient)
+    public function __construct($newDefaultRecipient)
     {
     {
-        $this->previousDefaultRecipient = $previousDefaultRecipient;
+        $this->newDefaultRecipient = $newDefaultRecipient;
     }
     }
 
 
     /**
     /**
@@ -46,8 +46,7 @@ class DefaultRecipientUpdated extends Notification implements ShouldQueue, Shoul
     public function toMail($notifiable)
     public function toMail($notifiable)
     {
     {
         $openpgpsigner = null;
         $openpgpsigner = null;
-        $recipient = $notifiable->defaultRecipient;
-        $fingerprint = $recipient->should_encrypt ? $recipient->fingerprint : null;
+        $fingerprint = $notifiable->should_encrypt ? $notifiable->fingerprint : null;
 
 
         if ($fingerprint) {
         if ($fingerprint) {
             try {
             try {
@@ -57,17 +56,17 @@ class DefaultRecipientUpdated extends Notification implements ShouldQueue, Shoul
                 info($e->getMessage());
                 info($e->getMessage());
                 $openpgpsigner = null;
                 $openpgpsigner = null;
 
 
-                $recipient->update(['should_encrypt' => false]);
+                $notifiable->update(['should_encrypt' => false]);
 
 
-                $recipient->notify(new GpgKeyExpired);
+                $notifiable->notify(new GpgKeyExpired);
             }
             }
         }
         }
 
 
         return (new MailMessage)
         return (new MailMessage)
             ->subject("Your default recipient has just been updated")
             ->subject("Your default recipient has just been updated")
             ->markdown('mail.default_recipient_updated', [
             ->markdown('mail.default_recipient_updated', [
-                'previousDefaultRecipient' => $this->previousDefaultRecipient,
-                'defaultRecipient' => $notifiable->email
+                'defaultRecipient' => $notifiable->email,
+                'newDefaultRecipient' => $this->newDefaultRecipient
             ])
             ])
             ->withSwiftMessage(function ($message) use ($openpgpsigner) {
             ->withSwiftMessage(function ($message) use ($openpgpsigner) {
                 $message->getHeaders()
                 $message->getHeaders()

+ 1 - 1
resources/views/mail/default_recipient_updated.blade.php

@@ -2,7 +2,7 @@
 
 
 # Default Recipient Updated
 # Default Recipient Updated
 
 
-Your account's default recipient has just been updated from **{{ $previousDefaultRecipient }}** to **{{ $defaultRecipient }}**.
+Your account's default recipient has just been updated from **{{ $defaultRecipient }}** to **{{ $newDefaultRecipient }}**.
 
 
 If this change was not made by you, please visit the settings page, log out of all other browser sessions and update your account's password.
 If this change was not made by you, please visit the settings page, log out of all other browser sessions and update your account's password.