Added echomail search and display

This commit is contained in:
Deon George
2021-08-29 11:48:27 +10:00
parent 12f9ee1960
commit 271f066667
7 changed files with 99 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Http\Controllers;
use App\Models\Echomail;
class EchomailController extends Controller
{
public function __construct()
{
$this->middleware('auth');
}
public function view(Echomail $o)
{
return view('echomail.view')
->with('o',$o);
}
}

View File

@@ -9,7 +9,7 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Gate;
use App\Classes\FTN\Packet;
use App\Models\{Address,Domain,Setup};
use App\Models\{Address,Domain,Echomail,Setup};
class HomeController extends Controller
{
@@ -86,7 +86,7 @@ class HomeController extends Controller
list($zone_id,$host_id,$node_id,$point_id,$domain) = sscanf($request->query('term'),'%d:%d/%d.%d@%s');
# Look for Opportunities
# Look for Systems
foreach (Address::select(['systems.name',DB::raw('systems.id AS system_id'),'zones.zone_id','region_id','host_id','node_id','point_id'])
->join('zones',['zones.id'=>'addresses.zone_id'])
->rightjoin('systems',['systems.id'=>'addresses.system_id'])
@@ -113,6 +113,14 @@ class HomeController extends Controller
$result->push(['id'=>$o->system_id,'name'=>$o->name.($ftn ? ' '.$ftn : ''),'value'=>url('ftn/system/addedit',[$o->system_id]),'category'=>'Systems']);
}
# Look for Messages
foreach (Echomail::select(['id','fftn_id','from'])
->where('msgid','like','%'.$request->query('term').'%')
->get() as $o)
{
$result->push(['id'=>$o->id,'name'=>sprintf('%s (%s)',$o->from,$o->fftn->ftn3d),'value'=>url('echomail/view',[$o->id]),'category'=>'Echomail']);
}
return $result->unique(['id'])->take(10)->values();
}

View File

@@ -207,6 +207,11 @@ class Address extends Model
return sprintf('%s@%s',$this->getFTN4DAttribute(),$this->zone->domain->name);
}
public function getFTN2DAttribute(): string
{
return sprintf('%d/%d',$this->host_id ?: $this->region_id,$this->node_id);
}
public function getFTN3DAttribute(): string
{
return sprintf('%d:%d/%d',$this->zone->zone_id,$this->host_id ?: $this->region_id,$this->node_id);

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Support\Collection;
use Jenssegers\Mongodb\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
@@ -32,6 +33,18 @@ class Echomail extends Model implements Packet
->withTrashed();
}
/* ATTRIBUTES */
public function getPathAttribute($value): Collection
{
return Address::whereIn('id',$value)->get()->pluck('ftn3d');
}
public function getSeenByAttribute($value): Collection
{
return Address::whereIn('id',$value)->get()->pluck('ftn2d');
}
/* METHODS */
public function jsonSerialize(): array