Batch up files when sending to a remote node
This commit is contained in:
parent
1296e3be40
commit
39034dbbb0
@ -203,7 +203,7 @@ class Send extends Base
|
||||
}
|
||||
|
||||
// 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));
|
||||
|
||||
// Add Files
|
||||
|
@ -1187,6 +1187,21 @@ class Address extends Model
|
||||
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)
|
||||
*
|
||||
|
@ -32,6 +32,7 @@ class Setup extends Model
|
||||
public const O_DNS = 1<<3; /* List for DNS */
|
||||
public const O_HIDEAKA = 1<<4; /* Hide AKAs to different Zones */
|
||||
|
||||
public const MAX_BATCH_FILES = 5;
|
||||
public const MAX_MSGS_PKT = 50;
|
||||
|
||||
protected $casts = [
|
||||
@ -68,6 +69,9 @@ class Setup extends Model
|
||||
case 'emsi_options':
|
||||
return Arr::get($this->servers,str_replace('_','.',$key));
|
||||
|
||||
case 'batch_files':
|
||||
return Arr::get($this->options,$key,self::MAX_BATCH_FILES);
|
||||
|
||||
case 'msgs_pkt':
|
||||
return Arr::get($this->options,$key,self::MAX_MSGS_PKT);
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
return $this->users->count();
|
||||
}
|
||||
|
||||
public function getPktMsgsAttribute(?int $val): int
|
||||
{
|
||||
return $val ?: Setup::findOrFail(config('app.id'))->msgs_pkt;
|
||||
}
|
||||
|
||||
public function getLastSeenAttribute(): ?Carbon
|
||||
{
|
||||
return $this->logs_recent->first()?->created_at;
|
||||
}
|
||||
|
||||
public function getPktMsgsAttribute(?int $val): int
|
||||
{
|
||||
return $val ?: Setup::findOrFail(config('app.id'))->msgs_pkt;
|
||||
}
|
||||
|
||||
/* METHODS */
|
||||
|
||||
public function addresses_common(): Collection
|
||||
|
Loading…
Reference in New Issue
Block a user