Enabled sending netmails to upstream areafix/filefix

This commit is contained in:
Deon George 2023-08-03 17:30:52 +10:00
parent f281575b15
commit a87cf875e4
6 changed files with 209 additions and 4 deletions

View File

@ -8,17 +8,21 @@ use Illuminate\Support\Arr;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Illuminate\Support\ViewErrorBag; use Illuminate\Support\ViewErrorBag;
use App\Http\Requests\SystemRegister; use App\Classes\FTN\Message;
use App\Http\Requests\{AreafixRequest,SystemRegister};
use App\Jobs\AddressPoll; use App\Jobs\AddressPoll;
use App\Models\{Address,Echoarea,Filearea,Setup,System,SystemZone,Zone}; use App\Models\{Address,Echoarea,Filearea,Netmail,Setup,System,SystemZone,Zone};
use App\Notifications\Netmails\AddressLink; use App\Notifications\Netmails\AddressLink;
use App\Rules\{FidoInteger,TwoByteInteger}; use App\Rules\{FidoInteger,TwoByteInteger};
class SystemController extends Controller class SystemController extends Controller
{ {
private const LOGKEY = 'CSC';
/** /**
* Add an address to a system * Add an address to a system
* *
@ -377,6 +381,37 @@ class SystemController extends Controller
return $result; return $result;
} }
public function areafix(AreafixRequest $request,System $o,Zone $zo)
{
if ($request->post()) {
$no = new Netmail;
foreach ($request->safe() as $item => $value)
$no->{$item} = $value;
$no->from = auth::user()->name;
$no->msg .= "\r";
$no->datetime = Carbon::now();
$no->tzoffset = $no->datetime->utcOffset();
$no->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE|Message::FLAG_CRASH);
$no->cost = 0;
$no->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
$no->save();
Log::info(sprintf('%s:= Areafix to [%s], scheduling a poll',self::LOGKEY,$no->fftn->ftn));
AddressPoll::dispatch($no->tftn);
return redirect()->back()->with('success','Areafix/Filefix sent');
}
return view('system.areafix')
->with('zo',$zo)
->with('ao',$o->match($zo)->first())
->with('o',$o)
->with('setup',Setup::findOrFail(config('app.id')));
}
/** /**
* Delete address assigned to a host * Delete address assigned to a host
* *

View File

@ -0,0 +1,40 @@
<?php
namespace App\Http\Requests;
use App\Models\Setup;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
use Illuminate\Validation\Rule;
class AreafixRequest extends FormRequest
{
public function authorize()
{
return Gate::allows( 'admin');
}
public function rules(Request $request)
{
if (! $request->isMethod('post'))
return [];
return [
'to' => [
'required',
Rule::in(config('app.areafilefix')),
],
'fftn_id' => [
'required',
Rule::in(Setup::findOrFail(config('app.id'))->system->akas->pluck('id')),
],
'tftn_id' => [
'required',
Rule::in($this->route('o')->akas->pluck('id')),
],
'subject' => 'required|min:1|max:8',
'msg' => 'required|min:1',
];
}
}

View File

@ -211,9 +211,10 @@
<td>{{ $oo->pivot->fixpass }}</td> <td>{{ $oo->pivot->fixpass }}</td>
<td style="width: 70px;"> <td style="width: 70px;">
{{-- {{--
<a href="{{ url('ftn/system/modsession',[$oo->id]) }}" title="Modify Details" class="modify"><i class="bi bi-pen-fill"></i></a> <a href="{{ url('ftn/system/modsession',[$oo->id]) }}" title="Modify Details" class="modify"><i class="bi bi-pen"></i></a>
--}} --}}
<a href="{{ url('ftn/system/delsession',[$o->id,$oo->id]) }}" title="Delete Details" class="purge"><i class="bi bi-trash-fill"></i></a> <a href="{{ url('ftn/system/delsession',[$o->id,$oo->id]) }}" title="Delete Details" class="purge"><i class="bi bi-trash"></i></a>
<a href="{{ url('ftn/system/areafix',[$o->id,$oo->id]) }}" title="Areafix/Filefix"><i class="bi bi-envelope-paper"></i></a>
</td> </td>
</tr> </tr>
@endforeach @endforeach

View File

@ -0,0 +1,116 @@
@extends('layouts.app')
@section('htmlheader_title')
Areafix/Filefix Message
@endsection
@section('content')
<div class="row">
<div class="col-12">
<h1>Areafix/Filefix to {{ $o->name }} - {{ $zo->domain->name }}</h1>
</div>
</div>
@include('widgets.success')
<form class="row g-0 needs-validation" method="post" novalidate>
@csrf
<div class="row pt-0">
<div class="col-2">
<label for="to" class="form-label">To</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-ui-radios"></i></span>
<select class="form-select @error('to') is-invalid @enderror" id="to" name="to">
@foreach (config('app.areafilefix') as $name)
<option value="{{ $name }}" @if(old('to' === $name ))selected @endif>{{ $name }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('to')
{{ $message }}
@enderror
</span>
</div>
</div>
<div class="offset-2 col-3">
<label for="tftn_id" class="form-label">Address</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-ui-radios"></i></span>
<select class="form-select @error('tftn_id') is-invalid @enderror" id="tftn_id" name="tftn_id">
@foreach ($o->akas->where('zone_id',$zo->id) as $ao)
<option value="{{ $ao->id }}" @if(old('tftn_id' === $ao->id))selected @endif>{{ $ao->ftn }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('tftn_id')
{{ $message }}
@enderror
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-3">
<label for="subject" class="form-label">Subject</label>
<div class="input-group">
<span class="input-group-text @error('subject') is-invalid @enderror"><i class="bi bi-wifi"></i></span>
<input type="text" class="form-control" id="subject" placeholder="Areafix Password" name="subject" value="{{ old('subject',$ao->session('fixpass')) }}">
<span class="invalid-feedback" role="alert">
@error('subject')
{{ $message }}
@enderror
</span>
</div>
</div>
<div class="offset-1 col-3">
<label for="fftn_id" class="form-label">From</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-ui-radios"></i></span>
<select class="form-select @error('fftn_id') is-invalid @enderror" id="fftn_id" name="fftn_id">
@foreach ($setup->system->akas->where('zone_id',$zo->id) as $ao)
<option value="{{ $ao->id }}" @if(old('fftn_id' === $ao->id))selected @endif>{{ $ao->ftn }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('fftn_id')
{{ $message }}
@enderror
</span>
</div>
</div>
</div>
<div class="row">
<!-- Message -->
<div class="col-12">
<label for="msg" class="form-label">Message</label>
<textarea class="form-control @error('msg') is-invalid @enderror" rows=10 name="msg" placeholder="Message...">{{ old('msg') }}</textarea>
<span class="invalid-feedback" role="alert">
@error('msg')
{{ $message }}
@enderror
</span>
</div>
</div>
<div class="row">
<div class="col-12">
<button type="submit" class="btn btn-success" name="submit" value="send">Send</button>
</div>
</div>
</form>
@endsection
@section('page-css')
@append
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
});
</script>
@append

View File

@ -0,0 +1,10 @@
<!-- Success -->
@if(session()->has('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
<h4 class="text-success"><i class="bi bi-hand-thumbs-up"></i> Success!</h4>
<ul>
<li>{{ session()->get('success') }}</li>
</ul>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif

View File

@ -77,6 +77,9 @@ Route::middleware(['auth','verified','activeuser'])->group(function () {
->where('o','[0-9]+'); ->where('o','[0-9]+');
Route::post('ftn/system/addsession/{o}',[SystemController::class,'add_session']) Route::post('ftn/system/addsession/{o}',[SystemController::class,'add_session'])
->where('o','[0-9]+'); ->where('o','[0-9]+');
Route::match(['get','post'],'ftn/system/areafix/{o}/{zo}',[SystemController::class,'areafix'])
->where('o','[0-9]+')
->where('zo','[0-9]+');
Route::get('ftn/system/deladdress/{o}',[SystemController::class,'del_address']) Route::get('ftn/system/deladdress/{o}',[SystemController::class,'del_address'])
->where('o','[0-9]+'); ->where('o','[0-9]+');
Route::get('ftn/system/demaddress/{o}',[SystemController::class,'dem_address']) Route::get('ftn/system/demaddress/{o}',[SystemController::class,'dem_address'])