feat: upgrade filament to v4 and ensure 100% test coverage

- Upgrade Filament framework from v3 to v4
   - Update all Filament resources and pages for v4 compatibility
   - Fix test suite to maintain 100% pass rate (321 tests passing)
   - Add visibility condition for ticket close action (only when not closed)
   - Update dependencies and build assets for new Filament version
   - Maintain backward compatibility while leveraging v4 improvements
This commit is contained in:
idevakk
2025-11-14 01:42:07 -08:00
parent 3706072ce5
commit 3892c48ef2
103 changed files with 1741 additions and 890 deletions

View File

@@ -2,6 +2,10 @@
namespace App\Models;
use Ddeboer\Imap\ConnectionInterface;
use DateTime;
use Exception;
use Illuminate\Support\Facades\Log;
use App\ColorPicker;
use Carbon\Carbon;
use Carbon\CarbonImmutable;
@@ -48,7 +52,7 @@ class Email extends Model
'timestamp' => 'datetime', // Cast timestamp to Carbon instance
];
public static function connectMailBox($imap = null): \Ddeboer\Imap\ConnectionInterface
public static function connectMailBox($imap = null): ConnectionInterface
{
if ($imap === null) {
$imap = json_decode(config('app.settings.imap_settings'), true);
@@ -69,7 +73,7 @@ class Email extends Model
try {
$allowed = explode(',', 'doc,docx,xls,xlsx,ppt,pptx,xps,pdf,dxf,ai,psd,eps,ps,svg,ttf,zip,rar,tar,gzip,mp3,mpeg,wav,ogg,jpeg,jpg,png,gif,bmp,tif,webm,mpeg4,3gpp,mov,avi,mpegs,wmv,flx,txt');
$connection = \App\Models\Email::connectMailBox();
$connection = Email::connectMailBox();
$mailbox = $connection->getMailbox('INBOX');
$messages = $mailbox->getMessages();
@@ -79,7 +83,7 @@ class Email extends Model
$sender = $message->getFrom();
$date = $message->getDate();
if (! $date) {
$date = new \DateTime;
$date = new DateTime;
if ($message->getHeaders()->get('udate')) {
$date->setTimestamp($message->getHeaders()->get('udate'));
}
@@ -146,8 +150,8 @@ class Email extends Model
$directory.$attachment->getFilename(),
$attachment->getDecodedContent()
);
} catch (\Exception $e) {
\Illuminate\Support\Facades\Log::error($e->getMessage());
} catch (Exception $e) {
Log::error($e->getMessage());
}
}
@@ -204,7 +208,7 @@ class Email extends Model
}
}
} catch (\Exception $e) {
} catch (Exception $e) {
// \Log::error($e);
}
} else {
@@ -241,7 +245,7 @@ class Email extends Model
}
}
} catch (\Exception $e) {
} catch (Exception $e) {
// \Log::error($e);
}
}
@@ -250,8 +254,8 @@ class Email extends Model
$connection->expunge();
} catch (\Exception $e) {
\Illuminate\Support\Facades\Log::error($e->getMessage());
} catch (Exception $e) {
Log::error($e->getMessage());
}
}
@@ -364,20 +368,20 @@ class Email extends Model
if (File::exists($dir)) {
File::cleanDirectory($dir);
}
} catch (\Exception $e) {
\Illuminate\Support\Facades\Log::error($e->getMessage());
} catch (Exception $e) {
Log::error($e->getMessage());
}
}
public static function deleteBulkMailboxes()
{
$foldersToClean = ['INBOX', 'ZDUMP', 'Trash'];
$cutoff = (new \DateTime)->modify('-3 hours');
$cutoff = (new DateTime)->modify('-3 hours');
$totalDeleted = 0;
$maxToDelete = 100;
foreach ($foldersToClean as $folderName) {
$connection = \App\Models\Email::connectMailBox();
$connection = Email::connectMailBox();
if ($totalDeleted >= $maxToDelete) {
$connection->expunge();
break;
@@ -385,7 +389,7 @@ class Email extends Model
if ($connection->hasMailbox($folderName)) {
$mailbox = $connection->getMailbox($folderName);
$messages = $mailbox->getMessages(new Since(new \DateTime('today')));
$messages = $mailbox->getMessages(new Since(new DateTime('today')));
foreach ($messages as $message) {
if ($totalDeleted >= $maxToDelete) {
@@ -446,12 +450,12 @@ class Email extends Model
public static function cleanMailbox(): string
{
$foldersToClean = ['INBOX'];
$cutoff = (new \DateTime)->modify('-6 hours');
$cutoff = (new DateTime)->modify('-6 hours');
$totalDeleted = 0;
$maxToDelete = 100;
foreach ($foldersToClean as $folderName) {
$connection = \App\Models\Email::connectMailBox();
$connection = Email::connectMailBox();
if ($totalDeleted >= $maxToDelete) {
$connection->expunge();
break;
@@ -459,7 +463,7 @@ class Email extends Model
if ($connection->hasMailbox($folderName)) {
$mailbox = $connection->getMailbox($folderName);
$messages = $mailbox->getMessages(new Since(new \DateTime('today')));
$messages = $mailbox->getMessages(new Since(new DateTime('today')));
foreach ($messages as $message) {
if ($totalDeleted >= $maxToDelete) {