Enable per system configuration of messages per packet
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 36s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m46s
Create Docker Image / Final Docker Image Manifest (push) Successful in 9s

This commit is contained in:
Deon George 2024-06-01 16:47:13 +10:00
parent b5f22bea86
commit a098393218
6 changed files with 55 additions and 11 deletions

View File

@ -31,7 +31,7 @@ class SystemController extends Controller
public function add_edit(SystemRegisterRequest $request, System $o)
{
if ($request->validated()) {
foreach (['name','location','phone','address','port','active','method','pkt_type'] as $key)
foreach (['name','location','phone','address','port','active','method','pkt_msgs','pkt_type'] as $key)
$o->{$key} = $request->validated($key);
// Sometimes items

View File

@ -73,6 +73,7 @@ class SystemRegisterRequest extends FormRequest
'hold' => 'sometimes|boolean',
'pollmode' => 'required|integer|min:0|max:2',
'heartbeat' => 'nullable|integer|min:0|max:48',
'pkt_msgs' => 'nullable|integer|min:5',
] : []));
}
}

View File

@ -1045,15 +1045,13 @@ class Address extends Model
public function getEchomail(): ?Packet
{
if (($num=$this->echomailWaiting())->count()) {
$s = Setup::findOrFail(config('app.id'));
Log::info(sprintf('%s:= Got [%d] echomails for [%s] for sending',self::LOGKEY,$num->count(),$this->ftn));
// Limit to max messages
if ($num->count() > $s->msgs_pkt)
Log::notice(sprintf('%s:= Only sending [%d] echomails for [%s]',self::LOGKEY,$s->msgs_pkt,$this->ftn));
if ($num->count() > $this->system->msgs_pkt)
Log::notice(sprintf('%s:= Only sending [%d] echomails for [%s]',self::LOGKEY,$this->system->msgs_pkt,$this->ftn));
return $this->system->packet($this)->mail($num->take($s->msgs_pkt));
return $this->system->packet($this)->mail($num->take($this->system->msgs_pkt));
}
return NULL;
@ -1103,15 +1101,13 @@ class Address extends Model
}
if (($num=$this->netmailWaiting())->count()) {
$s = Setup::findOrFail(config('app.id'));
Log::debug(sprintf('%s:= Got [%d] netmails for [%s] for sending',self::LOGKEY,$num->count(),$this->ftn));
// Limit to max messages
if ($num->count() > $s->msgs_pkt)
if ($num->count() > $this->system->msgs_pkt)
Log::alert(sprintf('%s:= Only sending [%d] netmails for [%s]',self::LOGKEY,$num->count(),$this->ftn));
return $this->system->packet($this)->mail($num->take($s->msgs_pkt));
return $this->system->packet($this)->mail($num->take($this->system->msgs_pkt));
}
return NULL;

View File

@ -170,6 +170,11 @@ class System extends Model
}
}
public function getMsgsPktAttribute(?int $val): int
{
return $val ?: Setup::findOrFail(config('app.id'))->msgs_pkt;
}
/* METHODS */
public function echoareas()

View File

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

View File

@ -1,6 +1,6 @@
@php
use App\Classes\FTN\Packet;
use App\Models\{Mailer,User};
use App\Models\{Mailer,Setup,User};
@endphp
<!-- $o=System::class -->
@ -189,6 +189,20 @@ use App\Models\{Mailer,User};
</span>
</div>
</div>
<!-- Packet Msgs -->
<div class="col-2">
<label for="pkt_msgs" class="form-label w-100">Packet Msgs</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-hash"></i></span>
<input type="text" class="form-control text-end @error('pkt_msgs') is-invalid @enderror" id="pkt_msgs" placeholder="{{ Setup::MAX_MSGS_PKT }}" name="pkt_msgs" value="{{ old('pkt_msgs',$o->pkt_msgs) }}" @cannot($action,$o)readonly @endcannot>
<span class="invalid-feedback" role="alert">
@error('pkt_msgs')
{{ $message }}
@enderror
</span>
</div>
</div>
</div>
</div>
</div>