Multiple enhancements to interactive messages, moved messages to Notifications, send netmail back when invalid packet password

This commit is contained in:
2023-07-23 17:27:52 +10:00
parent 9f0fa0a8ec
commit 17fe7e910d
28 changed files with 837 additions and 475 deletions

View File

@@ -619,6 +619,23 @@ class Address extends Model
$s = Setup::findOrFail(config('app.id'));
if (($x=$this->netmailAlertWaiting())->count()) {
Log::debug(sprintf('%s:= Packaging [%d] netmail alerts to [%s]',self::LOGKEY,$x->count(),$this->ftn));
$passpos = strpos($x->last()->subject,':');
if ($passpos > 8)
Log::alert(sprintf('%s:! Password would be greater than 8 chars? [%d]',self::LOGKEY,$passpos));
$pkt = $this->getPacket($x,substr($x->last()->subject,0,$passpos));
if ($pkt && $pkt->count() && $update)
DB::table('netmails')
->whereIn('id',$x->pluck('id'))
->update(['sent_pkt'=>$pkt->name]);
return $pkt;
}
if (($x=$this->netmailWaiting())
->count())
{
@@ -644,9 +661,10 @@ class Address extends Model
* Return a packet of mail
*
* @param Collection $msgs of message models (Echomail/Netmail)
* @param string|null $passwd Override password used in packet
* @return Packet|null
*/
public function getPacket(Collection $msgs): ?Packet
public function getPacket(Collection $msgs,string $passwd=NULL): ?Packet
{
$s = Setup::findOrFail(config('app.id'));
$ao = $s->system->match($this->zone)->first();
@@ -658,7 +676,7 @@ class Address extends Model
// Get packet type
$type = collect(Packet::PACKET_TYPES)->get($this->system->pkt_type ?: config('app.default_pkt'));
$o = new $type;
$o->addressHeader($ao,$this);
$o->addressHeader($ao,$this,$passwd);
// $oo = Netmail/Echomail Model
$c = 0;
@@ -667,7 +685,7 @@ class Address extends Model
if (++$c > $s->msgs_pkt)
break;
$o->addMail($oo->packet($this));
$o->addMail($oo->packet($this,$passwd));
}
return $o;
@@ -690,6 +708,21 @@ class Address extends Model
->get();
}
/**
* Netmail alerts waiting to be sent to this system
*
* @return Collection
*/
public function netmailAlertWaiting(): Collection
{
return Netmail::where('tftn_id',$this->id)
->whereRaw(sprintf('(flags & %d) > 0',Message::FLAG_LOCAL))
->whereRaw(sprintf('(flags & %d) > 0',Message::FLAG_PKTPASSWD))
->whereRaw(sprintf('(flags & %d) = 0',Message::FLAG_SENT))
->whereNull('sent_at')
->get();
}
/**
*
* Parse a string and split it out as an FTN array