Enable us to create an outbound packet without updating send details. Determine the send address for packets earlier
This commit is contained in:
parent
d930c410dc
commit
421cd565bd
@ -95,7 +95,11 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
return (! is_null($this->key())) && ($this->use_cache ? Cache::has($this->key()) : $this->messages->has($this->key()));
|
||||
}
|
||||
|
||||
public function __construct(Address $o=NULL)
|
||||
/**
|
||||
* @param Address|NULL $oo Origin Address
|
||||
* @param Address|NULL $o Destination Address
|
||||
*/
|
||||
public function __construct(Address $oo=NULL,Address $o=NULL)
|
||||
{
|
||||
$this->messages = collect();
|
||||
$this->errors = collect();
|
||||
@ -103,8 +107,8 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
$this->name = sprintf('%08x',timew());
|
||||
|
||||
// If we are creating an outbound packet, we need to set our header
|
||||
if ($o)
|
||||
$this->newHeader($o);
|
||||
if ($oo && $o)
|
||||
$this->newHeader($oo,$o);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -384,16 +388,16 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
/**
|
||||
* When creating a new packet, set the header.
|
||||
*
|
||||
* @param Address $oo
|
||||
* @param Address $o
|
||||
*/
|
||||
private function newHeader(Address $o): void
|
||||
private function newHeader(Address $oo,Address $o): void
|
||||
{
|
||||
$date = Carbon::now();
|
||||
$ao = Setup::findOrFail(config('app.id'))->system->match($o->zone)->first();
|
||||
|
||||
// Create Header
|
||||
$this->header = [
|
||||
'onode' => $ao->node_id, // Originating Node
|
||||
'onode' => $oo->node_id, // Originating Node
|
||||
'dnode' => $o->node_id, // Destination Node
|
||||
'y' => $date->format('Y'), // Year
|
||||
'm' => $date->format('m')-1, // Month
|
||||
@ -401,14 +405,14 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
||||
'H' => $date->format('H'), // Hour
|
||||
'M' => $date->format('i'), // Minute
|
||||
'S' => $date->format('s'), // Second
|
||||
'onet' => $ao->host_id ?: $ao->region_id, // Originating Net (0xffff when origPoint !=0 2+)
|
||||
'onet' => $oo->host_id ?: $oo->region_id, // Originating Net (0xffff when origPoint !=0 2+)
|
||||
'dnet' => $o->host_id ?: $o->region_id, // Destination Net
|
||||
'password' => $o->session('pktpass'), // Packet Password
|
||||
'qozone' => $ao->zone->zone_id,
|
||||
'qozone' => $oo->zone->zone_id,
|
||||
'qdzone' => $o->zone->zone_id,
|
||||
'ozone' => $ao->zone->zone_id, // Originating Zone (Not used 2)
|
||||
'ozone' => $oo->zone->zone_id, // Originating Zone (Not used 2)
|
||||
'dzone' => $o->zone->zone_id, // Destination Zone (Not used 2)
|
||||
'opoint' => $ao->point_id, // Originating Point (Not used 2)
|
||||
'opoint' => $oo->point_id, // Originating Point (Not used 2)
|
||||
'dpoint' => $o->point_id, // Destination Point (Not used 2)
|
||||
];
|
||||
}
|
||||
|
@ -371,9 +371,10 @@ class Address extends Model
|
||||
/**
|
||||
* Get echomail for this node
|
||||
*
|
||||
* @param bool $update
|
||||
* @return Packet|null
|
||||
*/
|
||||
public function getEchomail(): ?Packet
|
||||
public function getEchomail(bool $update=TRUE): ?Packet
|
||||
{
|
||||
$pkt = NULL;
|
||||
|
||||
@ -382,13 +383,14 @@ class Address extends Model
|
||||
{
|
||||
$pkt = $this->getPacket($x);
|
||||
|
||||
DB::table('echomail_seenby')
|
||||
->whereIn('echomail_id',$x->pluck('id'))
|
||||
->where('address_id',$this->id)
|
||||
->whereNull('sent_at')
|
||||
->whereNull('packet')
|
||||
->whereNotNull('echomail_seenby.export_at')
|
||||
->update(['sent_at'=>Carbon::now(),'packet'=>$pkt->name]);
|
||||
if ($pkt && $pkt->count() && $update)
|
||||
DB::table('echomail_seenby')
|
||||
->whereIn('echomail_id',$x->pluck('id'))
|
||||
->where('address_id',$this->id)
|
||||
->whereNull('sent_at')
|
||||
->whereNull('packet')
|
||||
->whereNotNull('echomail_seenby.export_at')
|
||||
->update(['sent_at'=>Carbon::now(),'packet'=>$pkt->name]);
|
||||
}
|
||||
|
||||
return $pkt;
|
||||
@ -397,9 +399,10 @@ class Address extends Model
|
||||
/**
|
||||
* Get netmail for this node (including it's children)
|
||||
*
|
||||
* @param bool $update
|
||||
* @return Packet|null
|
||||
*/
|
||||
public function getNetmail(): ?Packet
|
||||
public function getNetmail(bool $update=TRUE): ?Packet
|
||||
{
|
||||
$pkt = NULL;
|
||||
|
||||
@ -408,9 +411,10 @@ class Address extends Model
|
||||
{
|
||||
$pkt = $this->getPacket($x);
|
||||
|
||||
DB::table('netmails')
|
||||
->whereIn('id',$x->pluck('id'))
|
||||
->update(['sent_at'=>Carbon::now(),'sent_pkt'=>$pkt->name]);
|
||||
if ($pkt && $pkt->count() && $update)
|
||||
DB::table('netmails')
|
||||
->whereIn('id',$x->pluck('id'))
|
||||
->update(['sent_at'=>Carbon::now(),'sent_pkt'=>$pkt->name]);
|
||||
}
|
||||
|
||||
return $pkt;
|
||||
@ -422,9 +426,15 @@ class Address extends Model
|
||||
* @param Collection $c
|
||||
* @return Packet
|
||||
*/
|
||||
private function getPacket(Collection $c): Packet
|
||||
private function getPacket(Collection $c): ?Packet
|
||||
{
|
||||
$o = new Packet($this);
|
||||
$ao = Setup::findOrFail(config('app.id'))->system->match($this->zone)->first();
|
||||
|
||||
// If we dont match on the address, we cannot pack mail for that system
|
||||
if (! $ao)
|
||||
return NULL;
|
||||
|
||||
$o = new Packet($ao,$this);
|
||||
|
||||
foreach ($c as $oo)
|
||||
$o->addMail($oo->packet($this));
|
||||
|
Loading…
Reference in New Issue
Block a user