diff --git a/app/Classes/Jobs/Commands/V2/TestAttachingS3FileAndSendEmailCommandJob.php b/app/Classes/Jobs/Commands/V2/TestAttachingS3FileAndSendEmailCommandJob.php new file mode 100644 index 00000000..596dd2c8 --- /dev/null +++ b/app/Classes/Jobs/Commands/V2/TestAttachingS3FileAndSendEmailCommandJob.php @@ -0,0 +1,59 @@ +whereDate('dispatch_date', '<', Carbon::today())->whereDate('dispatch_date', '>', Carbon::now()->subdays(10)); + })->get(); + + Log::info("[TESTING] total containers: " . count($containers)); + + $sent = false; + foreach ($containers as $container){ + if($sent){ + break; + } + foreach ($container->packingLists as $packingList){ + if($sent){ + break; + } + + if(!($packingList->owner instanceof Order)) continue; + $user = $packingList->owner->companyModule->employees()->first(); + $user = User::where('email', 'dillonngoweijoon@gmail.com')->first(); + + Log::info("[TESTING] user: " . json_encode($user)); + Log::info("[TESTING] packingList: " . json_encode($packingList)); + + $user->notify(new ShipmentDepartureEmail($user, $packingList)); + $sent = true; + } + } + + $end = new Carbon(); + $elapsedTime = $start->diff($end)->format('%H:%I:%S'); + Log::info(Carbon::now() . ': End job - Test to attach a file from S3 bucket and trigger an email send. ElapsedTime: ' . $elapsedTime . '.'); + } +} diff --git a/app/Classes/Notifications/ShipmentDepartureEmail.php b/app/Classes/Notifications/ShipmentDepartureEmail.php index 53c5bf95..ef99ce37 100644 --- a/app/Classes/Notifications/ShipmentDepartureEmail.php +++ b/app/Classes/Notifications/ShipmentDepartureEmail.php @@ -44,9 +44,12 @@ class ShipmentDepartureEmail extends AbstractEmail $mailMessage = (new MailMessage) ->subject('Your packages are on the way to malaysia - Invoice pending payment for order no.'. $this->packingList->owner->reference); $filesystemDriver = Storage::getDefaultDriver(); + $filename = $invoiceDocument->first()->file->file_info->original->file; + Log::info('ShipmentDepartureEmail file name: '.$filename); if($filesystemDriver === 's3'){ $fileContent = null; - $fileContent = Storage::disk('s3')->get('documents/' . $invoiceDocument->first()->file->file_info->original->file); + + $fileContent = Storage::disk('s3')->get('documents/' . $filename); if ($fileContent) { $mailMessage->attachData($fileContent, [ 'as' => 'invoice.pdf', @@ -57,7 +60,7 @@ class ShipmentDepartureEmail extends AbstractEmail else{ $filePath = ''; // $fileContent = Storage::disk('documents')->get($invoiceDocument->first()->file->file_info->original->file); - $filePath = storage_path('app/documents/' . $invoiceDocument->first()->file->file_info->original->file); + $filePath = storage_path('app/documents/' . $filename); if ($filePath) { $mailMessage->attach($filePath, [ 'as' => 'invoice.pdf', diff --git a/app/Console/Commands/V2/TestAttachingS3FileAndSendEmailCommand.php b/app/Console/Commands/V2/TestAttachingS3FileAndSendEmailCommand.php new file mode 100644 index 00000000..3ed92f3c --- /dev/null +++ b/app/Console/Commands/V2/TestAttachingS3FileAndSendEmailCommand.php @@ -0,0 +1,44 @@ +everyFiveMinutes() ->withoutOverlapping(); - $schedule->command('curl-vt-command') - ->cron('0 8 * * *') - ->withoutOverlapping(); + //cief todo: disable commands to avoid unintentional interfering with production starts + // $schedule->command('curl-vt-command') + // ->cron('0 8 * * *') + // ->withoutOverlapping(); - $schedule->command('curl-yd-order-list-command') - ->cron('0 9-18/3 * * *') - ->withoutOverlapping(); + // $schedule->command('curl-yd-order-list-command') + // ->cron('0 9-18/3 * * *') + // ->withoutOverlapping(); - $schedule->command('fix-packinglist-command') - ->cron('30 9-18/3 * * *') - ->withoutOverlapping(); + // $schedule->command('fix-packinglist-command') + // ->cron('30 9-18/3 * * *') + // ->withoutOverlapping(); - $schedule->command('fix-duplicate-container-reference-command') - ->cron('0 1 * * *') - ->withoutOverlapping(); + // $schedule->command('fix-duplicate-container-reference-command') + // ->cron('0 1 * * *') + // ->withoutOverlapping(); - $schedule->command('invoice-generate-command') - ->hourly() - ->withoutOverlapping(); + // $schedule->command('invoice-generate-command') + // ->hourly() + // ->withoutOverlapping(); - $schedule->command('billplz-failed-callback-fix-command') - ->hourly() - ->withoutOverlapping(); + // $schedule->command('billplz-failed-callback-fix-command') + // ->hourly() + // ->withoutOverlapping(); - $schedule->command('check-storage-invoices-group-transactions-command') - ->dailyAt('0:01') - ->withoutOverlapping(); + // $schedule->command('check-storage-invoices-group-transactions-command') + // ->dailyAt('0:01') + // ->withoutOverlapping(); - $schedule->command('permits-reminder-send-command') - ->dailyAt('09:30') - ->withoutOverlapping(); + // $schedule->command('permits-reminder-send-command') + // ->dailyAt('09:30') + // ->withoutOverlapping(); + //cief todo: disable commands to avoid unintentional interfering with production ends } //Commands Version 1: Before AWS else