Add slack support to Firefly III

This commit is contained in:
James Cole
2022-09-24 12:14:27 +02:00
parent 2945f5fcde
commit 45d7042405
10 changed files with 138 additions and 17 deletions

View File

@@ -75,8 +75,9 @@ class HomeController extends Controller
foreach (config('firefly.admin_notifications') as $item) {
$notifications[$item] = FireflyConfig::get(sprintf('notification_%s', $item), true)->data;
}
$slackUrl = FireflyConfig::get('slack_webhook_url', '')->data;
return view('admin.index', compact('title', 'mainTitleIcon', 'email', 'notifications'));
return view('admin.index', compact('title', 'mainTitleIcon', 'email', 'notifications', 'slackUrl'));
}
public function notifications(Request $request): RedirectResponse
@@ -86,7 +87,14 @@ class HomeController extends Controller
if ($request->has(sprintf('notification_%s', $item))) {
$value = true;
}
FireflyConfig::set(sprintf('notification_%s',$item), $value);
FireflyConfig::set(sprintf('notification_%s', $item), $value);
}
$url = (string) $request->get('slackUrl');
if ('' === $url) {
FireflyConfig::delete('slack_webhook_url');
}
if (str_starts_with($url, 'https://hooks.slack.com/services/')) {
FireflyConfig::set('slack_webhook_url', $url);
}
session()->flash('success', (string) trans('firefly.notification_settings_saved'));