Changed logic in ftp file process mail configuration
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
|||||||
use App\Models\Machine;
|
use App\Models\Machine;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\ProductionTemp;
|
use App\Models\ProductionTemp;
|
||||||
|
use App\Models\AlertMailRule;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use App\Services\SftpFileService;
|
use App\Services\SftpFileService;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
@@ -562,19 +563,27 @@ class ProcessSftpFiles extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Send error logs through email
|
// Send error logs through email
|
||||||
if (!empty($logMessages)) {
|
if (!empty($logMessages)) {
|
||||||
|
|
||||||
$emailContent = implode(PHP_EOL, $logMessages);
|
$alertRule = AlertMailRule::where('module', 'FtpLogs')->where('rule_name', 'FtpLogsMail')->first();
|
||||||
|
|
||||||
Mail::raw('Please find attached machine error logs.', function ($message) use ($emailContent) {
|
if ($alertRule && !empty($alertRule->email)) {
|
||||||
|
|
||||||
$message->to(env('ERROR_LOG_MAIL'))
|
$emailContent = implode(PHP_EOL, $logMessages);
|
||||||
->subject('Machine Error Logs')
|
|
||||||
->attachData($emailContent, 'machine_errors.txt', [
|
$toEmails = array_filter(array_map('trim', explode(',', $alertRule->email)));
|
||||||
'mime' => 'text/plain',
|
|
||||||
]);
|
Mail::raw('Please find attached machine error logs.', function ($message) use ($emailContent, $toEmails) {
|
||||||
});
|
|
||||||
|
$message->to($toEmails)
|
||||||
|
->subject('Machine Error Logs')
|
||||||
|
->attachData($emailContent, 'machine_errors.txt', [
|
||||||
|
'mime' => 'text/plain',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info('Production TXT file processing completed.');
|
$this->info('Production TXT file processing completed.');
|
||||||
|
|||||||
Reference in New Issue
Block a user