Enabled sending netmails to upstream areafix/filefix
This commit is contained in:
@@ -8,17 +8,21 @@ use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
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\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\Rules\{FidoInteger,TwoByteInteger};
|
||||
|
||||
class SystemController extends Controller
|
||||
{
|
||||
private const LOGKEY = 'CSC';
|
||||
|
||||
/**
|
||||
* Add an address to a system
|
||||
*
|
||||
@@ -377,6 +381,37 @@ class SystemController extends Controller
|
||||
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
|
||||
*
|
||||
|
40
app/Http/Requests/AreafixRequest.php
Normal file
40
app/Http/Requests/AreafixRequest.php
Normal 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',
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user