From 88696c4eecaed9d28b93d4a17acf39927585d9ce Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 2 Mar 2016 16:29:26 +0200 Subject: [PATCH 1/6] Added auth check in subscription listeners --- app/Listeners/SubscriptionListener.php | 28 ++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/app/Listeners/SubscriptionListener.php b/app/Listeners/SubscriptionListener.php index 2d12fcaeb9..c3f1d9d803 100644 --- a/app/Listeners/SubscriptionListener.php +++ b/app/Listeners/SubscriptionListener.php @@ -24,29 +24,49 @@ class SubscriptionListener { public function createdClient(ClientWasCreated $event) { + if ( ! Auth::check()) { + return; + } + $transformer = new ClientTransformer(Auth::user()->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CLIENT, $event->client, $transformer); } public function createdQuote(QuoteWasCreated $event) { + if ( ! Auth::check()) { + return; + } + $transformer = new InvoiceTransformer(Auth::user()->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_QUOTE, $event->quote, $transformer, ENTITY_CLIENT); } public function createdPayment(PaymentWasCreated $event) { + if ( ! Auth::check()) { + return; + } + $transformer = new PaymentTransformer(Auth::user()->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_PAYMENT, $event->payment, $transformer, [ENTITY_CLIENT, ENTITY_INVOICE]); } public function createdCredit(CreditWasCreated $event) { + if ( ! Auth::check()) { + return; + } + //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_CREDIT, $event->credit); } public function createdInvoice(InvoiceWasCreated $event) { + if ( ! Auth::check()) { + return; + } + $transformer = new InvoiceTransformer(Auth::user()->account); $this->checkSubscriptions(ACTIVITY_TYPE_CREATE_INVOICE, $event->invoice, $transformer, ENTITY_CLIENT); } @@ -55,7 +75,7 @@ class SubscriptionListener { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_VENDOR, $event->vendor); } - + public function createdExpense(ExpenseWasCreated $event) { //$this->checkSubscriptions(ACTIVITY_TYPE_CREATE_EXPENSE, $event->expense); @@ -69,11 +89,11 @@ class SubscriptionListener $manager = new Manager(); $manager->setSerializer(new ArraySerializer()); $manager->parseIncludes($include); - + $resource = new Item($entity, $transformer, $entity->getEntityType()); $data = $manager->createData($resource)->toArray(); - + Utils::notifyZapier($subscription, $data); } } -} +} \ No newline at end of file From ab8f40517fc0e95c99343fe82508a1ed9cb80eeb Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 2 Mar 2016 22:51:13 +0200 Subject: [PATCH 2/6] Fix for tests --- .travis.yml | 3 ++- database/seeds/PaymentLibrariesSeeder.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7dd08d994..9a1a2f53b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,10 +34,11 @@ install: # these providers require referencing git commit's which cause Travis to fail - sed -i '/mollie/d' composer.json - sed -i '/2checkout/d' composer.json + - sed -i '/omnipay-neteller/d' composer.json - travis_retry composer install --prefer-dist; before_script: - # prevent MySQL went away error + # prevent MySQL went away error - mysql -u root -e 'SET @@GLOBAL.wait_timeout=28800;' # copy configuration files - cp .env.example .env diff --git a/database/seeds/PaymentLibrariesSeeder.php b/database/seeds/PaymentLibrariesSeeder.php index d4d01c76fd..8710357a36 100644 --- a/database/seeds/PaymentLibrariesSeeder.php +++ b/database/seeds/PaymentLibrariesSeeder.php @@ -32,7 +32,7 @@ class PaymentLibrariesSeeder extends Seeder ['name' => 'Buckaroo', 'provider' => 'Buckaroo_CreditCard', 'payment_library_id' => 1], ['name' => 'Coinbase', 'provider' => 'Coinbase', 'payment_library_id' => 1], ['name' => 'DataCash', 'provider' => 'DataCash', 'payment_library_id' => 1], - ['name' => 'Neteller', 'provider' => 'Neteller', 'payment_library_id' => 1], + ['name' => 'Neteller', 'provider' => 'Neteller', 'payment_library_id' => 2], ['name' => 'Pacnet', 'provider' => 'Pacnet', 'payment_library_id' => 1], ['name' => 'PaymentSense', 'provider' => 'PaymentSense', 'payment_library_id' => 1], ['name' => 'Realex', 'provider' => 'Realex_Remote', 'payment_library_id' => 1], @@ -157,7 +157,7 @@ class PaymentLibrariesSeeder extends Seeder ['format' => 'd-m-Y', 'picker_format' => 'dd-mm-yyyy', 'label' => '20-03-2013'], ['format' => 'm/d/Y', 'picker_format' => 'mm/dd/yyyy', 'label' => '03/20/2013'] ]; - + foreach ($formats as $format) { $record = DateFormat::whereLabel($format['label'])->first(); if ($record) { @@ -224,7 +224,7 @@ class PaymentLibrariesSeeder extends Seeder 'label' => '03/20/2013 6:15 pm' ] ]; - + foreach ($formats as $format) { $record = DatetimeFormat::whereLabel($format['label'])->first(); if ($record) { @@ -250,7 +250,7 @@ class PaymentLibrariesSeeder extends Seeder 'Playful', 'Photo', ]; - + for ($i=0; $i Date: Sun, 6 Mar 2016 08:13:01 +0200 Subject: [PATCH 3/6] Git update --- app/Http/routes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index f7bed59f68..0f2fb017f4 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -1,5 +1,6 @@ id === 1) { Auth::loginUsingId(1); } -*/ \ No newline at end of file +*/ From 93d9d3828685e257a09da65ffae88f285ee52d4f Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 6 Mar 2016 08:13:52 +0200 Subject: [PATCH 4/6] Git update --- app/Http/routes.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index 0f2fb017f4..661d9514ee 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -1,6 +1,5 @@ Date: Mon, 7 Mar 2016 17:26:57 +0200 Subject: [PATCH 5/6] Added warning if cache isn't set --- app/Libraries/Utils.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Libraries/Utils.php b/app/Libraries/Utils.php index 027f512a47..d0b17df7f0 100644 --- a/app/Libraries/Utils.php +++ b/app/Libraries/Utils.php @@ -274,7 +274,14 @@ class Utils } public static function getFromCache($id, $type) { - $data = Cache::get($type)->filter(function($item) use ($id) { + $cache = Cache::get($type); + + if ( ! $cache) { + static::logError("Cache for {$type} is not set"); + return null; + } + + $data = $cache->filter(function($item) use ($id) { return $item->id == $id; }); From 5bedad47e468413d84bc85ac8b459af97810dee6 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 7 Mar 2016 17:34:59 +0200 Subject: [PATCH 6/6] Bumped version to 2.5.0.4 --- app/Http/routes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/routes.php b/app/Http/routes.php index 661d9514ee..55ca02d103 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -509,7 +509,7 @@ if (!defined('CONTACT_EMAIL')) { define('NINJA_GATEWAY_CONFIG', 'NINJA_GATEWAY_CONFIG'); define('NINJA_WEB_URL', 'https://www.invoiceninja.com'); define('NINJA_APP_URL', 'https://app.invoiceninja.com'); - define('NINJA_VERSION', '2.5.0.3'); + define('NINJA_VERSION', '2.5.0.4'); define('NINJA_DATE', '2000-01-01'); define('SOCIAL_LINK_FACEBOOK', 'https://www.facebook.com/invoiceninja');