Merge branch 'release/0.16.1'

This commit is contained in:
Jonny Barnes 2018-02-17 21:58:37 +00:00
commit 97a13bc636
3 changed files with 49 additions and 4 deletions

View file

@ -142,10 +142,11 @@ class NoteService
*/ */
private function getCheckin(array $request): ?Place 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 { try {
$place = resolve(PlaceService::class)->createPlaceFromCheckin( $place = resolve(PlaceService::class)->createPlaceFromCheckin(
array_get($request, 'properties.location.0') $location
); );
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
return null; return null;
@ -153,12 +154,12 @@ class NoteService
return $place; 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( return Place::where(
'slug', 'slug',
basename( basename(
parse_url( parse_url(
array_get($request, 'properties.location.0'), $location,
PHP_URL_PATH PHP_URL_PATH
) )
) )

View file

@ -1,5 +1,8 @@
# Changelog # Changelog
## Version 0.16.1 (2018-02-17)
- Fix issue where OwnYourSwarm requests inlude h-adr block for location
## Version 0.16 (2018-02-16) ## Version 0.16 (2018-02-16)
- Update Laravel to 5.6 - Update Laravel to 5.6
- Fix issue with creating alternative Facebook content when no contacts - Fix issue with creating alternative Facebook content when no contacts

View file

@ -187,4 +187,45 @@ class SwarmTest extends TestCase
'name' => 'Awesome Venue', '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 <a href="http://example.org">Example Product</a>',
]],
'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',
]);
}
} }