Fix notification nullpointer

This commit is contained in:
James Cole
2023-07-18 18:15:17 +02:00
parent f5fef8c036
commit 923debb299
7 changed files with 27 additions and 7 deletions

View File

@@ -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'];
}