Expand test notification framework.

This commit is contained in:
James Cole
2024-12-08 16:28:22 +01:00
parent c06fb8daf6
commit 2f7a1c941e
15 changed files with 509 additions and 70 deletions

View File

@@ -54,6 +54,8 @@ use FireflyIII\Notifications\Admin\TestNotification;
use FireflyIII\Notifications\Admin\UserInvitation;
use FireflyIII\Notifications\Admin\UserRegistration;
use FireflyIII\Notifications\Admin\VersionCheckResult;
use FireflyIII\Notifications\Test\TestNotificationDiscord;
use FireflyIII\Notifications\Test\TestNotificationSlack;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -399,7 +401,7 @@ class User extends Authenticatable
/**
* Route notifications for the Slack channel.
*/
public function routeNotificationForSlack(Notification $notification): string
public function routeNotificationForSlack(Notification $notification): ?string
{
// this check does not validate if the user is owner, Should be done by notification itself.
$res = app('fireflyconfig')->get('slack_webhook_url', '')->data;
@@ -407,9 +409,19 @@ class User extends Authenticatable
$res = '';
}
$res = (string)$res;
if ($notification instanceof TestNotification) {
// not the best way to do this, but alas.
if ($notification instanceof TestNotificationSlack) {
return $res;
}
if ($notification instanceof TestNotificationDiscord) {
$res = app('fireflyconfig')->get('discord_webhook_url', '')->data;
if (is_array($res)) {
$res = '';
}
return (string)$res;
}
if ($notification instanceof UserInvitation) {
return $res;
}