Move determination of system packet to System::class
This commit is contained in:
parent
8bf58f3daa
commit
1c270025cf
@ -14,14 +14,41 @@ use App\Classes\FTN\{Message,Packet};
|
||||
use App\Exceptions\InvalidFTNException;
|
||||
use App\Traits\ScopeActive;
|
||||
|
||||
/**
|
||||
* This represents an FTN AKA.
|
||||
*
|
||||
* If an address is active, it belongs to the system. There can only be 1 active FTN (z:h/n.p@d)
|
||||
* If an address is not active, it belonged to the system at a point in time in the past.
|
||||
*
|
||||
* If an address is validated, we know that the system is using the address (we've confirmed that during a session).
|
||||
* Any mail for that address will be delivered.
|
||||
*
|
||||
* If an address is not validated, and the session password matches, validate the address.
|
||||
* If the session password doesnt match, treat the address as foreign (dont deliver, unless we originate netmail)
|
||||
*
|
||||
* Session:
|
||||
* + address not active
|
||||
* ++ address validated (shouldnt be the case)
|
||||
* ++ address not validated
|
||||
*
|
||||
* + address active
|
||||
* ++ address validated (give mail/files)
|
||||
* ++ address not validated - validate if the password is correct
|
||||
*
|
||||
* Mail in (from)
|
||||
* ++ address not validated, do not process
|
||||
* ++ address validated, process
|
||||
*
|
||||
* Mail out (to)
|
||||
* ++ address validated, deliver
|
||||
* ++ address not validated, only deliver netmail if we originate the call
|
||||
*/
|
||||
class Address extends Model
|
||||
{
|
||||
use ScopeActive,SoftDeletes;
|
||||
|
||||
private const LOGKEY = 'MA-';
|
||||
|
||||
protected $with = ['zone'];
|
||||
|
||||
// http://ftsc.org/docs/frl-1028.002
|
||||
public const ftn_regex = '(\d+):(\d+)/(\d+)(?:\.(\d+))?(?:@([a-zA-Z0-9\-_~]{0,8}))?';
|
||||
|
||||
@ -30,9 +57,9 @@ class Address extends Model
|
||||
public const NODE_NC = 1<<2; // Host
|
||||
public const NODE_HC = 1<<3; // Hub
|
||||
public const NODE_ACTIVE = 1<<4; // Node
|
||||
public const NODE_PVT = 1<<5; // Pvt
|
||||
public const NODE_HOLD = 1<<6; // Hold
|
||||
public const NODE_DOWN = 1<<7; // Down
|
||||
public const NODE_PVT = 1<<5; // Pvt (we dont have address information) @todo
|
||||
public const NODE_HOLD = 1<<6; // Hold (user has requested hold, we havent heard from the node for 7 days @todo
|
||||
public const NODE_DOWN = 1<<7; // Down we havent heard from the node for 30 days @todo
|
||||
public const NODE_POINT = 1<<8; // Point
|
||||
public const NODE_UNKNOWN = 1<<15; // Unknown
|
||||
public const NODE_ALL = 0xFFF; // Mask to catch all nodes
|
||||
@ -811,8 +838,7 @@ class Address extends Model
|
||||
}
|
||||
|
||||
// Get packet type
|
||||
$type = collect(Packet::PACKET_TYPES)->get($this->system->pkt_type ?: config('fido.packet_default'));
|
||||
$o = new $type;
|
||||
$o = $ao->system->packet();
|
||||
$o->addressHeader($ao,$this,$passwd);
|
||||
|
||||
// $oo = Netmail/Echomail Model
|
||||
|
@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use App\Classes\FTN\Packet;
|
||||
use App\Jobs\AddressPoll;
|
||||
|
||||
class System extends Model
|
||||
@ -249,6 +250,17 @@ class System extends Model
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the packet that this system uses
|
||||
*
|
||||
* @return Packet
|
||||
*/
|
||||
public function packet(): Packet
|
||||
{
|
||||
return new (collect(Packet::PACKET_TYPES)
|
||||
->get($this->pkt_type ?: config('fido.packet_default')));
|
||||
}
|
||||
|
||||
public function poll(): ?Job
|
||||
{
|
||||
return Job::where('queue',AddressPoll::QUEUE)
|
||||
|
Loading…
Reference in New Issue
Block a user