Sending Mail now dynamically creates packet name, size and mtime

This commit is contained in:
2023-07-14 20:03:09 +10:00
parent 28101237e8
commit 7bf957df3a
5 changed files with 35 additions and 13 deletions

View File

@@ -18,9 +18,6 @@ class Mail extends Item
switch ($action) {
case self::I_SEND:
$this->file = $mail;
$this->file_name = sprintf('%s.pkt',$mail->name);
$this->file_size = strlen($mail);
$this->file_mtime = Carbon::now()->timestamp; // @todo This timestamp should be consistent incase of retries
break;
@@ -31,8 +28,21 @@ class Mail extends Item
$this->action = $action;
}
public function __get($key) {
switch ($key) {
case 'file': return $this->file;
default:
return parent::__get($key);
}
}
public function read(int $start,int $length): string
{
return substr((string)$this->file,$start,$length);
}
public function youngest(): Carbon
{
return $this->file->messages->pluck('date')->sort()->last();
}
}