fix: notifications

This commit is contained in:
James Cole
2023-07-17 20:33:26 +02:00
parent 2bb4cc7954
commit 788dae1477
34 changed files with 192 additions and 99 deletions

View File

@@ -97,6 +97,10 @@ class TestNotification extends Notification
*/
public function via($notifiable)
{
return ['mail', 'slack'];
$slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -100,6 +100,10 @@ class UserInvitation extends Notification
*/
public function via($notifiable)
{
return ['mail', 'slack'];
$slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -98,6 +98,10 @@ class UserRegistration extends Notification
*/
public function via($notifiable)
{
return ['mail', 'slack'];
$slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}

View File

@@ -87,14 +87,14 @@ class VersionCheckResult extends Notification
public function toSlack($notifiable)
{
// return (new SlackMessage())->text($this->message)
// ->sectionBlock(function (SectionBlock $block) {
// $button = new ButtonElement('Button');
// $button->url('https://github.com/firefly-iii/firefly-iii/releases');
// $block->accessory($button);
// });
//// ->attachment(function ($attachment) {
//// $attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');
//// });
// ->sectionBlock(function (SectionBlock $block) {
// $button = new ButtonElement('Button');
// $button->url('https://github.com/firefly-iii/firefly-iii/releases');
// $block->accessory($button);
// });
//// ->attachment(function ($attachment) {
//// $attachment->title('Firefly III @ GitHub', 'https://github.com/firefly-iii/firefly-iii/releases');
//// });
return (new SlackMessage())->content($this->message)
@@ -112,6 +112,10 @@ class VersionCheckResult extends Notification
*/
public function via($notifiable)
{
return ['mail', 'slack'];
$slackUrl = (string)app('preferences')->getForUser(auth()->user(), 'slack_webhook_url', '')->data;
if (str_starts_with($slackUrl, 'https://hooks.slack.com/services/')) {
return ['mail', 'slack'];
}
return ['mail'];
}
}