diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 6223400..73b6f12 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -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 * diff --git a/app/Http/Requests/AreafixRequest.php b/app/Http/Requests/AreafixRequest.php new file mode 100644 index 0000000..92b0082 --- /dev/null +++ b/app/Http/Requests/AreafixRequest.php @@ -0,0 +1,40 @@ +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', + ]; + } +} \ No newline at end of file diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index 52773a6..727508a 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -211,9 +211,10 @@