From 4451fc247eb4c8b5675e887058853114b9279617 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Sat, 14 Mar 2026 19:18:00 +0000 Subject: [PATCH] Fix OwnYourSwarm checkin parsing to read from properties.checkin Real OwnYourSwarm requests send the checkin h-card inside properties.checkin (as an array), not at the top level. The code was reading from the top-level key so no Place was ever created, leaving checkin notes blank. Update tests to match the real request format. Co-Authored-By: Claude Sonnet 4.6 --- app/Services/Micropub/Data/EntryData.php | 2 +- tests/Feature/SwarmTest.php | 172 +++++++++++------------ 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/app/Services/Micropub/Data/EntryData.php b/app/Services/Micropub/Data/EntryData.php index 8942be78..52dde72d 100644 --- a/app/Services/Micropub/Data/EntryData.php +++ b/app/Services/Micropub/Data/EntryData.php @@ -46,7 +46,7 @@ class EntryData extends MicropubData name: Arr::get($data, 'properties.name.0'), description: Arr::get($data, 'properties.description.0'), geo: Arr::get($data, 'properties.geo.0'), - checkin: Arr::get($data, 'checkin'), + checkin: Arr::get($data, 'properties.checkin.0'), syndication: Arr::get($data, 'properties.syndication.0'), photos: Arr::get($data, 'properties.photo'), ); diff --git a/tests/Feature/SwarmTest.php b/tests/Feature/SwarmTest.php index 76caa962..85729c0a 100644 --- a/tests/Feature/SwarmTest.php +++ b/tests/Feature/SwarmTest.php @@ -37,15 +37,15 @@ class SwarmTest extends TestCase 'value' => 'My first #checkin using Example Product', 'html' => 'My first #checkin using Example Product', ]], - ], - 'checkin' => [ - 'type' => ['h-card'], - 'properties' => [ - 'name' => ['Awesome Venue'], - 'url' => ['https://foursquare.com/v/123456'], - 'latitude' => ['1.23'], - 'longitude' => ['4.56'], - ], + 'checkin' => [[ + 'type' => ['h-card'], + 'properties' => [ + 'name' => ['Awesome Venue'], + 'url' => ['https://foursquare.com/v/123456'], + 'latitude' => ['1.23'], + 'longitude' => ['4.56'], + ], + ]], ], ], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()] @@ -64,7 +64,7 @@ class SwarmTest extends TestCase } /** - * This request would actually come from another client than OwnYourSwarm, but we’re testing + * This request would actually come from another client than OwnYourSwarm, but we're testing * OpenStreetMap data. */ #[Test] @@ -83,15 +83,15 @@ class SwarmTest extends TestCase 'value' => 'My first #checkin using Example Product', 'html' => 'My first #checkin using Example Product', ]], - ], - 'checkin' => [ - 'type' => ['h-card'], - 'properties' => [ - 'name' => ['Awesome Venue'], - 'url' => ['https://www.openstreetmap.org/way/123456'], - 'latitude' => ['1.23'], - 'longitude' => ['4.56'], - ], + 'checkin' => [[ + 'type' => ['h-card'], + 'properties' => [ + 'name' => ['Awesome Venue'], + 'url' => ['https://www.openstreetmap.org/way/123456'], + 'latitude' => ['1.23'], + 'longitude' => ['4.56'], + ], + ]], ], ], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()] @@ -125,15 +125,15 @@ class SwarmTest extends TestCase 'value' => 'My first #checkin using Example Product', 'html' => 'My first #checkin using Example Product', ]], - ], - 'checkin' => [ - 'type' => ['h-card'], - 'properties' => [ - 'name' => ['Awesome Venue'], - 'url' => ['https://www.example.org/way/123456'], - 'latitude' => ['1.23'], - 'longitude' => ['4.56'], - ], + 'checkin' => [[ + 'type' => ['h-card'], + 'properties' => [ + 'name' => ['Awesome Venue'], + 'url' => ['https://www.example.org/way/123456'], + 'latitude' => ['1.23'], + 'longitude' => ['4.56'], + ], + ]], ], ], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()] @@ -159,15 +159,15 @@ class SwarmTest extends TestCase 'properties' => [ 'published' => [Carbon::now()->toDateTimeString()], 'syndication' => ['https://www.swarmapp.com/checkin/def'], - ], - 'checkin' => [ - 'type' => ['h-card'], - 'properties' => [ - 'name' => ['Awesomer Venue'], - 'url' => ['https://foursquare.com/v/654321'], - 'latitude' => ['3.21'], - 'longitude' => ['6.54'], - ], + 'checkin' => [[ + 'type' => ['h-card'], + 'properties' => [ + 'name' => ['Awesomer Venue'], + 'url' => ['https://foursquare.com/v/654321'], + 'latitude' => ['3.21'], + 'longitude' => ['6.54'], + ], + ]], ], ], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()] @@ -202,13 +202,13 @@ class SwarmTest extends TestCase 'value' => 'My first #checkin using Example Product', 'html' => 'My first #checkin using Example Product', ]], - ], - 'checkin' => [ - 'type' => ['h-card'], - 'properties' => [ - 'name' => ['Awesome Venue'], - 'url' => ['https://foursquare.com/v/123456'], - ], + 'checkin' => [[ + 'type' => ['h-card'], + 'properties' => [ + 'name' => ['Awesome Venue'], + 'url' => ['https://foursquare.com/v/123456'], + ], + ]], ], ], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()] @@ -240,21 +240,21 @@ class SwarmTest extends TestCase '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'], - ], + '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()] @@ -279,34 +279,34 @@ class SwarmTest extends TestCase 'type' => ['h-entry'], 'properties' => [ 'published' => [Carbon::now()->toDateTimeString()], - ], - 'syndication' => [ - 'https://www.swarmapp.com/user/199841/checkin/5c4b1ac56dcf04002c0a4f58', - ], - 'checkin' => [ - 'type' => ['h-card'], - 'properties' => [ - 'name' => ['Forbidden Planet'], - 'url' => ['https://foursquare.com/v/4ade0e46f964a520bf6f21e3'], - 'latitude' => [53.483153021713], - 'longitude' => [-2.2350297792539], - 'street-address' => ['65 Oldham St.'], - 'locality' => ['Manchester'], - 'country-name' => ['United Kingdom'], - 'postal-code' => ['M1 1JR'], - ], - 'value' => 'https://foursquare.com/v/4ade0e46f964a520bf6f21e3', - ], - 'location' => [ - 'type' => ['h-adr'], - 'properties' => [ - 'latitude' => [53.483153021713], - 'longitude' => [-2.2350297792539], - 'street-address' => ['65 Oldham St.'], - 'locality' => ['Manchester'], - 'country-name' => ['United Kingdom'], - 'postal-code' => ['M1 1JR'], + 'syndication' => [ + 'https://www.swarmapp.com/user/199841/checkin/5c4b1ac56dcf04002c0a4f58', ], + 'checkin' => [[ + 'type' => ['h-card'], + 'properties' => [ + 'name' => ['Forbidden Planet'], + 'url' => ['https://foursquare.com/v/4ade0e46f964a520bf6f21e3'], + 'latitude' => [53.483153021713], + 'longitude' => [-2.2350297792539], + 'street-address' => ['65 Oldham St.'], + 'locality' => ['Manchester'], + 'country-name' => ['United Kingdom'], + 'postal-code' => ['M1 1JR'], + ], + 'value' => 'https://foursquare.com/v/4ade0e46f964a520bf6f21e3', + ]], + 'location' => [[ + 'type' => ['h-adr'], + 'properties' => [ + 'latitude' => [53.483153021713], + 'longitude' => [-2.2350297792539], + 'street-address' => ['65 Oldham St.'], + 'locality' => ['Manchester'], + 'country-name' => ['United Kingdom'], + 'postal-code' => ['M1 1JR'], + ], + ]], ], ], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]