chore: code refactor via rector
This commit is contained in:
@@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Session;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use App\Models\Premium;
|
||||
use App\Models\ZEmail;
|
||||
use Session;
|
||||
|
||||
class AppController extends Controller
|
||||
{
|
||||
@@ -15,67 +17,66 @@ class AppController extends Controller
|
||||
'email' => 'required|email',
|
||||
])->validate();
|
||||
|
||||
if (json_decode(config('app.settings.configuration_settings'))->enable_create_from_url) {
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->enable_create_from_url) {
|
||||
ZEmail::createCustomEmailFull($email);
|
||||
}
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
if (! ZEmail::getEmail()) {
|
||||
return redirect()->route('home');
|
||||
return to_route('home');
|
||||
}
|
||||
if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return redirect()->route('home');
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
return $this->app();
|
||||
}
|
||||
|
||||
public function app()
|
||||
public function app(): Redirector|RedirectResponse
|
||||
{
|
||||
return redirect()->route('home');
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
public function switch($email)
|
||||
public function switch($email): Redirector|RedirectResponse
|
||||
{
|
||||
ZEmail::setEmail($email);
|
||||
if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return redirect()->route('home');
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
|
||||
public function delete($email = null)
|
||||
public function delete($email = null): Redirector|RedirectResponse
|
||||
{
|
||||
if ($email) {
|
||||
$emails = ZEmail::getEmails();
|
||||
ZEmail::removeEmail($email);
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
} else {
|
||||
return redirect()->route('home');
|
||||
return to_route('mailbox');
|
||||
}
|
||||
return to_route('home');
|
||||
}
|
||||
|
||||
public function switchP($email)
|
||||
public function switchP($email): Redirector|RedirectResponse
|
||||
{
|
||||
if (Session::get('isInboxTypePremium')) {
|
||||
if (\Illuminate\Support\Facades\Session::get('isInboxTypePremium')) {
|
||||
Premium::setEmailP($email);
|
||||
} else {
|
||||
ZEmail::setEmail($email);
|
||||
}
|
||||
if (json_decode(config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return redirect()->route('dashboard');
|
||||
if (json_decode((string) config('app.settings.configuration_settings'))->disable_mailbox_slug) {
|
||||
return to_route('dashboard');
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
return to_route('dashboard.premium');
|
||||
}
|
||||
|
||||
public function deleteP($email = null)
|
||||
public function deleteP($email = null): Redirector|RedirectResponse
|
||||
{
|
||||
if ($email) {
|
||||
if (Session::get('isInboxTypePremium')) {
|
||||
if (\Illuminate\Support\Facades\Session::get('isInboxTypePremium')) {
|
||||
$emails = Premium::getEmails();
|
||||
Premium::removeEmail($email);
|
||||
} else {
|
||||
@@ -83,10 +84,9 @@ class AppController extends Controller
|
||||
ZEmail::removeEmail($email);
|
||||
}
|
||||
|
||||
return redirect()->route('dashboard.premium');
|
||||
} else {
|
||||
return redirect()->route('dashboard');
|
||||
return to_route('dashboard.premium');
|
||||
}
|
||||
return to_route('dashboard');
|
||||
}
|
||||
|
||||
public function locale($locale)
|
||||
@@ -94,38 +94,8 @@ class AppController extends Controller
|
||||
if (in_array($locale, config('app.locales'))) {
|
||||
session(['locale' => $locale]);
|
||||
|
||||
return redirect()->back();
|
||||
return back();
|
||||
}
|
||||
abort(400);
|
||||
}
|
||||
|
||||
private function getStringBetween($string, $start, $end)
|
||||
{
|
||||
$string = ' '.$string;
|
||||
$ini = strpos($string, $start);
|
||||
if ($ini == 0) {
|
||||
return '';
|
||||
}
|
||||
$ini += strlen($start);
|
||||
$len = strpos($string, $end, $ini) - $ini;
|
||||
|
||||
return substr($string, $ini, $len);
|
||||
}
|
||||
|
||||
private function setHeaders($page)
|
||||
{
|
||||
$header = $page->header;
|
||||
foreach ($page->meta ? unserialize($page->meta) : [] as $meta) {
|
||||
if ($meta['name'] == 'canonical') {
|
||||
$header .= '<link rel="canonical" href="'.$meta['content'].'" />';
|
||||
} elseif (str_contains($meta['name'], 'og:')) {
|
||||
$header .= '<meta property="'.$meta['name'].'" content="'.$meta['content'].'" />';
|
||||
} else {
|
||||
$header .= '<meta name="'.$meta['name'].'" content="'.$meta['content'].'" />';
|
||||
}
|
||||
}
|
||||
$page->header = $header;
|
||||
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,19 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use App\NotifyMe;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Log;
|
||||
|
||||
class WebhookController extends Controller
|
||||
{
|
||||
use NotifyMe;
|
||||
|
||||
public function oxapay(Request $request)
|
||||
public function oxapay(Request $request): ResponseFactory|Response
|
||||
{
|
||||
// Get the request data
|
||||
$postData = $request->getContent();
|
||||
@@ -32,7 +34,7 @@ class WebhookController extends Controller
|
||||
|
||||
// Validate HMAC signature
|
||||
$hmacHeader = $request->header('HMAC');
|
||||
$calculatedHmac = hash_hmac('sha512', $postData, $apiSecretKey);
|
||||
$calculatedHmac = hash_hmac('sha512', $postData, (string) $apiSecretKey);
|
||||
|
||||
if (hash_equals($calculatedHmac, $hmacHeader)) {
|
||||
// HMAC signature is valid
|
||||
@@ -44,7 +46,7 @@ class WebhookController extends Controller
|
||||
$currency = $data['currency'] ?? 'Unknown';
|
||||
$trackId = $data['track_id'] ?? 'Unknown';
|
||||
$orderId = $data['order_id'] ?? 'N/A';
|
||||
$date = isset($data['date']) ? Carbon::createFromTimestamp($data['date'])->toDateTimeString() : now()->toDateTimeString();
|
||||
$date = isset($data['date']) ? Date::createFromTimestamp($data['date'])->toDateTimeString() : now()->toDateTimeString();
|
||||
|
||||
Log::info('Received Oxapay invoice payment callback', [
|
||||
'track_id' => $trackId,
|
||||
@@ -71,7 +73,7 @@ class WebhookController extends Controller
|
||||
$address = $data['address'] ?? 'Unknown';
|
||||
$txHash = $data['tx_hash'] ?? 'Unknown';
|
||||
$description = $data['description'] ?? 'N/A';
|
||||
$date = isset($data['date']) ? Carbon::createFromTimestamp($data['date'])->toDateTimeString() : now()->toDateTimeString();
|
||||
$date = isset($data['date']) ? Date::createFromTimestamp($data['date'])->toDateTimeString() : now()->toDateTimeString();
|
||||
|
||||
Log::info('Received Oxapay payout callback', [
|
||||
'track_id' => $trackId,
|
||||
|
||||
@@ -32,9 +32,7 @@ class CheckPageSlug
|
||||
return response()->file($publicPath);
|
||||
}
|
||||
|
||||
if (is_dir($publicPath)) {
|
||||
abort(404);
|
||||
}
|
||||
abort_if(is_dir($publicPath), 404);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
@@ -17,11 +17,11 @@ class Locale
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
try {
|
||||
$locale = explode('-', explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'])[0])[0];
|
||||
$locale = explode('-', explode(',', (string) \Illuminate\Support\Facades\Request::server('HTTP_ACCEPT_LANGUAGE'))[0])[0];
|
||||
if (in_array($locale, config('app.locales'))) {
|
||||
session(['browser-locale' => $locale]);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
} catch (Exception) {
|
||||
}
|
||||
app()->setLocale(session('locale', session('browser-locale', config('app.settings.language', config('app.locale', 'en')))));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user