EMSI Continue sending mail until no more mail to send

This commit is contained in:
Deon George 2022-12-03 01:09:41 +11:00
parent e78b5975b0
commit 09fe65a8db
2 changed files with 16 additions and 8 deletions

View File

@ -226,15 +226,19 @@ final class Send extends Item
* Add our mail to the send queue * Add our mail to the send queue
* *
* @param Address $ao * @param Address $ao
* @return bool
* @throws Exception * @throws Exception
* @todo We need to make this into a transaction, incase the transfer fails. * @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 the node is marked as hold - dont send any mail.
if ($ao->system->hold) { if ($ao->system->hold) {
Log::info(sprintf('%s: - System [%d] mail is marked as hold - not checking for mail.',self::LOGKEY,$ao->system_id)); Log::info(sprintf('%s: - System [%d] mail is marked as hold - not checking for mail.',self::LOGKEY,$ao->system_id));
return;
return FALSE;
} }
// Netmail // 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)); Log::debug(sprintf('%s: - Netmail(s) added for sending to [%s]',self::LOGKEY,$ao->ftn));
$this->packets->push(new Mail($x,self::I_SEND)); $this->packets->push(new Mail($x,self::I_SEND));
$mail = TRUE;
} }
// Echomail // 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)); Log::debug(sprintf('%s: - Echomail(s) added for sending to [%s]',self::LOGKEY,$ao->ftn));
$this->packets->push(new Mail($x,self::I_SEND)); $this->packets->push(new Mail($x,self::I_SEND));
$mail = TRUE;
} }
return $mail;
} }
/** /**

View File

@ -1177,13 +1177,13 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
// Add our mail to the queue if we have authenticated // Add our mail to the queue if we have authenticated
if ($this->node->aka_authed) if ($this->node->aka_authed)
foreach ($this->node->aka_remote_authed as $ao) { foreach ($this->node->aka_remote_authed as $ao) {
$this->send->mail($ao); while ($this->send->mail($ao)) {
}
$z = new Zmodem; $z = new Zmodem;
if (! $z->zmodem_sendinit($this->client,$zap) && $this->send->total_count) if (! $z->zmodem_sendinit($this->client,$zap) && $this->send->total_count)
$z->zmodem_sendfile($this->send); $z->zmodem_sendfile($this->send);
}
}
Log::debug(sprintf('%s:- Finished sending',self::LOGKEY)); Log::debug(sprintf('%s:- Finished sending',self::LOGKEY));
return ($z->zmodem_senddone()<0); return ($z->zmodem_senddone()<0);