Added almost all features except language, ads, seo, pages

This commit is contained in:
Gitea
2025-04-27 06:28:15 +05:30
parent 89f6410578
commit 94eb01b1ab
43 changed files with 1842 additions and 188 deletions

View File

@@ -2,13 +2,17 @@
namespace App\Livewire\Frontend;
use App\ColorPicker;
use App\Models\Message;
use App\Models\ZEmail;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Log;
use Livewire\Component;
class Mailbox extends Component
{
use ColorPicker;
public $messages = [];
public $deleted = [];
public $error = '';
@@ -16,25 +20,32 @@ class Mailbox extends Component
public $initial = false;
public $type;
public $overflow = false;
public $messageId;
protected $listeners = ['fetchMessages' => 'fetch', 'syncMailbox' => 'syncEmail'];
protected $listeners = ['fetchMessages' => 'fetch', 'syncMailbox' => 'syncEmail', 'setMessageId' => 'setMessageId'];
public function mount(): void
public function mount()
{
$this->email = ZEmail::getEmail();
$this->initial = false;
if (!ZEmail::getEmail()) {
return redirect()->route('home');
}
}
public function syncEmail($email): void
{
$this->email = $email;
$this->initial = false;
$this->messages = [];
}
public function fetch(): void
{
try {
$count = count($this->messages);
if ($count > 0) {
$this->messages = [];
}
$responses = [];
if (config('app.beta_feature') || !json_decode(config('app.settings.imap_settings'))->cc_check) {
$responses = [
@@ -51,21 +62,6 @@ class Mailbox extends Component
];
}
// $responses = [
// 'to' => ZEmail::getMessages($this->email, 'to', $this->deleted),
// ];
// $imapSettings = json_decode(config('app.settings.imap_settings'));
// $betaFeature = config('app.beta_feature');
//
// if ($betaFeature || empty($imapSettings?->cc_check)) {
// $responses['cc'] = [
// 'data' => [],
// 'notifications' => []
// ];
// } else {
// $responses['cc'] = ZEmail::getMessages($this->email, 'cc', $this->deleted);
// }
$this->deleted = [];
$this->messages = array_merge($responses['to']['data'], $responses['cc']['data']);
$notifications = array_merge($responses['to']['notifications'], $responses['cc']['notifications']);
@@ -90,22 +86,33 @@ class Mailbox extends Component
}
}
$this->dispatch('stopLoader');
$this->dispatch('loadDownload');
$this->initial = true;
}
public function delete($messageId) {
if (config('app.beta_feature')) {
Message::find($messageId)->delete();
}
$this->deleted[] = $messageId;
foreach ($this->messages as $key => $message) {
if ($message['id'] == $messageId) {
$directory = './tmp/attachments/' . $messageId;
$this->rrmdir($directory);
unset($this->messages[$key]);
try {
if (config('app.beta_feature')) {
Message::find($messageId)->delete();
}
if (config('app.fetch_from_db')) {
\App\Models\Email::where(['message_id' => $messageId])->delete();
}
$this->deleted[] = $messageId;
foreach ($this->messages as $key => $message) {
if ($message['id'] == $messageId) {
$directory = public_path('tmp/attachments/') . $messageId;
$this->rrmdir($directory);
unset($this->messages[$key]);
}
}
} catch (
\Exception $exception
) {
Log::error($exception->getMessage());
}
}
public function render()