chore: code styling via pint

This commit is contained in:
idevakk
2025-11-14 01:51:35 -08:00
parent 3892c48ef2
commit 90ab79b3a2
121 changed files with 1003 additions and 892 deletions

View File

@@ -2,44 +2,62 @@
namespace App\Livewire\Dashboard\Mailbox;
use Exception;
use App\ColorPicker;
use App\Models\Log;
use App\Models\Premium;
use App\Models\PremiumEmail;
use App\Models\UsageLog;
use App\Models\ZEmail;
use Artisan;
use Carbon\Carbon;
use Exception;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cookie;
use Livewire\Component;
use Session;
class Inbox extends Component
{
use ColorPicker;
public $messages = [];
public $deleted = [];
public $error = '';
public $email;
public $initial = false;
public $type;
public $overflow = false;
public $messageId;
public $list = false;
public $emails;
public $mailboxHistory;
public $emailsHistory;
public $username, $domain, $domains, $action;
public $username;
public $domain;
public $domains;
public $action;
public $email_limit = 20;
public bool $premium = true;
private $isSubscribed;
protected $listeners = ['updateEmail' => 'syncEmail', 'getEmail' => 'generateEmail', 'fetchMessages' => 'fetch', 'setMessageId' => 'setMessageId'];
public function mount(): void
{
$this->premium = Session::get('isInboxTypePremium', true);
@@ -64,7 +82,7 @@ class Inbox extends Component
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
Session::put('isSubscribed', $subscriptionCheck);
if($subscriptionCheck) {
if ($subscriptionCheck) {
try {
$result = auth()->user()->subscriptions()->where(['stripe_status' => 'active'])->orderByDesc('updated_at')->first();
$userPriceID = $result['items'][0]['stripe_price'];
@@ -116,7 +134,7 @@ class Inbox extends Component
} else {
$domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
}
if (!in_array($domain, $domains)) {
if (! in_array($domain, $domains)) {
return $this->showAlert('error', __('This mailbox can not be recovered.'));
}
}
@@ -150,24 +168,25 @@ class Inbox extends Component
}
/* Actions */
public function create() {
if (!$this->username) {
public function create()
{
if (! $this->username) {
return $this->showAlert('error', __('Please enter Username'));
}
$this->checkDomainInUsername();
if (strlen($this->username) < json_decode(config('app.settings.configuration_settings'))->custom_username_length_min || strlen($this->username) > json_decode(config('app.settings.configuration_settings'))->custom_username_length_max) {
return $this->showAlert('error', __('Username length cannot be less than') . ' ' . json_decode(config('app.settings.configuration_settings'))->custom_username_length_min . ' ' . __('and greater than') . ' ' . json_decode(config('app.settings.configuration_settings'))->custom_username_length_max);
return $this->showAlert('error', __('Username length cannot be less than').' '.json_decode(config('app.settings.configuration_settings'))->custom_username_length_min.' '.__('and greater than').' '.json_decode(config('app.settings.configuration_settings'))->custom_username_length_max);
}
if (!$this->domain) {
if (! $this->domain) {
return $this->showAlert('error', __('Please Select a Domain'));
}
if (in_array($this->username, json_decode(config('app.settings.configuration_settings'))->forbidden_ids)) {
return $this->showAlert('error', __('Username not allowed'));
}
if (!$this->checkEmailLimit()) {
return $this->showAlert('error', __('You have reached daily limit of MAX ') . $this->email_limit . __(' temp mail'));
if (! $this->checkEmailLimit()) {
return $this->showAlert('error', __('You have reached daily limit of MAX ').$this->email_limit.__(' temp mail'));
}
if (!$this->checkUsedEmail()) {
if (! $this->checkUsedEmail()) {
return $this->showAlert('error', __('Sorry! That email is already been used by someone else. Please try a different email address.'));
}
if ($this->premium) {
@@ -175,42 +194,51 @@ class Inbox extends Component
} else {
$this->email = ZEmail::createCustomEmail($this->username, $this->domain);
}
return redirect()->route('dashboard.premium');
}
public function random() {
if (!$this->checkEmailLimit()) {
return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.'));
public function random()
{
if (! $this->checkEmailLimit()) {
return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.'));
}
if ($this->premium) {
$this->email = Premium::generateRandomEmail();
} else {
$this->email = ZEmail::generateRandomEmail();
}
return redirect()->route('dashboard.premium');
}
public function gmail() {
if (!$this->checkEmailLimit()) {
return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.'));
public function gmail()
{
if (! $this->checkEmailLimit()) {
return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.'));
}
if ($this->premium) {
$this->email = Premium::generateRandomGmail();
} else {
$this->email = ZEmail::generateRandomGmail();
}
return redirect()->route('dashboard.premium');
}
public function outlook() {
if (!$this->checkEmailLimit()) {
return $this->showAlert('error', __('You have reached daily limit of maximum ') . $this->email_limit . __(' temp mail addresses.'));
public function outlook()
{
if (! $this->checkEmailLimit()) {
return $this->showAlert('error', __('You have reached daily limit of maximum ').$this->email_limit.__(' temp mail addresses.'));
}
if ($this->premium) {
$this->email = Premium::generateRandomOutlook();
} else {
$this->email = ZEmail::generateRandomOutlook();
}
return redirect()->route('dashboard.premium');
}
@@ -230,18 +258,21 @@ class Inbox extends Component
if (count($logs) >= $this->email_limit) {
return false;
}
return true;
}
private function checkUsedEmail(): bool
{
if (json_decode(config('app.settings.configuration_settings'))->disable_used_email) {
$check = Log::where('email', $this->user . '@' . $this->domain)->where('ip', '<>', request()->ip())->count();
$check = Log::where('email', $this->user.'@'.$this->domain)->where('ip', '<>', request()->ip())->count();
if ($check > 0) {
return false;
}
return true;
}
return true;
}
@@ -268,7 +299,7 @@ class Inbox extends Component
} else {
$domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
}
if (!in_array($domain, $domains)) {
if (! in_array($domain, $domains)) {
$key = array_search($this->email, $this->emails);
if ($this->premium) {
Premium::removeEmail($this->email);
@@ -290,7 +321,6 @@ class Inbox extends Component
/* Mailbox */
public function fetch(): void
{
try {
@@ -300,33 +330,33 @@ class Inbox extends Component
}
$responses = [];
if ($this->premium) {
if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->premium_cc_check) {
if (config('app.beta_feature') || ! json_decode(config('app.settings.imap_settings'))->premium_cc_check) {
$responses = [
'to' => Premium::getMessages($this->email, 'to', $this->deleted),
'cc' => [
'data' => [],
'notifications' => []
]
'notifications' => [],
],
];
} else {
$responses = [
'to' => Premium::getMessages($this->email, 'to', $this->deleted),
'cc' => Premium::getMessages($this->email, 'cc', $this->deleted)
'cc' => Premium::getMessages($this->email, 'cc', $this->deleted),
];
}
} else {
if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->cc_check) {
if (config('app.beta_feature') || ! json_decode(config('app.settings.imap_settings'))->cc_check) {
$responses = [
'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
'cc' => [
'data' => [],
'notifications' => []
]
'notifications' => [],
],
];
} else {
$responses = [
'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted)
'cc' => ZEmail::getMessages($this->email, 'cc', $this->deleted),
];
}
}
@@ -336,7 +366,7 @@ class Inbox extends Component
$notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']);
if (count($notifications)) {
if (!$this->overflow && count($this->messages) == $count) {
if (! $this->overflow && count($this->messages) == $count) {
$this->overflow = true;
}
} else {
@@ -367,16 +397,17 @@ class Inbox extends Component
$this->initial = true;
}
public function delete($messageId) {
public function delete($messageId)
{
try {
$this->deleted[] = $messageId;
foreach ($this->messages as $key => $message) {
if ($message['id'] == $messageId) {
if ($this->premium) {
$directory = public_path('tmp/premium/attachments/') . $messageId;
$directory = public_path('tmp/premium/attachments/').$messageId;
} else {
$directory = public_path('tmp/attachments/') . $messageId;
$directory = public_path('tmp/attachments/').$messageId;
}
$this->rrmdir($directory);
unset($this->messages[$key]);
@@ -384,7 +415,7 @@ class Inbox extends Component
}
} catch (
Exception $exception
Exception $exception
) {
\Illuminate\Support\Facades\Log::error($exception->getMessage());
}
@@ -393,7 +424,7 @@ class Inbox extends Component
public function toggleMode()
{
$this->premium = !$this->premium;
$this->premium = ! $this->premium;
Session::put('isInboxTypePremium', $this->premium);
if ($this->premium) {
$this->domains = json_decode(config('app.settings.configuration_settings'))->premium_domains ?? [];
@@ -432,11 +463,12 @@ class Inbox extends Component
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir . DIRECTORY_SEPARATOR . $object) && !is_link($dir . "/" . $object))
$this->rrmdir($dir . DIRECTORY_SEPARATOR . $object);
else
unlink($dir . DIRECTORY_SEPARATOR . $object);
if ($object != '.' && $object != '..') {
if (is_dir($dir.DIRECTORY_SEPARATOR.$object) && ! is_link($dir.'/'.$object)) {
$this->rrmdir($dir.DIRECTORY_SEPARATOR.$object);
} else {
unlink($dir.DIRECTORY_SEPARATOR.$object);
}
}
}
rmdir($dir);