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)
$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(',')));
} else {
@ -687,6 +689,8 @@ final class Binkp extends BaseProtocol
foreach ($this->node->aka_remote as $ao)
$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(',')));
} else {

View File

@ -188,6 +188,8 @@ final class EMSI extends BaseProtocol implements CRCInterface,ZmodemInterface
foreach ($this->node->aka_remote as $ao)
$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(',')));
} else {

View File

@ -3,6 +3,7 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Jenssegers\Mongodb\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
@ -10,8 +11,10 @@ use App\Classes\FTN\Message;
use App\Interfaces\Packet;
use App\Traits\UseMongo;
class Netmail extends Model implements Packet
final class Netmail extends Model implements Packet
{
private const LOGKEY = 'MN-';
use SoftDeletes,UseMongo;
protected $dates = ['datetime','sent_at'];
@ -40,9 +43,12 @@ class Netmail extends Model implements Packet
*/
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
$o = new Message;
try {
$o->header = [
'onode' => $this->fftn->node_id,
'dnode' => $ao->node_id,
@ -90,6 +96,11 @@ class Netmail extends Model implements Packet
$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;
}
}