Compare commits

..

No commits in common. "b6639c7bfcb70236e1ed4c3f33615ea48ae6ff6f" and "03bfc9dbfcbad3ea3e8dbb26e5d44723057141ad" have entirely different histories.

9 changed files with 24 additions and 67 deletions

View File

@ -13,8 +13,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use App\Classes\FTN\Message; use App\Models\{Address,Domain,Echoarea};
use App\Models\{Address,Domain};
use App\Notifications\Echomails\AbsentNodes; use App\Notifications\Echomails\AbsentNodes;
use App\Notifications\Emails\NodeMarkedDown as NodeMarkedDownEmail; use App\Notifications\Emails\NodeMarkedDown as NodeMarkedDownEmail;
use App\Notifications\Netmails\NodeMarkedDown as NodeMarkedDownNetmail; use App\Notifications\Netmails\NodeMarkedDown as NodeMarkedDownNetmail;
@ -58,34 +57,8 @@ class AddressIdle implements ShouldQueue
Log::info(sprintf('%s:- Delisting [%s], not seen for [%d] days',self::LOGKEY,$ao->ftn,config('fido.idle.delist'))); Log::info(sprintf('%s:- Delisting [%s], not seen for [%d] days',self::LOGKEY,$ao->ftn,config('fido.idle.delist')));
$contact = FALSE; $contact = FALSE;
// Remove echomail not collected from echomail_seenby // @todo Subscribe from echoareas/fileareas
DB::table('echomail_seenby')
->where('address_id',$ao->id)
->whereNotNull('export_at')
->whereNull('sent_at')
->delete();
// Remove FLAG_INTRANSIT from netmail that hasnt been delivered
DB::table('netmails')
->where('tftn_id',$ao->id)
->whereRaw(sprintf('(flags & %d) > 0',Message::FLAG_INTRANSIT))
->update(['flags'=>DB::raw(sprintf('(flags & ~%d)',Message::FLAG_INTRANSIT))]);
// Remove files not collected
DB::table('file_seenby')
->where('address_id',$ao->id)
->whereNotNull('export_at')
->whereNull('sent_at')
->delete();
// Remove subscribed echoareas
$ao->echoareas()->detach();
// Remove subscribed fileareas
$ao->fileareas()->detach();
$ao->active = FALSE; $ao->active = FALSE;
$ao->validated = FALSE;
$ao->save(); $ao->save();
// Email Alert // Email Alert
@ -95,8 +68,10 @@ class AddressIdle implements ShouldQueue
} }
// Netmail Alert (to othernet network address) // Netmail Alert (to othernet network address)
if ($ao->system->uncommon()->count()) { // Uncommon addresses
Notification::route('netmail',$ao->system->uncommon()->first()->withoutRelations())->notify(new NodeDelistedNetmail($ao->withoutRelations())); $uncommon = $ao->system->addresses->map(fn($item)=>$item->parent())->diff(our_address())->first();
if ($uncommon) {
Notification::route('netmail',$uncommon->withoutRelations())->notify(new NodeDelistedNetmail($ao->withoutRelations()));
$contact = TRUE; $contact = TRUE;
} }
@ -116,8 +91,10 @@ class AddressIdle implements ShouldQueue
} }
// Netmail Alert (to othernet network address) // Netmail Alert (to othernet network address)
if ($ao->system->uncommon()->count()) { // Uncommon addresses
Notification::route('netmail',$ao->system->uncommon()->first()->withoutRelations())->notify(new NodeMarkedDownNetmail($ao->withoutRelations())); $uncommon = $ao->system->addresses->map(fn($item)=>$item->parent())->diff(our_address())->first();
if ($uncommon) {
Notification::route('netmail',$uncommon->withoutRelations())->notify(new NodeMarkedDownNetmail($ao->withoutRelations()));
$contact = TRUE; $contact = TRUE;
} }
@ -147,8 +124,10 @@ class AddressIdle implements ShouldQueue
} }
// Netmail Alert (to othernet network address) // Netmail Alert (to othernet network address)
if ($ao->system->uncommon()->count()) { // Uncommon addresses
Notification::route('netmail',$ao->system->uncommon()->first()->withoutRelations())->notify(new NodeMarkedHoldNetmail($ao->withoutRelations())); $uncommon = $ao->system->addresses->map(fn($item)=>$item->parent())->diff(our_address())->first();
if ($uncommon) {
Notification::route('netmail',$uncommon->withoutRelations())->notify(new NodeMarkedHoldNetmail($ao->withoutRelations()));
$contact = TRUE; $contact = TRUE;
} }

View File

@ -275,17 +275,4 @@ class System extends Model
return $this->akas->pluck('id')->search($item->command->address->id) !== FALSE; }) return $this->akas->pluck('id')->search($item->command->address->id) !== FALSE; })
->last(); ->last();
} }
/**
* Return other addresses that are no collected here, but are on the same network as us.
*
* @return \Illuminate\Database\Eloquent\Collection
* @throws \Exception
*/
public function uncommon(): Collection
{
$our = our_address();
return $this->akas->filter(fn($item)=>($item->parent() && (! $our->contains($item->parent()))));
}
} }

View File

@ -7,7 +7,6 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use App\Models\Address; use App\Models\Address;
@ -15,8 +14,6 @@ class NodeDelisted extends Notification //implements ShouldQueue
{ {
use Queueable; use Queueable;
private const LOGKEY = 'NED';
/** /**
* Create a new notification instance. * Create a new notification instance.
*/ */
@ -39,8 +36,6 @@ class NodeDelisted extends Notification //implements ShouldQueue
*/ */
public function toMail(object $notifiable): MailMessage public function toMail(object $notifiable): MailMessage
{ {
Log::info(sprintf('%s:+ Sending a NODE DELISTED EMAIL for address [%s]',self::LOGKEY,$this->ao->ftn));
$now = Carbon::now(); $now = Carbon::now();
return (new MailMessage) return (new MailMessage)

View File

@ -7,7 +7,6 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use App\Models\Address; use App\Models\Address;
@ -15,8 +14,6 @@ class NodeMarkedDown extends Notification //implements ShouldQueue
{ {
use Queueable; use Queueable;
private const LOGKEY = 'NEM';
/** /**
* Create a new notification instance. * Create a new notification instance.
*/ */
@ -39,8 +36,6 @@ class NodeMarkedDown extends Notification //implements ShouldQueue
*/ */
public function toMail(object $notifiable): MailMessage public function toMail(object $notifiable): MailMessage
{ {
Log::info(sprintf('%s:+ Sending a NODE MARKED DOWN EMAIL for address [%s]',self::LOGKEY,$this->ao->ftn));
$now = Carbon::now(); $now = Carbon::now();
return (new MailMessage) return (new MailMessage)

View File

@ -7,7 +7,6 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use App\Models\Address; use App\Models\Address;
@ -15,8 +14,6 @@ class NodeMarkedHold extends Notification //implements ShouldQueue
{ {
use Queueable; use Queueable;
private const LOGKEY = 'NEH';
/** /**
* Create a new notification instance. * Create a new notification instance.
*/ */
@ -39,8 +36,6 @@ class NodeMarkedHold extends Notification //implements ShouldQueue
*/ */
public function toMail(object $notifiable): MailMessage public function toMail(object $notifiable): MailMessage
{ {
Log::info(sprintf('%s:+ Sending a NODE MARKED HOLD EMAIL for address [%s]',self::LOGKEY,$this->ao->ftn));
$now = Carbon::now(); $now = Carbon::now();
return (new MailMessage) return (new MailMessage)

View File

@ -4,6 +4,7 @@ namespace App\Notifications\Netmails;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message; use App\Classes\FTN\Message;
@ -15,7 +16,7 @@ class NodeDelisted extends Netmails //implements ShouldQueue
{ {
use Queueable,PageTemplate; use Queueable,PageTemplate;
private const LOGKEY = 'NND'; private const LOGKEY = 'NMD';
/** /**
* Create a new notification instance. * Create a new notification instance.

View File

@ -4,6 +4,7 @@ namespace App\Notifications\Netmails;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message; use App\Classes\FTN\Message;
@ -15,7 +16,7 @@ class NodeMarkedDown extends Netmails //implements ShouldQueue
{ {
use Queueable,PageTemplate; use Queueable,PageTemplate;
private const LOGKEY = 'NNM'; private const LOGKEY = 'NMD';
/** /**
* Create a new notification instance. * Create a new notification instance.
@ -35,7 +36,7 @@ class NodeMarkedDown extends Netmails //implements ShouldQueue
$o = $this->setupNetmail($notifiable); $o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via); $ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Sending a NODE MARKED DOWN NETMAIL for address [%s]',self::LOGKEY,$ao->ftn)); Log::info(sprintf('%s:+ Sending a NODE MARKED DOWN for address [%s]',self::LOGKEY,$ao->ftn));
$o->subject = sprintf('ACTION REQUIRED: Your system will be delisted on %s',$now->format('Y-m-d')); $o->subject = sprintf('ACTION REQUIRED: Your system will be delisted on %s',$now->format('Y-m-d'));
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH); $o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH);

View File

@ -4,6 +4,7 @@ namespace App\Notifications\Netmails;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Message; use App\Classes\FTN\Message;
@ -15,7 +16,7 @@ class NodeMarkedHold extends Netmails //implements ShouldQueue
{ {
use Queueable,PageTemplate; use Queueable,PageTemplate;
private const LOGKEY = 'NNH'; private const LOGKEY = 'NMD';
/** /**
* Create a new notification instance. * Create a new notification instance.

View File

@ -169,6 +169,9 @@ trait MessageAttributes
{ {
Log::debug(sprintf('%s:+ Bundling [%s] for [%s]',self::LOGKEY,$this->id,$ao->ftn),['type'=>get_class($this)]); Log::debug(sprintf('%s:+ Bundling [%s] for [%s]',self::LOGKEY,$this->id,$ao->ftn),['type'=>get_class($this)]);
// For netmails, our tftn is the next hop
$this->tftn = $ao;
// @todo Dont bundle mail to nodes that have been disabled, or addresses that have been deleted // @todo Dont bundle mail to nodes that have been disabled, or addresses that have been deleted
return Message::packMessage($this); return Message::packMessage($this);
} }