mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 10:47:00 +00:00 
			
		
		
		
	Fix notification nullpointer
This commit is contained in:
		| @@ -24,6 +24,7 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Notifications\Admin; | ||||
|  | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Bus\Queueable; | ||||
| use Illuminate\Notifications\Messages\MailMessage; | ||||
| use Illuminate\Notifications\Messages\SlackMessage; | ||||
| @@ -97,7 +98,9 @@ class TestNotification extends Notification | ||||
|      */ | ||||
|     public function via($notifiable) | ||||
|     { | ||||
|         $slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         /** @var User|null $user */ | ||||
|         $user = auth()->user(); | ||||
|         $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) { | ||||
|             return ['mail', 'slack']; | ||||
|         } | ||||
|   | ||||
| @@ -25,6 +25,7 @@ declare(strict_types=1); | ||||
| namespace FireflyIII\Notifications\Admin; | ||||
|  | ||||
| use FireflyIII\Models\InvitedUser; | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Bus\Queueable; | ||||
| use Illuminate\Notifications\Messages\MailMessage; | ||||
| use Illuminate\Notifications\Messages\SlackMessage; | ||||
| @@ -100,7 +101,9 @@ class UserInvitation extends Notification | ||||
|      */ | ||||
|     public function via($notifiable) | ||||
|     { | ||||
|         $slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         /** @var User|null $user */ | ||||
|         $user = auth()->user(); | ||||
|         $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) { | ||||
|             return ['mail', 'slack']; | ||||
|         } | ||||
|   | ||||
| @@ -98,7 +98,9 @@ class UserRegistration extends Notification | ||||
|      */ | ||||
|     public function via($notifiable) | ||||
|     { | ||||
|         $slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         /** @var User|null $user */ | ||||
|         $user = auth()->user(); | ||||
|         $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) { | ||||
|             return ['mail', 'slack']; | ||||
|         } | ||||
|   | ||||
| @@ -24,6 +24,7 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Notifications\Admin; | ||||
|  | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Bus\Queueable; | ||||
| use Illuminate\Notifications\Messages\MailMessage; | ||||
| use Illuminate\Notifications\Messages\SlackMessage; | ||||
| @@ -112,7 +113,9 @@ class VersionCheckResult extends Notification | ||||
|      */ | ||||
|     public function via($notifiable) | ||||
|     { | ||||
|         $slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         /** @var User|null $user */ | ||||
|         $user = auth()->user(); | ||||
|         $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) { | ||||
|             return ['mail', 'slack']; | ||||
|         } | ||||
|   | ||||
| @@ -25,6 +25,7 @@ declare(strict_types=1); | ||||
| namespace FireflyIII\Notifications\User; | ||||
|  | ||||
| use FireflyIII\Models\Bill; | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Bus\Queueable; | ||||
| use Illuminate\Notifications\Messages\MailMessage; | ||||
| use Illuminate\Notifications\Messages\SlackMessage; | ||||
| @@ -118,7 +119,9 @@ class BillReminder extends Notification | ||||
|      */ | ||||
|     public function via($notifiable) | ||||
|     { | ||||
|         $slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         /** @var User|null $user */ | ||||
|         $user = auth()->user(); | ||||
|         $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) { | ||||
|             return ['mail', 'slack']; | ||||
|         } | ||||
|   | ||||
| @@ -24,6 +24,7 @@ declare(strict_types=1); | ||||
|  | ||||
| namespace FireflyIII\Notifications\User; | ||||
|  | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Bus\Queueable; | ||||
| use Illuminate\Notifications\Messages\MailMessage; | ||||
| use Illuminate\Notifications\Messages\SlackMessage; | ||||
| @@ -94,7 +95,9 @@ class NewAccessToken extends Notification | ||||
|      */ | ||||
|     public function via($notifiable) | ||||
|     { | ||||
|         $slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         /** @var User|null $user */ | ||||
|         $user = auth()->user(); | ||||
|         $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) { | ||||
|             return ['mail', 'slack']; | ||||
|         } | ||||
|   | ||||
| @@ -25,6 +25,7 @@ declare(strict_types=1); | ||||
| namespace FireflyIII\Notifications\User; | ||||
|  | ||||
| use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\User; | ||||
| use Illuminate\Bus\Queueable; | ||||
| use Illuminate\Notifications\Messages\MailMessage; | ||||
| use Illuminate\Notifications\Notification; | ||||
| @@ -122,7 +123,9 @@ class UserLogin extends Notification | ||||
|      */ | ||||
|     public function via($notifiable) | ||||
|     { | ||||
|         $slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         /** @var User|null $user */ | ||||
|         $user = auth()->user(); | ||||
|         $slackUrl = null === $user ? '' : (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data; | ||||
|         if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) { | ||||
|             return ['mail', 'slack']; | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user