From 8ddab8b1de40c848d0eaa47628976bf7d25756d2 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sat, 17 Feb 2018 21:49:35 +0000 Subject: [PATCH 1/4] Add test for OwnYourSwarm request with h-adr location value --- tests/Feature/SwarmTest.php | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/Feature/SwarmTest.php b/tests/Feature/SwarmTest.php index 7e8f133b..8f92c4f3 100644 --- a/tests/Feature/SwarmTest.php +++ b/tests/Feature/SwarmTest.php @@ -187,4 +187,45 @@ class SwarmTest extends TestCase 'name' => 'Awesome Venue', ]); } + + public function test_ownyourswarm_request_with_hadr_location() + { + $response = $this->json( + 'POST', + 'api/post', + [ + 'type' => ['h-entry'], + 'properties' => [ + 'published' => [\Carbon\Carbon::now()->toDateTimeString()], + 'syndication' => ['https://www.swarmapp.com/checkin/abc'], + 'content' => [[ + 'value' => 'My first #checkin using Example Product', + 'html' => 'My first #checkin using Example Product', + ]], + 'location' => [[ + 'type' => ['h-adr'], + 'properties' => [ + 'latitude' => ['1.23'], + 'longitude' => ['4.56'], + 'street-address' => ['Awesome Street'], + ], + ]], + 'checkin' => [[ + 'type' => ['h-card'], + 'properties' => [ + 'name' => ['Awesome Venue'], + 'url' => ['https://foursquare.com/v/123456'], + ], + ]], + ], + ], + ['HTTP_Authorization' => 'Bearer ' . $this->getToken()] + ); + $response + ->assertStatus(201) + ->assertJson(['response' => 'created']); + $this->assertDatabaseMissing('places', [ + 'name' => 'Awesome Venue', + ]); + } } From 79d0e789058302e7da915386208a7fdfcdec14bb Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sat, 17 Feb 2018 21:50:46 +0000 Subject: [PATCH 2/4] Ignore (for now), OwnYourSwarm requests with h-adr location value --- app/Services/NoteService.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Services/NoteService.php b/app/Services/NoteService.php index b29f5d3c..eb3e25a0 100644 --- a/app/Services/NoteService.php +++ b/app/Services/NoteService.php @@ -142,10 +142,11 @@ class NoteService */ private function getCheckin(array $request): ?Place { - if (array_get($request, 'properties.location.0.type.0') === 'h-card') { + $location = array_get($request, 'properties.location.0'); + if (array_get($location, 'type.0') === 'h-card') { try { $place = resolve(PlaceService::class)->createPlaceFromCheckin( - array_get($request, 'properties.location.0') + $location ); } catch (\InvalidArgumentException $e) { return null; @@ -153,12 +154,12 @@ class NoteService return $place; } - if (starts_with(array_get($request, 'properties.location.0'), config('app.url'))) { + if (is_string($location) && starts_with($location, config('app.url'))) { return Place::where( 'slug', basename( parse_url( - array_get($request, 'properties.location.0'), + $location, PHP_URL_PATH ) ) From 3abb5272d26d7709a2d90797dacad36c7ead851e Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sat, 17 Feb 2018 21:51:41 +0000 Subject: [PATCH 3/4] Update changelog --- changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.md b/changelog.md index 6acc263c..dfa10cac 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # Changelog +## Version {next} + - Fix issue where OwnYourSwarm requests inlude h-adr block for location + ## Version 0.16 (2018-02-16) - Update Laravel to 5.6 - Fix issue with creating alternative Facebook content when no contacts From 54045d793126f4295d7c80d2fe45454a77a4ccb1 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sat, 17 Feb 2018 21:58:04 +0000 Subject: [PATCH 4/4] Bump version to 0.16.1 --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index dfa10cac..a5d9f48d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,6 @@ # Changelog -## Version {next} +## Version 0.16.1 (2018-02-17) - Fix issue where OwnYourSwarm requests inlude h-adr block for location ## Version 0.16 (2018-02-16)