Set packed boolean when packing Netmail's is successful

This commit is contained in:
Deon George 2021-08-16 22:30:34 +10:00
parent 628293c741
commit 5bf612e5b4
3 changed files with 10 additions and 5 deletions

View File

@ -107,6 +107,8 @@ class Message extends FTNBase
private Collection $via; // The path the message has gone using Via lines (Netmail) private Collection $via; // The path the message has gone using Via lines (Netmail)
private Collection $unknown; // Temporarily hold attributes we have no logic for. private Collection $unknown; // Temporarily hold attributes we have no logic for.
public bool $packed = FALSE; // Has the message been packed successfully
// Convert characters into printable chars // Convert characters into printable chars
// https://int10h.org/oldschool-pc-fonts/readme/#437_charset // https://int10h.org/oldschool-pc-fonts/readme/#437_charset
private const CP437 = [ private const CP437 = [
@ -157,6 +159,7 @@ class Message extends FTNBase
{ {
$this->domain = $domain; $this->domain = $domain;
$this->header = [];
$this->kludge = collect(); $this->kludge = collect();
$this->msgid = ''; $this->msgid = '';
@ -392,9 +395,7 @@ class Message extends FTNBase
*/ */
public function __toString(): string public function __toString(): string
{ {
$return = ''; $return = pack(collect(self::header)->pluck(1)->join(''),
$return .= pack(collect(self::header)->pluck(1)->join(''),
$this->ff, $this->ff,
$this->tf, $this->tf,
$this->fn, $this->fn,

View File

@ -254,8 +254,10 @@ class Packet extends FTNBase
if (is_null($return)) { if (is_null($return)) {
$return = $this->createHeader(); $return = $this->createHeader();
foreach ($this->messages as $o) foreach ($this->messages as $o) {
if ($o->packed)
$return .= "\02\00".(string)$o; $return .= "\02\00".(string)$o;
}
$return .= "\00\00"; $return .= "\00\00";
} }

View File

@ -96,6 +96,8 @@ final class Netmail extends Model implements Packet
$o->via = $via; $o->via = $via;
$o->packed = TRUE;
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error(sprintf('%s:Error converting netmail [%s] to a message (%d:%s)',self::LOGKEY,$this->id,$e->getLine(),$e->getMessage())); Log::error(sprintf('%s:Error converting netmail [%s] to a message (%d:%s)',self::LOGKEY,$this->id,$e->getLine(),$e->getMessage()));
dump($this); dump($this);