diff --git a/.env.example b/.env.example index 9f8319b00738..f84708528ee5 100644 --- a/.env.example +++ b/.env.example @@ -51,11 +51,13 @@ TRUSTED_PROXIES= NINJA_ENVIRONMENT=selfhost -PHANTOMJS_PDF_GENERATION=true +#options - snappdf / phantom / hosted_ninja +PDF_GENERATOR=phantom + PHANTOMJS_KEY='a-demo-key-with-low-quota-per-ip-address' PHANTOMJS_SECRET=secret -UPDATE_SECRET= +UPDATE_SECRET=secret COMPOSER_AUTH='{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}' SENTRY_LARAVEL_DSN=https://cc7e8e2c678041689e53e409b7dba236@sentry.invoicing.co/5 \ No newline at end of file diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 4f854498784e..0a7c8d2b1924 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -141,10 +141,10 @@ class ActivityController extends BaseController return response()->json(['message'=> ctrans('texts.no_backup_exists'), 'errors' => new stdClass], 404); } - if (config('ninja.phantomjs_pdf_generation')) { + if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { $pdf = (new Phantom)->convertHtmlToPdf($backup->html_backup); } - elseif(config('ninja.invoiceninja_hosted_pdf_generation')){ + elseif(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){ $pdf = (new NinjaPdf())->build($backup->html_backup); } else { diff --git a/app/Http/Controllers/PreviewController.php b/app/Http/Controllers/PreviewController.php index 70c21a9554f2..d15bd37fff29 100644 --- a/app/Http/Controllers/PreviewController.php +++ b/app/Http/Controllers/PreviewController.php @@ -131,11 +131,11 @@ class PreviewController extends BaseController } //if phantom js...... inject here.. - if (config('ninja.phantomjs_pdf_generation')) { + if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { return (new Phantom)->convertHtmlToPdf($maker->getCompiledHTML(true)); } - if(config('ninja.invoiceninja_hosted_pdf_generation')){ + if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){ return (new NinjaPdf())->build($maker->getCompiledHTML(true)); } diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index 067706227384..6fd777da27ac 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -105,7 +105,7 @@ class CreateEntityPdf implements ShouldQueue $this->entity->service()->deletePdf(); - if (config('ninja.phantomjs_pdf_generation')) { + if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { return (new Phantom)->generate($this->invitation); } @@ -171,7 +171,7 @@ class CreateEntityPdf implements ShouldQueue try { - if(config('ninja.invoiceninja_hosted_pdf_generation')){ + if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){ $pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true)); } else { diff --git a/app/Services/Invoice/GenerateDeliveryNote.php b/app/Services/Invoice/GenerateDeliveryNote.php index 581a5da1fa8c..b6c93fa494ba 100644 --- a/app/Services/Invoice/GenerateDeliveryNote.php +++ b/app/Services/Invoice/GenerateDeliveryNote.php @@ -60,7 +60,7 @@ class GenerateDeliveryNote $file_path = sprintf('%s%s_delivery_note.pdf', $this->invoice->client->invoice_filepath(), $this->invoice->number); - if (config('ninja.phantomjs_pdf_generation')) { + if (config('ninja.phantomjs_pdf_generation') || config('ninja.pdf_generator') == 'phantom') { return (new Phantom)->generate($this->invoice->invitations->first()); } @@ -92,7 +92,7 @@ class GenerateDeliveryNote // Storage::makeDirectory($this->invoice->client->invoice_filepath(), 0775); - if(config('ninja.invoiceninja_hosted_pdf_generation')){ + if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){ $pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true)); } else { diff --git a/app/Utils/SystemHealth.php b/app/Utils/SystemHealth.php index b130585ac28d..552d580df458 100644 --- a/app/Utils/SystemHealth.php +++ b/app/Utils/SystemHealth.php @@ -17,6 +17,7 @@ use Exception; use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Mail; +use Illuminate\Support\Facades\Queue; /** * Class SystemHealth. @@ -80,6 +81,7 @@ class SystemHealth 'open_basedir' => (bool)self::checkOpenBaseDir(), 'mail_mailer' => (string)self::checkMailMailer(), 'flutter_renderer' => (string)config('ninja.flutter_canvas_kit'), + 'jobs_pending' => (int) Queue::size(), ]; } diff --git a/config/ninja.php b/config/ninja.php index c6fa1d9b89cf..4c7da8e8068a 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -18,7 +18,7 @@ return [ 'app_tag' => '5.1.61-release', 'minimum_client_version' => '5.0.16', 'terms_version' => '1.0.1', - 'api_secret' => env('API_SECRET', false), + 'api_secret' => env('API_SECRET', ''), 'google_maps_api_key' => env('GOOGLE_MAPS_API_KEY'), 'google_analytics_url' => env('GOOGLE_ANALYTICS_URL', 'https://www.google-analytics.com/collect'), 'key_length' => 64, @@ -148,4 +148,5 @@ return [ 'disable_auto_update' => env('DISABLE_AUTO_UPDATE', false), 'invoiceninja_hosted_pdf_generation' => env('NINJA_HOSTED_PDF', false), 'ninja_stripe_key' => env('NINJA_STRIPE_KEY', null), + 'pdf_generator' => env('PDF_GENERATOR', false), ]; diff --git a/tests/Unit/InvitationTest.php b/tests/Unit/InvitationTest.php index 0bee7f83e1d1..c66cfbafc8d9 100644 --- a/tests/Unit/InvitationTest.php +++ b/tests/Unit/InvitationTest.php @@ -52,7 +52,6 @@ class InvitationTest extends TestCase try { $response = $this->withHeaders([ - 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, ])->put('/api/v1/invoices/'.$this->encodePrimaryKey($this->invoice->id), $this->invoice->toArray()); } catch (\Exception $e) {