BINKP responding to incoming netmail pings

This commit is contained in:
Deon George
2021-07-18 22:10:21 +10:00
parent 7bb3e12f66
commit 9dcfe6b17d
19 changed files with 145 additions and 54 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Carbon\Carbon;
use Exception;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -157,13 +158,22 @@ class Address extends Model
*/
public function getNetmail(): ?Packet
{
if (($x=Netmail::whereIn('tftn_id',$this->children->pluck('id')->push($this->id)))->count()) {
if (($x=Netmail::whereIn('tftn_id',$this->children->pluck('id')->push($this->id))
->where(function($q) {
return $q->whereNull('sent')
->orWhere('sent',FALSE);
}))
->count())
{
$o = new Packet($this);
foreach ($x->get() as $oo) {
$o->addNetmail($oo->packet());
// @todo We need to mark the netmail as sent
$oo->packet = $o->name;
$oo->sent = TRUE;
$oo->sent_at = Carbon::now();
$oo->save();
}
return $o;

View File

@@ -12,8 +12,20 @@ class Netmail extends Model
{
use SoftDeletes;
protected $connection = 'mongodb';
protected $dates = ['datetime'];
//protected $connection = 'mongodb';
protected $dates = ['datetime','sent_at'];
/**
* Resolve a connection instance.
* We need to do this, because our relations are in pgsql and somehow loading a relation changes this models
* connection information. Using protected $connection is not enough.
*
* @param string|null $connection
*/
public static function resolveConnection($connection = null)
{
return static::$resolver->connection('mongodb');
}
/* RELATIONS */
@@ -69,6 +81,10 @@ class Netmail extends Model
$o->user_from = $this->from;
$o->subject = $this->subject;
$o->message = $this->msg;
if ($this->tagline)
$o->message .= "\r... ".$this->tagline."\r";
$o->tearline .= $this->tearline;
$o->msgid = sprintf('%s %08x',$this->fftn->ftn3d,crc32($this->id));

View File

@@ -93,9 +93,6 @@ class Setup extends Model
$this->do_prevent = 1; /* EMSI - send an immediate EMSI_INQ on connect */
$this->ignore_nrq = 0;
$this->options = 0; /* EMSI - our capabilities */
/* EMSI - the order of protocols we are able to accept */
$this->inbound = '/tmp';
}
/**
@@ -106,7 +103,6 @@ class Setup extends Model
switch ($key) {
case 'binkp_options':
case 'ignore_nrq':
case 'inbound':
case 'opt_nr': // @todo - this keys are now in #binkp as bits
case 'opt_nd':
case 'opt_nda':
@@ -134,7 +130,6 @@ class Setup extends Model
switch ($key) {
case 'binkp_options':
case 'ignore_nrq':
case 'inbound':
case 'opt_nr':
case 'opt_nd':
case 'opt_nda':