Batch up files when sending to a remote node

This commit is contained in:
Deon George 2024-11-26 22:07:07 +11:00
parent 1296e3be40
commit 39034dbbb0
4 changed files with 30 additions and 6 deletions

View File

@ -203,7 +203,7 @@ class Send extends Base
} }
// Files // Files
if (($x=$ao->filesWaiting())->count()) { if (($x=$ao->getFiles())->count()) {
Log::info(sprintf('%s:- [%d] Files(s) added for sending to [%s]',self::LOGKEY,$x->count(),$ao->ftn)); Log::info(sprintf('%s:- [%d] Files(s) added for sending to [%s]',self::LOGKEY,$x->count(),$ao->ftn));
// Add Files // Add Files

View File

@ -1187,6 +1187,21 @@ class Address extends Model
return NULL; return NULL;
} }
public function getFiles(): Collection
{
if ($count=($num=$this->filesWaiting())->count()) {
Log::info(sprintf('%s:= Got [%d] files for [%s] for sending',self::LOGKEY,$count,$this->ftn));
// Limit to max messages
if ($count > $this->system->batch_files)
Log::notice(sprintf('%s:= Only sending [%d] files for [%s]',self::LOGKEY,$this->system->batch_files,$this->ftn));
return $num->take($this->system->batch_files);
}
return new Collection;
}
/** /**
* Get netmail for this node (including it's children) * Get netmail for this node (including it's children)
* *

View File

@ -32,6 +32,7 @@ class Setup extends Model
public const O_DNS = 1<<3; /* List for DNS */ public const O_DNS = 1<<3; /* List for DNS */
public const O_HIDEAKA = 1<<4; /* Hide AKAs to different Zones */ public const O_HIDEAKA = 1<<4; /* Hide AKAs to different Zones */
public const MAX_BATCH_FILES = 5;
public const MAX_MSGS_PKT = 50; public const MAX_MSGS_PKT = 50;
protected $casts = [ protected $casts = [
@ -68,6 +69,9 @@ class Setup extends Model
case 'emsi_options': case 'emsi_options':
return Arr::get($this->servers,str_replace('_','.',$key)); return Arr::get($this->servers,str_replace('_','.',$key));
case 'batch_files':
return Arr::get($this->options,$key,self::MAX_BATCH_FILES);
case 'msgs_pkt': case 'msgs_pkt':
return Arr::get($this->options,$key,self::MAX_MSGS_PKT); return Arr::get($this->options,$key,self::MAX_MSGS_PKT);

View File

@ -184,21 +184,26 @@ class System extends Model
} }
} }
public function getBatchFilesAttribute(?int $val): int
{
return $val ?: Setup::findOrFail(config('app.id'))->batch_files;
}
public function getIsOwnedAttribute(): bool public function getIsOwnedAttribute(): bool
{ {
return $this->users->count(); return $this->users->count();
} }
public function getPktMsgsAttribute(?int $val): int
{
return $val ?: Setup::findOrFail(config('app.id'))->msgs_pkt;
}
public function getLastSeenAttribute(): ?Carbon public function getLastSeenAttribute(): ?Carbon
{ {
return $this->logs_recent->first()?->created_at; return $this->logs_recent->first()?->created_at;
} }
public function getPktMsgsAttribute(?int $val): int
{
return $val ?: Setup::findOrFail(config('app.id'))->msgs_pkt;
}
/* METHODS */ /* METHODS */
public function addresses_common(): Collection public function addresses_common(): Collection