From 724c19d539a3603c33a9527d62a77a94e4847a85 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 27 Nov 2022 09:26:52 +1100 Subject: [PATCH 1/4] Clean up for logging --- app/Services/Client/ClientService.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 9b9da5dfaf0a..54bfcb799ea1 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -33,8 +33,6 @@ class ClientService try { \DB::connection(config('database.default'))->transaction(function () use($amount) { - nlog("inside transaction - updating balance by {$amount}"); - $this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); $this->client->balance += $amount; $this->client->save(); From 31988d0387165d51d68cc3b6f472f144cb39dbcb Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 27 Nov 2022 09:46:24 +1100 Subject: [PATCH 2/4] Fixes for creating backup directory if it does not exist --- app/Console/Commands/SendRemindersCron.php | 1 + app/Http/Controllers/InvoiceController.php | 14 +++++++------- app/Jobs/Company/CompanyExport.php | 11 +++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/SendRemindersCron.php b/app/Console/Commands/SendRemindersCron.php index ad0b99387a65..0e0550d9ecd3 100644 --- a/app/Console/Commands/SendRemindersCron.php +++ b/app/Console/Commands/SendRemindersCron.php @@ -26,6 +26,7 @@ use App\Utils\Traits\MakesReminders; use Illuminate\Console\Command; use Illuminate\Support\Facades\App; +//@deprecated 27-11-2022 - only ever should be used for testing class SendRemindersCron extends Command { use MakesReminders, MakesDates; diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index b81b4a476387..c9df6ee84990 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -428,13 +428,13 @@ class InvoiceController extends BaseController event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); - $transaction = [ - 'invoice' => $invoice->transaction_event(), - 'payment' => [], - 'client' => $invoice->client->transaction_event(), - 'credit' => [], - 'metadata' => [], - ]; + // $transaction = [ + // 'invoice' => $invoice->transaction_event(), + // 'payment' => [], + // 'client' => $invoice->client->transaction_event(), + // 'credit' => [], + // 'metadata' => [], + // ]; // TransactionLog::dispatch(TransactionEvent::INVOICE_UPDATED, $transaction, $invoice->company->db); diff --git a/app/Jobs/Company/CompanyExport.php b/app/Jobs/Company/CompanyExport.php index f523c91b34da..5da3430b65ae 100644 --- a/app/Jobs/Company/CompanyExport.php +++ b/app/Jobs/Company/CompanyExport.php @@ -36,6 +36,8 @@ use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Storage; +use function Amp\call; + class CompanyExport implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, MakesHash; @@ -531,6 +533,15 @@ class CompanyExport implements ShouldQueue $path = 'backups'; + Storage::makeDirectory(public_path('storage/backups/')); + + try { + mkdir(public_path('storage/backups/')); + } + catch(\Exception $e) { + nlog("could not create directory"); + } + $zip_path = public_path('storage/backups/'.$file_name); $zip = new \ZipArchive(); From d21144f64b890f302c7b2a10ac628d905c9b0302 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 27 Nov 2022 10:47:59 +1100 Subject: [PATCH 3/4] minor fixes for type checks --- app/PaymentDrivers/Stripe/SEPA.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Stripe/SEPA.php b/app/PaymentDrivers/Stripe/SEPA.php index c002d08f1f9d..0b817b8146ae 100644 --- a/app/PaymentDrivers/Stripe/SEPA.php +++ b/app/PaymentDrivers/Stripe/SEPA.php @@ -84,7 +84,7 @@ class SEPA $this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all()); $this->stripe->payment_hash->save(); - if (property_exists($gateway_response, 'status') && ($gateway_response->status == 'processing' || $gateway_response->status === 'succeeded')) { + if (property_exists($gateway_response, 'status') && ($gateway_response->status == 'processing' || $gateway_response->status == 'succeeded')) { if ($request->store_card) { $this->storePaymentMethod($gateway_response); } From 2e3f371b802a7e148490c3b2844fcba6b2a9060f Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 27 Nov 2022 12:17:02 +1100 Subject: [PATCH 4/4] Minor fixes for failed notifications --- app/Listeners/Invoice/InvoiceFailedEmailNotification.php | 2 +- config/queue.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php index 8ab0e094949f..ac100e0e4646 100644 --- a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php +++ b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php @@ -48,7 +48,7 @@ class InvoiceFailedEmailNotification $first_notification_sent = true; $invoice = $event->invitation->invoice; - $invoice->update(['last_sent_date' => now()]); + // $invoice->update(['last_sent_date' => now()]); $nmo = new NinjaMailerObject; $nmo->mailable = new NinjaMailer((new EntityFailedSendObject($event->invitation, 'invoice', $event->template, $event->message))->build()); diff --git a/config/queue.php b/config/queue.php index 412282299176..18666fc43454 100644 --- a/config/queue.php +++ b/config/queue.php @@ -67,7 +67,7 @@ return [ 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 'queue' => env('REDIS_QUEUE', 'default'), 'retry_after' => 90000000, - 'block_for' => null, + 'block_for' => 1, 'after_commit' => false, ],