From 033e221d2f4da57eba5c3f1b2dbebd91677a378b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 21 Apr 2021 13:54:10 +1000 Subject: [PATCH 1/2] Adjustments for recurring invoice cron --- .../Controllers/Traits/VerifiesUserEmail.php | 9 ++++++ app/Jobs/RecurringInvoice/SendRecurring.php | 18 +++++------ config/database.php | 30 ++++++++++--------- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/app/Http/Controllers/Traits/VerifiesUserEmail.php b/app/Http/Controllers/Traits/VerifiesUserEmail.php index 74232e3fc7..cf5cc73a7d 100644 --- a/app/Http/Controllers/Traits/VerifiesUserEmail.php +++ b/app/Http/Controllers/Traits/VerifiesUserEmail.php @@ -43,6 +43,15 @@ trait VerifiesUserEmail $user->confirmation_code = null; $user->save(); + if(isset($user->oauth_user_id)){ + + return $this->render('auth.confirmed', [ + 'root' => 'themes', + 'message' => ctrans('texts.security_confirmation'), + ]); + + } + if (is_null($user->password) || empty($user->password) || Hash::check('', $user->password)) { return $this->render('auth.confirmation_with_password', ['root' => 'themes', 'user_id' => $user->hashed_id]); } diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index e0dec9726c..8a70e621be 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -68,15 +68,6 @@ class SendRecurring implements ShouldQueue ->fillDefaults() ->save(); - nlog("Invoice {$invoice->number} created"); - - $invoice->invitations->each(function ($invitation) use ($invoice) { - if ($invitation->contact && strlen($invitation->contact->email) >=1) { - EmailEntity::dispatch($invitation, $invoice->company); - nlog("Firing email for invoice {$invoice->number}"); - } - }); - nlog("updating recurring invoice dates"); /* Set next date here to prevent a recurring loop forming */ $this->recurring_invoice->next_send_date = $this->recurring_invoice->nextSendDate()->format('Y-m-d'); @@ -99,6 +90,15 @@ class SendRecurring implements ShouldQueue $invoice->entityEmailEvent($invoice->invitations->first(), 'invoice', 'email_template_invoice'); } + nlog("Invoice {$invoice->number} created"); + + $invoice->invitations->each(function ($invitation) use ($invoice) { + if ($invitation->contact && strlen($invitation->contact->email) >=1) { + EmailEntity::dispatch($invitation, $invoice->company); + nlog("Firing email for invoice {$invoice->number}"); + } + }); + if ($invoice->client->getSetting('auto_bill_date') == 'on_send_date' && $this->recurring_invoice->auto_bill_enabled) { nlog("attempting to autobill {$invoice->number}"); $invoice->service()->autoBill()->save(); diff --git a/config/database.php b/config/database.php index a59440a08e..dbccc25c3c 100644 --- a/config/database.php +++ b/config/database.php @@ -154,13 +154,14 @@ return [ ], 'sentinel-default' => array_merge( - array_map( - function ($a, $b) { - return ["host" => $a,"port" => $b]; - }, - explode(',', env('REDIS_HOST', 'localhost')), - explode(',', env('REDIS_PORT', 26379)) - ), + [ + "host" => "v5db1", + "port" => "26379", + ], + [ + "host" => "v5db2", + "port" => "26379", + ], ['options' => [ 'replication' => 'sentinel', 'service' => env('REDIS_SENTINEL_SERVICE', 'mymaster'), @@ -172,13 +173,14 @@ return [ ), 'sentinel-cache' => array_merge( - array_map( - function ($a, $b) { - return ["host" => $a,"port" => $b]; - }, - explode(',', env('REDIS_HOST', 'localhost')), - explode(',', env('REDIS_PORT', 26379)) - ), + [ + "host" => "v5db1", + "port" => "26379", + ], + [ + "host" => "v5db2", + "port" => "26379", + ], ['options' => [ 'replication' => 'sentinel', 'service' => env('REDIS_SENTINEL_SERVICE', 'mymaster'), From 6021f31ab4ab88b6ec27eba3ade6735073a34114 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 21 Apr 2021 14:18:03 +1000 Subject: [PATCH 2/2] Redis Sentinel configuration --- composer.json | 1 + composer.lock | 165 +++++++++++++++++++++++++++++++++++++++++++- config/cache.php | 4 ++ config/database.php | 23 ++++++ config/queue.php | 7 ++ config/session.php | 2 +- 6 files changed, 200 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 12254fd486..fff14da8ad 100644 --- a/composer.json +++ b/composer.json @@ -58,6 +58,7 @@ "league/omnipay": "^3.1", "livewire/livewire": "^2.0", "maennchen/zipstream-php": "^1.2", + "monospice/laravel-redis-sentinel-drivers": "^2.7", "nwidart/laravel-modules": "^8.0", "omnipay/paypal": "^3.0", "pragmarx/google2fa": "^8.0", diff --git a/composer.lock b/composer.lock index 25bd1c789e..3c218742df 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f01381d3d00f0bd84acbda078ad1b99e", + "content-hash": "131c90cf17cbf87d1fc25b96c052a8e3", "packages": [ { "name": "authorizenet/authorizenet", @@ -4175,6 +4175,169 @@ ], "time": "2020-12-14T13:15:25+00:00" }, + { + "name": "monospice/laravel-redis-sentinel-drivers", + "version": "2.x-dev", + "source": { + "type": "git", + "url": "https://github.com/monospice/laravel-redis-sentinel-drivers.git", + "reference": "5b1c107d2fc511c26829c5c5b57957e31dc32807" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/monospice/laravel-redis-sentinel-drivers/zipball/5b1c107d2fc511c26829c5c5b57957e31dc32807", + "reference": "5b1c107d2fc511c26829c5c5b57957e31dc32807", + "shasum": "" + }, + "require": { + "illuminate/cache": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "illuminate/contracts": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "illuminate/queue": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "illuminate/redis": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "illuminate/session": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "illuminate/support": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "monospice/spicy-identifiers": "^0.1", + "php": ">=5.6.4", + "predis/predis": "^1.1" + }, + "require-dev": { + "laravel/framework": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "laravel/horizon": "^1.0 || ^2.0 || ^3.0 || ^4.0", + "laravel/lumen-framework": "^5.4 || ^6.0 || ^7.0 || ^8.0", + "mockery/mockery": "^1.3", + "phpunit/phpunit": "^5.0" + }, + "default-branch": true, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Monospice\\LaravelRedisSentinel\\RedisSentinelServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Monospice\\LaravelRedisSentinel\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cy Rossignol", + "email": "cy@rossignols.me" + } + ], + "description": "Redis Sentinel integration for Laravel and Lumen.", + "keywords": [ + "laravel", + "lumen", + "redis", + "sentinel" + ], + "support": { + "issues": "https://github.com/monospice/laravel-redis-sentinel-drivers/issues", + "source": "https://github.com/monospice/laravel-redis-sentinel-drivers/tree/integration-tests" + }, + "time": "2020-09-08T06:14:57+00:00" + }, + { + "name": "monospice/spicy-identifier-tools", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/monospice/spicy-identifier-tools.git", + "reference": "8659493c64d3023c38bf4f325bff86fbb53c085a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/monospice/spicy-identifier-tools/zipball/8659493c64d3023c38bf4f325bff86fbb53c085a", + "reference": "8659493c64d3023c38bf4f325bff86fbb53c085a", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpspec/phpspec": "~2.2", + "phpunit/phpunit": "~4.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "Monospice\\SpicyIdentifiers\\Tools\\": "src/Tools" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cy Rossignol", + "email": "cy.rossignol@yahoo.com" + } + ], + "description": "An easy way to parse, convert, and format identifier names.", + "support": { + "issues": "https://github.com/monospice/spicy-identifier-tools/issues", + "source": "https://github.com/monospice/spicy-identifier-tools/tree/1.0.3" + }, + "time": "2015-11-04T19:00:37+00:00" + }, + { + "name": "monospice/spicy-identifiers", + "version": "0.1.0", + "source": { + "type": "git", + "url": "https://github.com/monospice/spicy-identifiers.git", + "reference": "ecd04ca84907f2f0d58bf3b2bb9a36d7d29d86bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/monospice/spicy-identifiers/zipball/ecd04ca84907f2f0d58bf3b2bb9a36d7d29d86bd", + "reference": "ecd04ca84907f2f0d58bf3b2bb9a36d7d29d86bd", + "shasum": "" + }, + "require": { + "monospice/spicy-identifier-tools": "~1.0", + "php": ">=5.4.0" + }, + "require-dev": { + "phpspec/phpspec": "~2.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Monospice\\SpicyIdentifiers\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cy Rossignol", + "email": "cy@rossignols.me" + } + ], + "description": "An easy way to parse and manipulate identifier names, such as dynamic method names.", + "keywords": [ + "dynamic", + "method", + "parser", + "variable" + ], + "support": { + "issues": "https://github.com/monospice/spicy-identifiers/issues", + "source": "https://github.com/monospice/spicy-identifiers/tree/1.0.x" + }, + "time": "2017-01-29T09:00:23+00:00" + }, { "name": "mtdowling/jmespath.php", "version": "2.6.0", diff --git a/config/cache.php b/config/cache.php index b054ca87d6..a18a947d0e 100644 --- a/config/cache.php +++ b/config/cache.php @@ -86,6 +86,10 @@ return [ 'endpoint' => env('DYNAMODB_ENDPOINT'), ], + 'redis-sentinel' => [ + 'driver' => 'redis-sentinel', + 'connection' => 'default', + ], ], /* diff --git a/config/database.php b/config/database.php index dbccc25c3c..9609cb8464 100644 --- a/config/database.php +++ b/config/database.php @@ -193,4 +193,27 @@ return [ ], + 'redis-sentinel' => [ + + 'default' => [ + [ + 'host' => 'v5db1', + 'port' => 26379, + ], + [ + 'host' => 'v5db2', + 'port' => 26379, + ], + ], + + 'options' => [ + 'service' => env('REDIS_SENTINEL_SERVICE', 'mymaster'), + 'parameters' => [ + 'password' => env('REDIS_PASSWORD', null), + 'database' => 0, + ], + ], + + ], + ]; diff --git a/config/queue.php b/config/queue.php index 8f826c982b..7a42ca0b0a 100644 --- a/config/queue.php +++ b/config/queue.php @@ -67,6 +67,13 @@ return [ 'block_for' => null, ], + 'redis-sentinel' => [ + 'driver' => 'redis-sentinel', + 'connection' => 'default', + 'queue' => 'default', + 'retry_after' => 90, // Laravel >= 5.4.30 + 'expire' => 90, // Laravel < 5.4.30 + ], ], /* diff --git a/config/session.php b/config/session.php index 4e0f66cda6..1122a33a17 100644 --- a/config/session.php +++ b/config/session.php @@ -72,7 +72,7 @@ return [ | */ - 'connection' => env('SESSION_CONNECTION', null), + 'connection' => env('SESSION_CONNECTION', 'default'), /* |--------------------------------------------------------------------------