diff --git a/.env.example b/.env.example index f08acd05bc0f..19c98183f300 100644 --- a/.env.example +++ b/.env.example @@ -26,7 +26,7 @@ BROADCAST_DRIVER=log LOG_CHANNEL=stack CACHE_DRIVER=file QUEUE_CONNECTION=database -SESSION_DRIVER=file +SESSION_DRIVER=cookie SESSION_LIFETIME=120 REDIS_HOST=127.0.0.1 @@ -46,7 +46,6 @@ POSTMARK_API_TOKEN= REQUIRE_HTTPS=false GOOGLE_MAPS_API_KEY= -API_SECRET=superdoopersecrethere ERROR_EMAIL= TRUSTED_PROXIES= diff --git a/.htaccess b/.htaccess index 886d649923e3..753c7e35614c 100644 --- a/.htaccess +++ b/.htaccess @@ -1,7 +1,7 @@ RewriteEngine On RewriteRule "^.env" - [F,L] - RewriteRule "^storage" - [F,L] +# RewriteRule "^storage" - [F,L] RewriteRule ^(.well-known)($|/) - [L] RewriteRule ^(.*)$ public/$1 [L] diff --git a/app/Console/Commands/ImportMigrations.php b/app/Console/Commands/ImportMigrations.php index bfbc60cd6d08..069cf5ebcfe9 100644 --- a/app/Console/Commands/ImportMigrations.php +++ b/app/Console/Commands/ImportMigrations.php @@ -12,7 +12,15 @@ namespace App\Console\Commands; use App\DataMapper\CompanySettings; +use App\Exceptions\MigrationValidatorFailed; +use App\Exceptions\NonExistingMigrationFile; +use App\Exceptions\ProcessingMigrationArchiveFailed; +use App\Exceptions\ResourceDependencyMissing; +use App\Exceptions\ResourceNotAvailableForMigration; +use App\Jobs\Util\Import; use App\Jobs\Util\StartMigration; +use App\Libraries\MultiDB; +use App\Mail\MigrationFailed; use App\Models\Account; use App\Models\Company; use App\Models\CompanyToken; @@ -24,6 +32,7 @@ use Faker\Factory; use Faker\Generator; use Illuminate\Console\Command; use Illuminate\Support\Str; +use ZipArchive; class ImportMigrations extends Command { @@ -69,17 +78,45 @@ class ImportMigrations extends Command public function handle() { $this->buildCache(); - - $path = $this->option('path') ?? storage_path('migrations/import'); + + $path = $this->option('path') ?? public_path('storage/migrations/import'); $directory = new DirectoryIterator($path); foreach ($directory as $file) { if ($file->getExtension() === 'zip') { + + $user = $this->getUser(); + $company = $this->getUser()->companies()->first(); + $this->info('Started processing: '.$file->getBasename().' at '.now()); - StartMigration::dispatch($file->getRealPath(), $this->getUser(), $this->getUser()->companies()->first()); - } - } + + $zip = new ZipArchive(); + $archive = $zip->open($file->getRealPath()); + + try { + if (! $archive) { + throw new ProcessingMigrationArchiveFailed('Processing migration archive failed. Migration file is possibly corrupted.'); + } + + $filename = pathinfo($file->getRealPath(), PATHINFO_FILENAME); + + $zip->extractTo(public_path("storage/migrations/{$filename}")); + $zip->close(); + + $import_file = public_path("storage/migrations/$filename/migration.json"); + + Import::dispatch($import_file, $this->getUser()->companies()->first(), $this->getUser()); + // StartMigration::dispatch($file->getRealPath(), $this->getUser(), $this->getUser()->companies()->first()); + } + catch (NonExistingMigrationFile | ProcessingMigrationArchiveFailed | ResourceNotAvailableForMigration | MigrationValidatorFailed | ResourceDependencyMissing $e) { + \Mail::to($this->user)->send(new MigrationFailed($e, $e->getMessage())); + + if (app()->environment() !== 'production') { + info($e->getMessage()); + } + + }}} } public function getUser(): User diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index 3d9a8639069d..b1febefdab7a 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -55,7 +55,7 @@ class CompanySettings extends BaseSettings public $default_task_rate = 0; // @TODO Where do we inject this? public $payment_terms = ''; //@implemented - public $send_reminders = false; //@TODO + public $send_reminders = true; //@TODO public $custom_message_dashboard = ''; // @TODO There currently is no dashboard so this is pending public $custom_message_unpaid_invoice = ''; diff --git a/app/Http/Requests/ClientPortal/ShowInvoiceRequest.php b/app/Http/Requests/ClientPortal/ShowInvoiceRequest.php index fef7bb800963..0fa25695e129 100644 --- a/app/Http/Requests/ClientPortal/ShowInvoiceRequest.php +++ b/app/Http/Requests/ClientPortal/ShowInvoiceRequest.php @@ -22,6 +22,6 @@ class ShowInvoiceRequest extends Request */ public function authorize() : bool { - return auth('contact')->user()->client->id === $this->invoice->client_id; + return auth('contact')->user()->client->id == $this->invoice->client_id; } } diff --git a/app/Jobs/Util/Import.php b/app/Jobs/Util/Import.php index 7b210f32cb79..54c5378c5efb 100644 --- a/app/Jobs/Util/Import.php +++ b/app/Jobs/Util/Import.php @@ -177,6 +177,9 @@ class Import implements ShouldQueue { set_time_limit(0); + auth()->login($this->user, false); + auth()->user()->setCompany($this->company); + // $jsonStream = \JsonMachine\JsonMachine::fromFile($this->file_path, "/data"); $array = json_decode(file_get_contents($this->file_path), 1); $data = $array['data']; diff --git a/app/Transformers/ActivityTransformer.php b/app/Transformers/ActivityTransformer.php index 887f0b776c34..1acf4f1b49a1 100644 --- a/app/Transformers/ActivityTransformer.php +++ b/app/Transformers/ActivityTransformer.php @@ -39,6 +39,7 @@ class ActivityTransformer extends EntityTransformer 'company_id' => $activity->company_id ? (string) $this->encodePrimaryKey($activity->company_id) : '', 'user_id' => (string) $this->encodePrimaryKey($activity->user_id), 'invoice_id' => $activity->invoice_id ? (string) $this->encodePrimaryKey($activity->invoice_id) : '', + 'quote_id' => $activity->quote_id ? (string) $this->encodePrimaryKey($activity->quote_id) : '', 'payment_id' => $activity->payment_id ? (string) $this->encodePrimaryKey($activity->payment_id) : '', 'credit_id' => $activity->credit_id ? (string) $this->encodePrimaryKey($activity->credit_id) : '', 'updated_at' => (int) $activity->updated_at, diff --git a/config/filesystems.php b/config/filesystems.php index 76d21e4bac5d..01a12dad13eb 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -75,7 +75,6 @@ return [ ], ], ], - 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), diff --git a/resources/views/index/index.blade.php b/resources/views/index/index.blade.php index 5c629c81066f..165f82c7eaf2 100644 --- a/resources/views/index/index.blade.php +++ b/resources/views/index/index.blade.php @@ -88,7 +88,7 @@ if ('serviceWorker' in navigator) { window.addEventListener('load', function () { - navigator.serviceWorker.register('/flutter_service_worker.js?v={{ config('ninja.app_version') }}'); + navigator.serviceWorker.register('flutter_service_worker.js?v={{ config('ninja.app_version') }}'); }); }