From 922aecdd9fa60c3da08c6f88ac085bfb2e5518f3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 24 Oct 2022 08:42:38 +1100 Subject: [PATCH 1/2] Add configuration for R2 --- app/Jobs/Entity/CreateEntityPdf.php | 8 +------- app/Jobs/Util/UploadFile.php | 2 +- app/Jobs/Vendor/CreatePurchaseOrderPdf.php | 12 +----------- app/Services/Invoice/GenerateDeliveryNote.php | 8 +------- config/filesystems.php | 14 +++++++------- 5 files changed, 11 insertions(+), 33 deletions(-) diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index 96c6c48edbfd..34026a79c5c8 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -213,13 +213,7 @@ class CreateEntityPdf implements ShouldQueue if ($pdf) { try { - // if (! Storage::disk($this->disk)->exists($path)) { - // Storage::disk($this->disk)->makeDirectory($path, 0775); - // } - - Storage::disk($this->disk)->put($file_path, $pdf, 'public'); - -//r2 Storage::disk($this->disk)->put($file_path, $pdf); + Storage::disk($this->disk)->put($file_path, $pdf); } catch (\Exception $e) { throw new FilePermissionsFailure($e->getMessage()); } diff --git a/app/Jobs/Util/UploadFile.php b/app/Jobs/Util/UploadFile.php index 6ec31040c5e7..f15f3e8af3f0 100644 --- a/app/Jobs/Util/UploadFile.php +++ b/app/Jobs/Util/UploadFile.php @@ -167,7 +167,7 @@ class UploadFile implements ShouldQueue $previewHeight = $height * Document::DOCUMENT_PREVIEW_SIZE / $width; } else { $previewHeight = Document::DOCUMENT_PREVIEW_SIZE; - $previewWidth = $width * DOCUMENT_PREVIEW_SIZE / $height; + $previewWidth = $width * Document::DOCUMENT_PREVIEW_SIZE / $height; } $img->resize($previewWidth, $previewHeight); diff --git a/app/Jobs/Vendor/CreatePurchaseOrderPdf.php b/app/Jobs/Vendor/CreatePurchaseOrderPdf.php index b8ff4af3a1d9..8e6316e14aa1 100644 --- a/app/Jobs/Vendor/CreatePurchaseOrderPdf.php +++ b/app/Jobs/Vendor/CreatePurchaseOrderPdf.php @@ -99,20 +99,11 @@ class CreatePurchaseOrderPdf implements ShouldQueue if ($pdf) { try{ - - // if(!Storage::disk($this->disk)->exists($this->path)) - // Storage::disk($this->disk)->makeDirectory($this->path, 0775); - - Storage::disk($this->disk)->put($this->file_path, $pdf, 'public'); - -//r2 Storage::disk($this->disk)->put($this->file_path, $pdf); - + Storage::disk($this->disk)->put($this->file_path, $pdf); } catch(\Exception $e) { - throw new FilePermissionsFailure($e->getMessage()); - } } @@ -211,7 +202,6 @@ class CreatePurchaseOrderPdf implements ShouldQueue if($numbered_pdf) $pdf = $numbered_pdf; - } diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 204c0cc345f5..c6a40d0578c5 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -105,13 +105,7 @@ class GenerateDeliveryNote info($maker->getCompiledHTML()); } - // if (! Storage::disk($this->disk)->exists($this->invoice->client->invoice_filepath($invitation))) { - // Storage::disk($this->disk)->makeDirectory($this->invoice->client->invoice_filepath($invitation), 0775); - // } - - Storage::disk($this->disk)->put($file_path, $pdf, 'public'); - -//r2 Storage::disk($this->disk)->put($file_path, $pdf); + Storage::disk($this->disk)->put($file_path, $pdf); return $file_path; } diff --git a/config/filesystems.php b/config/filesystems.php index a7234ef8eb54..088e30385765 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -81,14 +81,14 @@ return [ 'r2' => [ 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION'), - 'bucket' => env('AWS_BUCKET'), - 'url' => env('AWS_URL'), + 'key' => env('R2_ACCESS_KEY_ID'), + 'secret' => env('R2_SECRET_ACCESS_KEY'), + 'region' => env('R2_DEFAULT_REGION'), + 'bucket' => env('R2_BUCKET'), + 'url' => env('R2_URL'), 'visibility' => 'private', - 'endpoint' => env('AWS_ENDPOINT'), - 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), + 'endpoint' => env('R2_ENDPOINT'), + 'use_path_style_endpoint' => env('R2_USE_PATH_STYLE_ENDPOINT', false), 'throw' => false, ], From fce12d1fcf5178b6f8cf6d44c403d43379311a62 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 24 Oct 2022 21:49:05 +1100 Subject: [PATCH 2/2] Free email list update --- app/Jobs/Account/CreateAccount.php | 2 +- app/Jobs/User/UserEmailChanged.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index e09128daa28f..5c35378b8026 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -86,7 +86,7 @@ class CreateAccount $sp794f3f->hosted_company_count = config('ninja.quotas.free.max_companies'); $sp794f3f->account_sms_verified = true; - if(in_array($this->getDomain($this->request['email']), ['yopmail.com','gmail.com', 'hotmail.com', 'outlook.com', 'yahoo.com', 'aol.com', 'mail.ru'])){ + if(in_array($this->getDomain($this->request['email']), ['givmail.com','yopmail.com','gmail.com', 'hotmail.com', 'outlook.com', 'yahoo.com', 'aol.com', 'mail.ru'])){ $sp794f3f->account_sms_verified = false; } diff --git a/app/Jobs/User/UserEmailChanged.php b/app/Jobs/User/UserEmailChanged.php index 8a582c4d951d..813358aad5ae 100644 --- a/app/Jobs/User/UserEmailChanged.php +++ b/app/Jobs/User/UserEmailChanged.php @@ -17,11 +17,13 @@ use App\Libraries\MultiDB; use App\Mail\User\UserNotificationMailer; use App\Models\Company; use App\Models\User; +use App\Utils\Ninja; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; +use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Mail; use stdClass; @@ -54,11 +56,14 @@ class UserEmailChanged implements ShouldQueue public function handle() { - nlog('notifying user of email change'); - //Set DB MultiDB::setDb($this->company->db); + App::forgetInstance('translator'); + $t = app('translator'); + $t->replace(Ninja::transformTranslations($this->company->settings)); + App::setLocale($this->company->getLocale()); + /*Build the object*/ $mail_obj = new stdClass; $mail_obj->subject = ctrans('texts.email_address_changed');