diff --git a/app/Classes/File/Send.php b/app/Classes/File/Send.php index 5e2fdd5..cc6214b 100644 --- a/app/Classes/File/Send.php +++ b/app/Classes/File/Send.php @@ -226,15 +226,19 @@ final class Send extends Item * Add our mail to the send queue * * @param Address $ao + * @return bool * @throws Exception * @todo We need to make this into a transaction, incase the transfer fails. */ - public function mail(Address $ao): void + public function mail(Address $ao): bool { + $mail = FALSE; + // If the node is marked as hold - dont send any mail. if ($ao->system->hold) { Log::info(sprintf('%s: - System [%d] mail is marked as hold - not checking for mail.',self::LOGKEY,$ao->system_id)); - return; + + return FALSE; } // Netmail @@ -242,6 +246,7 @@ final class Send extends Item Log::debug(sprintf('%s: - Netmail(s) added for sending to [%s]',self::LOGKEY,$ao->ftn)); $this->packets->push(new Mail($x,self::I_SEND)); + $mail = TRUE; } // Echomail @@ -249,7 +254,10 @@ final class Send extends Item Log::debug(sprintf('%s: - Echomail(s) added for sending to [%s]',self::LOGKEY,$ao->ftn)); $this->packets->push(new Mail($x,self::I_SEND)); + $mail = TRUE; } + + return $mail; } /** diff --git a/app/Classes/Protocol/EMSI.php b/app/Classes/Protocol/EMSI.php index 82722eb..194ab72 100644 --- a/app/Classes/Protocol/EMSI.php +++ b/app/Classes/Protocol/EMSI.php @@ -1177,14 +1177,14 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface // Add our mail to the queue if we have authenticated if ($this->node->aka_authed) foreach ($this->node->aka_remote_authed as $ao) { - $this->send->mail($ao); + while ($this->send->mail($ao)) { + $z = new Zmodem; + + if (! $z->zmodem_sendinit($this->client,$zap) && $this->send->total_count) + $z->zmodem_sendfile($this->send); + } } - $z = new Zmodem; - - if (! $z->zmodem_sendinit($this->client,$zap) && $this->send->total_count) - $z->zmodem_sendfile($this->send); - Log::debug(sprintf('%s:- Finished sending',self::LOGKEY)); return ($z->zmodem_senddone()<0); }