Enable system mail hold

This commit is contained in:
Deon George 2022-01-15 22:38:45 +11:00
parent 6f1d47a6ab
commit c7e6bb2575
6 changed files with 60 additions and 3 deletions

View File

@ -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));

View File

@ -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();

View File

@ -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',

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class SystemMailHold extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('systems', function (Blueprint $table) {
$table->boolean('hold')->default(FALSE);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('systems', function (Blueprint $table) {
$table->dropColumn(['hold']);
});
}
}

View File

@ -31,7 +31,7 @@
@foreach (\App\Models\SystemZone::select('*')->with(['system','zone.domain'])->get() as $oo)
<tr>
<td>{{ $oo->zone->domain->name }}</td>
<td><a href="{{ url('ftn/system/addedit',[$oo->system_id]) }}">{{ $oo->system_id }}</a></td>
<td><a href="{{ url('ftn/system/addedit',[$oo->system_id]) }}">{{ $oo->system_id }}</a>@if($oo->system->hold)<span class="float-end"><i class="text-danger bi bi-stop-circle"></i></span>@endif</td>
<td>{{ $oo->system->name }}</td>
<td>{{ $oo->system->sysop }}</td>
<td>{{ $oo->system->location }}</td>

View File

@ -37,8 +37,26 @@
@endif
</div>
<!-- Hold -->
<div class="col-2">
@if($o->exists)
@can('update',$o)
<label for="hold" class="form-label">Hold Mail</label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="hold" id="hold_yes" value="1" required @if(old('hold',$o->hold))checked @endif>
<label class="btn btn-outline-success" for="hold_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="hold" id="hold_no" value="0" required @if(! old('hold',$o->hold))checked @endif>
<label class="btn btn-outline-danger" for="hold_no">No</label>
</div>
</div>
@endcan
@endif
</div>
<!-- ZeroTier ID -->
<div class="offset-3 col-3">
<div class="offset-1 col-3">
<label for="zt_id" class="form-label">ZeroTier ID</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-shield-lock-fill"></i></span>