Enable per system configuration of messages per packet

This commit is contained in:
2024-06-01 16:47:13 +10:00
parent 0bc3d4cf60
commit 1d354da6e3
6 changed files with 57 additions and 13 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->pkt_msgs)
Log::notice(sprintf('%s:= Only sending [%d] echomails for [%s]',self::LOGKEY,$this->system->pkt_msgs,$this->ftn));
return $this->system->packet($this)->mail($num->take($s->msgs_pkt));
return $this->system->packet($this)->mail($num->take($this->system->pkt_msgs));
}
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)
Log::alert(sprintf('%s:= Only sending [%d] netmails for [%s]',self::LOGKEY,$num->count(),$this->ftn));
if ($num->count() > $this->system->pkt_msgs)
Log::alert(sprintf('%s:= Only sending [%d] netmails for [%s]',self::LOGKEY,$this->system->pkt_msgs,$this->ftn));
return $this->system->packet($this)->mail($num->take($s->msgs_pkt));
return $this->system->packet($this)->mail($num->take($this->system->pkt_msgs));
}
return NULL;
@@ -1145,7 +1141,7 @@ class Address extends Model
$c = 0;
foreach ($msgs as $oo) {
// Only bundle up to max messages
if (++$c > $s->msgs_pkt)
if (++$c > $s->pkt_msgs)
break;
$o->addMail($oo->packet($this,$passwd));

View File

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