From c7e6bb25751833e1201ee60f244da6f691faafcf Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 15 Jan 2022 22:38:45 +1100 Subject: [PATCH] Enable system mail hold --- app/Classes/File/Send.php | 6 ++++ app/Http/Controllers/SystemController.php | 2 +- app/Http/Requests/SystemRegister.php | 1 + .../2022_01_15_112024_system_mail_hold.php | 32 +++++++++++++++++++ resources/views/system/ours.blade.php | 2 +- .../views/system/widget/form-system.blade.php | 20 +++++++++++- 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 database/migrations/2022_01_15_112024_system_mail_hold.php diff --git a/app/Classes/File/Send.php b/app/Classes/File/Send.php index cba62f2..0eb71ce 100644 --- a/app/Classes/File/Send.php +++ b/app/Classes/File/Send.php @@ -230,6 +230,12 @@ final class Send extends Item */ public function mail(Address $ao): void { + // If the node is marked as hold - dont send any mail. + if ($ao->system->hold) { + Log::info(sprintf('%s: - System [%d] mail is marked as hold - not checking for mail.',self::LOGKEY,$ao->system_id)); + return; + } + // Netmail if ($x=$ao->getNetmail()) { Log::debug(sprintf('%s: - Netmail(s) added for sending to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 300f43e..4794252 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -258,7 +258,7 @@ class SystemController extends Controller public function add_edit(SystemRegister $request,System $o) { if ($request->post()) { - foreach (['name','location','sysop','phone','address','port','active','method','notes','mailer_type','mailer_address','mailer_port','zt_id'] as $key) + foreach (['name','location','sysop','hold','phone','address','port','active','method','notes','mailer_type','mailer_address','mailer_port','zt_id'] as $key) $o->{$key} = $request->post($key); $o->save(); diff --git a/app/Http/Requests/SystemRegister.php b/app/Http/Requests/SystemRegister.php index 8203de2..70fe914 100644 --- a/app/Http/Requests/SystemRegister.php +++ b/app/Http/Requests/SystemRegister.php @@ -46,6 +46,7 @@ class SystemRegister extends FormRequest ], ($this->so->exists || ($request->action != 'create')) ? [ 'location' => 'required|min:3', + 'hold' => 'required|boolean', 'sysop' => 'required|min:3', 'phone' => 'nullable|regex:/^([0-9-]+)$/', 'address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i', diff --git a/database/migrations/2022_01_15_112024_system_mail_hold.php b/database/migrations/2022_01_15_112024_system_mail_hold.php new file mode 100644 index 0000000..f1798a1 --- /dev/null +++ b/database/migrations/2022_01_15_112024_system_mail_hold.php @@ -0,0 +1,32 @@ +boolean('hold')->default(FALSE); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('systems', function (Blueprint $table) { + $table->dropColumn(['hold']); + }); + } +} diff --git a/resources/views/system/ours.blade.php b/resources/views/system/ours.blade.php index d43fd7b..3f41d38 100644 --- a/resources/views/system/ours.blade.php +++ b/resources/views/system/ours.blade.php @@ -31,7 +31,7 @@ @foreach (\App\Models\SystemZone::select('*')->with(['system','zone.domain'])->get() as $oo) {{ $oo->zone->domain->name }} - {{ $oo->system_id }} + {{ $oo->system_id }}@if($oo->system->hold)@endif {{ $oo->system->name }} {{ $oo->system->sysop }} {{ $oo->system->location }} diff --git a/resources/views/system/widget/form-system.blade.php b/resources/views/system/widget/form-system.blade.php index 78fd127..e58ed08 100644 --- a/resources/views/system/widget/form-system.blade.php +++ b/resources/views/system/widget/form-system.blade.php @@ -37,8 +37,26 @@ @endif + +
+ @if($o->exists) + @can('update',$o) + +
+
+ hold))checked @endif> + + + hold))checked @endif> + +
+
+ @endcan + @endif +
+ -
+