Catch Netmails that dont generate an exception when converting to a packed message. Make sure we present unique addresses

This commit is contained in:
Deon George 2021-08-15 19:25:04 +10:00
parent 0789ee9042
commit b8478adecb
3 changed files with 56 additions and 39 deletions

View File

@ -150,6 +150,8 @@ final class Binkp extends BaseProtocol
foreach ($this->node->aka_remote_authed as $ao) foreach ($this->node->aka_remote_authed as $ao)
$addresses = $addresses->merge($this->setup->system->match($ao->zone)); $addresses = $addresses->merge($this->setup->system->match($ao->zone));
$addresses = $addresses->unique();
Log::debug(sprintf('%s: - Presenting limited AKAs [%s]',__METHOD__,$addresses->pluck('ftn')->join(','))); Log::debug(sprintf('%s: - Presenting limited AKAs [%s]',__METHOD__,$addresses->pluck('ftn')->join(',')));
} else { } else {
@ -687,6 +689,8 @@ final class Binkp extends BaseProtocol
foreach ($this->node->aka_remote as $ao) foreach ($this->node->aka_remote as $ao)
$addresses = $addresses->merge($this->setup->system->match($ao->zone)); $addresses = $addresses->merge($this->setup->system->match($ao->zone));
$addresses = $addresses->unique();
Log::debug(sprintf('%s: - Presenting limited AKAs [%s]',__METHOD__,$addresses->pluck('ftn')->join(','))); Log::debug(sprintf('%s: - Presenting limited AKAs [%s]',__METHOD__,$addresses->pluck('ftn')->join(',')));
} else { } else {

View File

@ -188,6 +188,8 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
foreach ($this->node->aka_remote as $ao) foreach ($this->node->aka_remote as $ao)
$addresses = $addresses->merge($this->setup->system->match($ao->zone)); $addresses = $addresses->merge($this->setup->system->match($ao->zone));
$addresses = $addresses->unique();
Log::debug(sprintf('%s: - Presenting limited AKAs [%s]',__METHOD__,$addresses->pluck('ftn')->join(','))); Log::debug(sprintf('%s: - Presenting limited AKAs [%s]',__METHOD__,$addresses->pluck('ftn')->join(',')));
} else { } else {

View File

@ -3,6 +3,7 @@
namespace App\Models; namespace App\Models;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jenssegers\Mongodb\Eloquent\Model; use Jenssegers\Mongodb\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\SoftDeletes; use Jenssegers\Mongodb\Eloquent\SoftDeletes;
@ -10,8 +11,10 @@ use App\Classes\FTN\Message;
use App\Interfaces\Packet; use App\Interfaces\Packet;
use App\Traits\UseMongo; use App\Traits\UseMongo;
class Netmail extends Model implements Packet final class Netmail extends Model implements Packet
{ {
private const LOGKEY = 'MN-';
use SoftDeletes,UseMongo; use SoftDeletes,UseMongo;
protected $dates = ['datetime','sent_at']; protected $dates = ['datetime','sent_at'];
@ -40,9 +43,12 @@ class Netmail extends Model implements Packet
*/ */
public function packet(Address $ao): Message public function packet(Address $ao): Message
{ {
Log::debug(sprintf('%s:Bundling [%s]',self::LOGKEY,$this->id));
// @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
$o = new Message; $o = new Message;
try {
$o->header = [ $o->header = [
'onode' => $this->fftn->node_id, 'onode' => $this->fftn->node_id,
'dnode' => $ao->node_id, 'dnode' => $ao->node_id,
@ -90,6 +96,11 @@ class Netmail extends Model implements Packet
$o->via = $via; $o->via = $via;
} catch (\Exception $e) {
Log::error(sprintf('%s:Error converting netmail [%s] to a message (%d:%s)',self::LOGKEY,$this->id,$e->getLine(),$e->getMessage()));
dump($this);
}
return $o; return $o;
} }
} }