Transfering netmail via EMSI
This commit is contained in:
@@ -53,7 +53,8 @@ class Address extends Model
|
||||
return $this->hasMany(self::class,'hub_id','id');
|
||||
|
||||
case 'node':
|
||||
return NULL;
|
||||
// Nodes dont have children, but must return a relationship instance
|
||||
return $this->hasOne(self::class,NULL,'void');
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown role: '.$this->role);
|
||||
@@ -151,18 +152,24 @@ class Address extends Model
|
||||
|
||||
/**
|
||||
* Get netmail for this node (including it's children)
|
||||
*
|
||||
* @return Packet|null
|
||||
*/
|
||||
public function getNetmail(): Packet
|
||||
public function getNetmail(): ?Packet
|
||||
{
|
||||
$o = new Packet($this);
|
||||
if (($x=Netmail::whereIn('tftn_id',$this->children->pluck('id')->push($this->id)))->count()) {
|
||||
$o = new Packet($this);
|
||||
|
||||
foreach (Netmail::whereIn('tftn_id',$this->children->pluck('id')->push($this->id))->get() as $oo) {
|
||||
$o->addNetmail($oo->packet());
|
||||
foreach ($x->get() as $oo) {
|
||||
$o->addNetmail($oo->packet());
|
||||
|
||||
// @todo We need to mark the netmail as sent
|
||||
// @todo We need to mark the netmail as sent
|
||||
}
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
||||
return $o;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -21,7 +21,8 @@ class Netmail extends Model
|
||||
{
|
||||
return $this
|
||||
->setConnection('pgsql')
|
||||
->belongsTo(Address::class);
|
||||
->belongsTo(Address::class)
|
||||
->withTrashed();
|
||||
}
|
||||
|
||||
public function tftn()
|
||||
@@ -52,6 +53,8 @@ class Netmail extends Model
|
||||
{
|
||||
$o = new Message;
|
||||
|
||||
// @todo Dont bundle mail to nodes that have been disabled, or addresses that have been deleted
|
||||
|
||||
$o->header = [
|
||||
'onode' => $this->fftn->node_id,
|
||||
'dnode' => $this->tftn->node_id,
|
||||
@@ -88,6 +91,9 @@ class Netmail extends Model
|
||||
// @todo Point handling FMPT/TOPT
|
||||
$o->intl = sprintf('%s %s',$this->tftn->ftn3d,$this->fftn->ftn3d);
|
||||
|
||||
// TZUTC
|
||||
$o->kludge->put('tzutc',str_replace('+','',$this->created_at->getOffsetString('')));
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
@@ -42,9 +42,21 @@ class Setup extends Model
|
||||
public const PRODUCT_VERSION_MAJ = 0;
|
||||
public const PRODUCT_VERSION_MIN = 0;
|
||||
|
||||
public const hexdigitslower = '0123456789abcdef';
|
||||
|
||||
// Our non model attributes and values
|
||||
private array $internal = [];
|
||||
|
||||
public static function product_id(int $c=self::PRODUCT_ID): string
|
||||
{
|
||||
$x = substr(static::hexdigitslower,($c&0xf000)>>12,1);
|
||||
$x .= substr(static::hexdigitslower,($c&0x0f00)>>8,1);
|
||||
$x .= substr(static::hexdigitslower,($c&0x00f0)>>4,1);
|
||||
$x .= substr(static::hexdigitslower,($c&0x000f),1);
|
||||
|
||||
return $x;
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
public function system()
|
||||
|
Reference in New Issue
Block a user