-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: settings for notifications (#61)
* Add settings to enable/disable operation notification types Several users have requested the ability to reduce the number of notifications sent via the calendar. This commit adds the ability to globally disable each type of notification: create/post, update/edit, cancel, activate, end. * Allow configuring intervals for operation pings This addresses one of the top comments in issues reported to the calendar: allow admins to control when and how often operations are pinged out. Closes #22
- Loading branch information
1 parent
3ddf302
commit ee71122
Showing
11 changed files
with
215 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of SeAT | ||
* | ||
* Copyright (C) 2022 Alkari Verende | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program; if not, write to the Free Software Foundation, Inc., | ||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
*/ | ||
|
||
namespace Seat\Kassie\Calendar\Http\Validation; | ||
|
||
use Illuminate\Foundation\Http\FormRequest; | ||
|
||
/** | ||
* Class Settings. | ||
* | ||
* @package Seat\Kassie\Calendar\Validation | ||
*/ | ||
class SettingsValidation extends FormRequest | ||
{ | ||
/** | ||
* Authorize the request by default. | ||
* | ||
* @return bool | ||
*/ | ||
public function authorize() | ||
{ | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Get the validation rules that apply to the request. | ||
* | ||
* @return array | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
'slack_integration' => ['boolean'], | ||
'slack_integration_default_channel' => ['nullable', 'exists:integrations,id'], | ||
'slack_emoji_importance_full' => ['nullable', 'string'], | ||
'slack_emoji_importance_half' => ['nullable', 'string'], | ||
'slack_emoji_importance_empty' => ['nullable', 'string'], | ||
'notify_operation_interval' => ['nullable', 'string'], | ||
'notify_create_operation' => ['boolean'], | ||
'notify_update_operation' => ['boolean'], | ||
'notify_cancel_operation' => ['boolean'], | ||
'notify_activate_operation' => ['boolean'], | ||
'notify_end_operation' => ['boolean'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/database/migrations/2021_12_31_213410_default_notification_settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
use Seat\Services\Models\GlobalSetting; | ||
|
||
class DefaultNotificationSettings extends Migration | ||
{ | ||
const DEFAULT_SETTINGS = [ | ||
'kassie.calendar.notify_create_operation' => true, | ||
'kassie.calendar.notify_update_operation' => true, | ||
'kassie.calendar.notify_cancel_operation' => true, | ||
'kassie.calendar.notify_activate_operation' => true, | ||
'kassie.calendar.notify_end_operation' => true, | ||
'kassie.calendar.notify_operation_interval' => '15,30,60', | ||
]; | ||
|
||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
foreach (self::DEFAULT_SETTINGS as $name => $value) { | ||
setting([$name, $value], true); | ||
} | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
GlobalSetting::whereIn('name', array_keys(self::DEFAULT_SETTINGS))->delete(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters