Clean up code.

This commit is contained in:
James Cole
2024-12-14 07:22:46 +01:00
parent b3560ff525
commit 5f1502eea7
30 changed files with 432 additions and 505 deletions

View File

@@ -31,27 +31,6 @@ use NotificationChannels\Pushover\PushoverReceiver;
class OwnerNotifiable
{
public function routeNotificationForSlack(): string
{
$res = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
if (is_array($res)) {
$res = '';
}
return (string) $res;
}
public function routeNotificationForPushover()
{
Log::debug('Return settings for routeNotificationForPushover');
$pushoverAppToken = (string) app('fireflyconfig')->getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
return PushoverReceiver::withUserKey($pushoverUserToken)
->withApplicationToken($pushoverAppToken)
;
}
/**
* Get the notification routing information for the given driver.
*
@@ -62,7 +41,7 @@ class OwnerNotifiable
*/
public function routeNotificationFor($driver, $notification = null)
{
$method = 'routeNotificationFor'.Str::studly($driver);
$method = 'routeNotificationFor' . Str::studly($driver);
if (method_exists($this, $method)) {
Log::debug(sprintf('Redirect for settings to "%s".', $method));
@@ -75,4 +54,24 @@ class OwnerNotifiable
default => null,
};
}
public function routeNotificationForPushover()
{
Log::debug('Return settings for routeNotificationForPushover');
$pushoverAppToken = (string) app('fireflyconfig')->getEncrypted('pushover_app_token', '')->data;
$pushoverUserToken = (string) app('fireflyconfig')->getEncrypted('pushover_user_token', '')->data;
return PushoverReceiver::withUserKey($pushoverUserToken)
->withApplicationToken($pushoverAppToken);
}
public function routeNotificationForSlack(): string
{
$res = app('fireflyconfig')->getEncrypted('slack_webhook_url', '')->data;
if (is_array($res)) {
$res = '';
}
return (string) $res;
}
}