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,6 +2,7 @@
namespace App\Models;
use App\ColorPicker;
use Carbon\Carbon;
use Ddeboer\Imap\Search\Date\Since;
use Ddeboer\Imap\Search\Email\Cc;
@@ -14,7 +15,7 @@ use Illuminate\Support\Facades\Storage;
class Message extends Model
{
use HasFactory;
use HasFactory, ColorPicker;
public static function store(Request $request): void
{
@@ -149,7 +150,6 @@ class Message extends Model
$content = '';
$contentText = '';
$html = $message->getBodyHtml();
$text = $message->getBodyText();
if ($text) {
$contentText = str_replace('<a', '<a target="blank"', str_replace(array("\r\n", "\n"), '', $text));
@@ -173,12 +173,16 @@ class Message extends Model
$obj['content'] = $content;
$obj['contentText'] = $contentText;
$obj['attachments'] = [];
$obj['is_seen'] = true;
$obj['sender_photo'] = self::chooseColor(strtoupper(substr($sender->getName() ?: $sender->getAddress(), 0, 1) ));
//Checking if Sender is Blocked
$domain = explode('@', $obj['sender_email'])[1];
$blocked = in_array($domain, json_decode(config('app.settings.configuration_settings'))->blocked_domains);
if ($blocked) {
$obj['subject'] = __('Blocked');
$obj['content'] = __('Emails from') . ' ' . $domain . ' ' . __('are blocked by Admin');
$obj['contentText'] = __('Emails from') . ' ' . $domain . ' ' . __('are blocked by Admin');
}
if ($message->hasAttachments() && !$blocked) {
$attachments = $message->getAttachments();
@@ -189,10 +193,14 @@ class Message extends Model
$extension = $filenameArray[count($filenameArray) - 1];
if (in_array($extension, $allowed)) {
if (!file_exists($directory . $attachment->getFilename())) {
file_put_contents(
$directory . $attachment->getFilename(),
$attachment->getDecodedContent()
);
try {
file_put_contents(
$directory . $attachment->getFilename(),
$attachment->getDecodedContent()
);
} catch (\Exception $e) {
\Illuminate\Support\Facades\Log::error($e->getMessage());
}
}
if ($attachment->getFilename() !== 'undefined') {
$url = config('app.settings.app_base_url') . str_replace('./', '/', $directory . $attachment->getFilename());