chore: code styling via pint
This commit is contained in:
@@ -9,61 +9,83 @@ use Livewire\Component;
|
||||
|
||||
class Action extends Component
|
||||
{
|
||||
public $username, $email, $emails, $domain, $domains, $action, $initial;
|
||||
public function mount() {
|
||||
public $username;
|
||||
|
||||
public $email;
|
||||
|
||||
public $emails;
|
||||
|
||||
public $domain;
|
||||
|
||||
public $domains;
|
||||
|
||||
public $action;
|
||||
|
||||
public $initial;
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->domains = json_decode(config('app.settings.configuration_settings'))->domains ?? [];
|
||||
$this->email = ZEmail::getEmail();
|
||||
$this->emails = ZEmail::getEmails();
|
||||
$this->validateDomainInEmail();
|
||||
}
|
||||
|
||||
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 ') . json_decode(config('app.settings.configuration_settings'))->email_limit . __(' temp mail'));
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of MAX ').json_decode(config('app.settings.configuration_settings'))->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.'));
|
||||
}
|
||||
|
||||
$this->email = ZEmail::createCustomEmail($this->username, $this->domain);
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
|
||||
}
|
||||
public function random() {
|
||||
if (!$this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ') . json_decode(config('app.settings.configuration_settings'))->email_limit . __(' temp mail addresses.'));
|
||||
|
||||
public function random()
|
||||
{
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
$this->email = ZEmail::generateRandomEmail();
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
}
|
||||
|
||||
public function gmail() {
|
||||
if (!$this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ') . json_decode(config('app.settings.configuration_settings'))->email_limit . __(' temp mail addresses.'));
|
||||
public function gmail()
|
||||
{
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
$this->email = ZEmail::generateRandomGmail();
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
}
|
||||
|
||||
public function outlook() {
|
||||
if (!$this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ') . json_decode(config('app.settings.configuration_settings'))->email_limit . __(' temp mail addresses.'));
|
||||
public function outlook()
|
||||
{
|
||||
if (! $this->checkEmailLimit()) {
|
||||
return $this->showAlert('error', __('You have reached daily limit of maximum ').json_decode(config('app.settings.configuration_settings'))->email_limit.__(' temp mail addresses.'));
|
||||
}
|
||||
$this->email = ZEmail::generateRandomOutlook();
|
||||
|
||||
return redirect()->route('mailbox');
|
||||
}
|
||||
|
||||
@@ -87,22 +109,26 @@ class Action extends Component
|
||||
if (count($logs) >= json_decode(config('app.settings.configuration_settings'))->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;
|
||||
}
|
||||
|
||||
private function checkDomainInUsername() {
|
||||
private function checkDomainInUsername()
|
||||
{
|
||||
$parts = explode('@', $this->username);
|
||||
if (isset($parts[1])) {
|
||||
if (in_array($parts[1], $this->domains)) {
|
||||
@@ -118,7 +144,7 @@ class Action extends Component
|
||||
if (isset($data[1])) {
|
||||
$domain = $data[1];
|
||||
$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);
|
||||
ZEmail::removeEmail($this->email);
|
||||
if ($key == 0 && count($this->emails) == 1 && json_decode(config('app.settings.configuration_settings'))->after_last_email_delete == 'redirect_to_homepage') {
|
||||
@@ -129,7 +155,9 @@ class Action extends Component
|
||||
}
|
||||
}
|
||||
}
|
||||
public function render() {
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.frontend.action');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,14 @@ use Livewire\Component;
|
||||
class Email extends Component
|
||||
{
|
||||
public $list = false;
|
||||
public $type, $email, $emails, $initial;
|
||||
|
||||
public $type;
|
||||
|
||||
public $email;
|
||||
|
||||
public $emails;
|
||||
|
||||
public $initial;
|
||||
|
||||
protected $listeners = ['updateEmail' => 'syncEmail', 'getEmail' => 'generateEmail'];
|
||||
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Livewire\Frontend;
|
||||
|
||||
use Exception;
|
||||
use App\Models\Email;
|
||||
use App\ColorPicker;
|
||||
use App\Models\Email;
|
||||
use App\Models\Message;
|
||||
use App\Models\ZEmail;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Livewire\Component;
|
||||
@@ -16,12 +16,19 @@ class Mailbox extends Component
|
||||
use ColorPicker;
|
||||
|
||||
public $messages = [];
|
||||
|
||||
public $deleted = [];
|
||||
|
||||
public $error = '';
|
||||
|
||||
public $email;
|
||||
|
||||
public $initial = false;
|
||||
|
||||
public $type;
|
||||
|
||||
public $overflow = false;
|
||||
|
||||
public $messageId;
|
||||
|
||||
protected $listeners = ['fetchMessages' => 'fetch', 'syncMailbox' => 'syncEmail', 'setMessageId' => 'setMessageId'];
|
||||
@@ -30,10 +37,11 @@ class Mailbox extends Component
|
||||
{
|
||||
$this->email = ZEmail::getEmail();
|
||||
$this->initial = false;
|
||||
if (!ZEmail::getEmail()) {
|
||||
if (! ZEmail::getEmail()) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
}
|
||||
|
||||
public function syncEmail($email): void
|
||||
{
|
||||
$this->email = $email;
|
||||
@@ -49,18 +57,18 @@ class Mailbox extends Component
|
||||
$this->messages = [];
|
||||
}
|
||||
$responses = [];
|
||||
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),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -69,7 +77,7 @@ class Mailbox 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 {
|
||||
@@ -91,7 +99,8 @@ class Mailbox extends Component
|
||||
$this->initial = true;
|
||||
}
|
||||
|
||||
public function delete($messageId) {
|
||||
public function delete($messageId)
|
||||
{
|
||||
|
||||
try {
|
||||
if (config('app.beta_feature')) {
|
||||
@@ -103,7 +112,7 @@ class Mailbox extends Component
|
||||
$this->deleted[] = $messageId;
|
||||
foreach ($this->messages as $key => $message) {
|
||||
if ($message['id'] == $messageId) {
|
||||
$directory = public_path('tmp/attachments/') . $messageId;
|
||||
$directory = public_path('tmp/attachments/').$messageId;
|
||||
$this->rrmdir($directory);
|
||||
unset($this->messages[$key]);
|
||||
}
|
||||
@@ -127,11 +136,12 @@ class Mailbox 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);
|
||||
|
||||
Reference in New Issue
Block a user