mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Merge pull request #6219 from turbo124/v5-develop
Fixes for portal domain
This commit is contained in:
commit
cbd2374d24
@ -67,8 +67,8 @@ class UpdateCompanyRequest extends Request
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
// if(array_key_exists('portal_domain', $input) && strlen($input['portal_domain']) > 1)
|
||||
// $input['portal_domain'] = str_replace("http:", "https:", $input['portal_domain']);
|
||||
if(array_key_exists('portal_domain', $input) && strlen($input['portal_domain']) > 1)
|
||||
$input['portal_domain'] = $this->addScheme($input['portal_domain']);
|
||||
|
||||
if (array_key_exists('settings', $input)) {
|
||||
$input['settings'] = $this->filterSaveableSettings($input['settings']);
|
||||
@ -105,4 +105,15 @@ class UpdateCompanyRequest extends Request
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
private function addScheme($url, $scheme = 'https://')
|
||||
{
|
||||
|
||||
$url = str_replace("http://", "", $url);
|
||||
|
||||
$url = parse_url($url, PHP_URL_SCHEME) === null ? $scheme . $url : $url;
|
||||
|
||||
return rtrim($url, '/');
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ class CreateEntityPdf implements ShouldQueue
|
||||
|
||||
$this->contact = $invitation->contact;
|
||||
|
||||
$this->disk = $disk;
|
||||
$this->disk = Ninja::isHosted() ? config('filesystems.default') : $disk;
|
||||
|
||||
// $this->disk = $disk ?? config('filesystems.default');
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Mail\Engine;
|
||||
|
||||
use App\DataMapper\EmailTemplateDefaults;
|
||||
use App\Jobs\Entity\CreateEntityPdf;
|
||||
use App\Models\Account;
|
||||
use App\Utils\HtmlEngine;
|
||||
use App\Utils\Ninja;
|
||||
@ -111,13 +112,13 @@ class InvoiceEmailEngine extends BaseEmailEngine
|
||||
|
||||
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
|
||||
|
||||
CreateEntityPdf::dispatchNow($invitation);
|
||||
|
||||
if(Ninja::isHosted())
|
||||
$this->setAttachments([$this->invoice->pdf_file_path($this->invitation, 'url', true)]);
|
||||
else
|
||||
$this->setAttachments([$this->invoice->pdf_file_path($this->invitation)]);
|
||||
|
||||
// $this->setAttachments(['path' => $this->invoice->pdf_file_path(), 'name' => basename($this->invoice->pdf_file_path())]);
|
||||
|
||||
}
|
||||
|
||||
//attach third party documents
|
||||
|
59
tests/Unit/UrlTest.php
Normal file
59
tests/Unit/UrlTest.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com).
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
namespace Tests\Unit;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
class UrlTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp() :void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testNoScheme()
|
||||
{
|
||||
$url = 'google.com';
|
||||
|
||||
$this->assertEquals("https://google.com", $this->addScheme($url));
|
||||
}
|
||||
|
||||
public function testNoSchemeAndTrailingSlash()
|
||||
{
|
||||
$url = 'google.com/';
|
||||
|
||||
$this->assertEquals("https://google.com", $this->addScheme($url));
|
||||
}
|
||||
|
||||
|
||||
public function testNoSchemeAndTrailingSlashAndHttp()
|
||||
{
|
||||
$url = 'http://google.com/';
|
||||
|
||||
$this->assertEquals("https://google.com", $this->addScheme($url));
|
||||
}
|
||||
|
||||
private function addScheme($url, $scheme = 'https://')
|
||||
{
|
||||
|
||||
$url = str_replace("http://", "", $url);
|
||||
|
||||
$url = parse_url($url, PHP_URL_SCHEME) === null ? $scheme . $url : $url;
|
||||
|
||||
return rtrim($url, '/');
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user