From 28cd3e01a7dc249a5bbb9147e15005ee9f2757d9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 3 Mar 2016 11:24:13 +1100 Subject: [PATCH 1/3] Bug fixes push notifications --- app/Http/Controllers/AccountApiController.php | 11 ++++++----- composer.lock | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index ffbc17568a01..57b8fd17b68a 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -163,24 +163,25 @@ class AccountApiController extends BaseAPIController $devices = json_decode($account->devices, TRUE); if(count($devices)<1) - return $this->errorResponse(['message'=>'no devices exist'], 400); + return $this->errorResponse(['message'=>'No registered devices.'], 400); for($x=0; $xusername) { - unset($devices[$x]); $newDevice = [ - 'token' => $request->token, - 'email' => $request->email, - 'device' => $request->device, + 'token' => $devices[$x]['token'], + 'email' => $devices[$x]['email'], + 'device' => $devices[$x]['device'], 'notify_sent' => $request->notify_sent, 'notify_viewed' => $request->notify_viewed, 'notify_approved' => $request->notify_approved, 'notify_paid' => $request->notify_paid, ]; + unset($devices[$x]); + $devices[] = $newDevice; $account->devices = json_encode($devices); $account->save(); diff --git a/composer.lock b/composer.lock index 61af58eb88b9..eaa49a541873 100644 --- a/composer.lock +++ b/composer.lock @@ -123,12 +123,12 @@ "source": { "type": "git", "url": "https://github.com/formers/former.git", - "reference": "795f7b9b200a4ff4a33b37a96eaaab0229e36325" + "reference": "e196c4336db77be97131f6a3b3c3b69b3a22b683" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/formers/former/zipball/795f7b9b200a4ff4a33b37a96eaaab0229e36325", - "reference": "795f7b9b200a4ff4a33b37a96eaaab0229e36325", + "url": "https://api.github.com/repos/formers/former/zipball/e196c4336db77be97131f6a3b3c3b69b3a22b683", + "reference": "e196c4336db77be97131f6a3b3c3b69b3a22b683", "shasum": "" }, "require": { @@ -174,7 +174,7 @@ "foundation", "laravel" ], - "time": "2015-11-05 15:53:52" + "time": "2016-03-02 17:21:21" }, { "name": "anahkiasen/html-object", From 9744ad69b77d3f2a1f6303080e690c180a6fd868 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 3 Mar 2016 13:28:16 +1100 Subject: [PATCH 2/3] Localization API & PUSH --- app/Http/Controllers/AccountApiController.php | 2 +- app/Services/PushService.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/AccountApiController.php b/app/Http/Controllers/AccountApiController.php index 57b8fd17b68a..c4672954124d 100644 --- a/app/Http/Controllers/AccountApiController.php +++ b/app/Http/Controllers/AccountApiController.php @@ -162,7 +162,7 @@ class AccountApiController extends BaseAPIController $devices = json_decode($account->devices, TRUE); - if(count($devices)<1) + if(count($devices) < 1) return $this->errorResponse(['message'=>'No registered devices.'], 400); for($x=0; $xis_quote) - return "Quote #{$invoice->invoice_number} sent!"; + return trans("texts.notification_quote_sent_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); else - return "Invoice #{$invoice->invoice_number} sent"; + return trans("texts.notification_invoice_sent_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); } @@ -141,7 +141,7 @@ class PushService */ private function invoicePaidMessage($invoice) { - return "Invoice #{$invoice->invoice_number} paid!"; + return trans("texts.notification_invoice_paid_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); } /** @@ -150,7 +150,7 @@ class PushService */ private function quoteApprovedMessage($invoice) { - return "Quote #{$invoice->invoice_number} approved!"; + return trans("texts.notification_quote_approved_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); } /** @@ -160,9 +160,9 @@ class PushService private function entityViewedMessage($invoice) { if($invoice->is_quote) - return "Quote #{$invoice->invoice_number} viewed!"; + return trans("texts.notification_quote_viewed_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); else - return "Invoice #{$invoice->invoice_number} viewed!"; + return trans("texts.notification_invoice_viewed_subject", ['invoice' => $invoice->invoice_number, 'client' => $invoice->client->name]); } From a42202650e4e809582fdbef84dd32b17894bd578 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 3 Mar 2016 14:21:00 +1100 Subject: [PATCH 3/3] bug fixes --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index eaa49a541873..61af58eb88b9 100644 --- a/composer.lock +++ b/composer.lock @@ -123,12 +123,12 @@ "source": { "type": "git", "url": "https://github.com/formers/former.git", - "reference": "e196c4336db77be97131f6a3b3c3b69b3a22b683" + "reference": "795f7b9b200a4ff4a33b37a96eaaab0229e36325" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/formers/former/zipball/e196c4336db77be97131f6a3b3c3b69b3a22b683", - "reference": "e196c4336db77be97131f6a3b3c3b69b3a22b683", + "url": "https://api.github.com/repos/formers/former/zipball/795f7b9b200a4ff4a33b37a96eaaab0229e36325", + "reference": "795f7b9b200a4ff4a33b37a96eaaab0229e36325", "shasum": "" }, "require": { @@ -174,7 +174,7 @@ "foundation", "laravel" ], - "time": "2016-03-02 17:21:21" + "time": "2015-11-05 15:53:52" }, { "name": "anahkiasen/html-object",