From b4f0878dbb0b2029dbcfc4c50b36438bafef1cd6 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Mon, 13 Oct 2025 13:11:45 +0000 Subject: [PATCH 1/3] Ignore events other than play All events in gPodder are : - play - download - delete - new - flattr (see https://gpoddernet.readthedocs.io/en/latest/api/reference/events.html) `download` and `delete` are ignored by AntennaPod and cause issues with some frontends (see https://github.com/AntennaPod/AntennaPod/issues/6957#issuecomment-2050513363) For `new`, the official documentaion says "This state needs to be interpreted by receiving clients and does not delete any information on the webservice." However, gpodder-sync will erase position and total if client put some value in it (-1 most of the time). It does not respect the spec and should be ignored as well. `flattr` is undocumented and seems unused. By elimination, only play is really helpfull. We should not remove the action column because it can have NEW, DOWNLOAD and DELETE action already with -1 data and could cause damage if removed. --- lib/Controller/EpisodeActionController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Controller/EpisodeActionController.php b/lib/Controller/EpisodeActionController.php index 761979c..f2d9023 100644 --- a/lib/Controller/EpisodeActionController.php +++ b/lib/Controller/EpisodeActionController.php @@ -41,6 +41,7 @@ public function __construct( public function create(): JSONResponse { $episodeActionsArray = $this->filterEpisodesFromRequestParams($this->request->getParams()); + $episodeActionsArray = $this->filterOnlyPlays($episodeActionsArray); $this->episodeActionSaver->saveEpisodeActions($episodeActionsArray, $this->userId); return new JSONResponse(["timestamp" => time()]); @@ -74,4 +75,12 @@ public function list(int $since = 0): JSONResponse { public function filterEpisodesFromRequestParams(array $data): array { return array_filter($data, "is_numeric", ARRAY_FILTER_USE_KEY); } + + /** + * @param array $data + * @return array $episodeActionsArray + */ + public function filterOnlyPlays(array $data): array { + return array_filter($data, fn($ep) => isset($ep['action']) && strtolower($ep['action']) === 'play'); + } } From 8040c405cf01bad932916e846c1ec731e6aac948 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 16 Oct 2025 19:26:34 +0000 Subject: [PATCH 2/3] Add a better variables names on filter's functions --- lib/Controller/EpisodeActionController.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/Controller/EpisodeActionController.php b/lib/Controller/EpisodeActionController.php index f2d9023..19ff329 100644 --- a/lib/Controller/EpisodeActionController.php +++ b/lib/Controller/EpisodeActionController.php @@ -68,19 +68,11 @@ public function list(int $since = 0): JSONResponse { ]); } - /** - * @param array $data - * @return array $episodeActionsArray - */ - public function filterEpisodesFromRequestParams(array $data): array { - return array_filter($data, "is_numeric", ARRAY_FILTER_USE_KEY); + public function filterEpisodesFromRequestParams(array $episodesFromRequestParams): array { + return array_filter($episodesFromRequestParams, "is_numeric", ARRAY_FILTER_USE_KEY); } - /** - * @param array $data - * @return array $episodeActionsArray - */ - public function filterOnlyPlays(array $data): array { - return array_filter($data, fn($ep) => isset($ep['action']) && strtolower($ep['action']) === 'play'); + public function filterOnlyPlays(array $episodesFromRequestParams): array { + return array_filter($episodesFromRequestParams, fn($ep) => isset($ep['action']) && strtolower($ep['action']) === 'play'); } } From 361a64693bd80b0d168c1af06bf914f3da1e0aad Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Wed, 5 Nov 2025 12:00:02 +0000 Subject: [PATCH 3/3] Add a test that proove episode with action other than play is ignored when synced --- .../Controller/EpisodeActionControllerTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Integration/Controller/EpisodeActionControllerTest.php b/tests/Integration/Controller/EpisodeActionControllerTest.php index 53c51c9..2c30455 100644 --- a/tests/Integration/Controller/EpisodeActionControllerTest.php +++ b/tests/Integration/Controller/EpisodeActionControllerTest.php @@ -151,6 +151,16 @@ public function testEpisodeActionCreateAction(): void "started": 15, "position": 120, "total": 500 + }, + { + "podcast": "https://example.com/feed.rss", + "episode": "https://example.com/files/s01e21.mp3", + "guid": "s01e21-example-org", + "action": "DELETE", + "timestamp": "2009-12-12T09:00:00", + "started": -1, + "position": -1, + "total": -1 } ]', true, @@ -181,6 +191,7 @@ public function testEpisodeActionCreateAction(): void $episodeActionEntities = $mapper->findAll(0, $userId); /** @var EpisodeActionEntity $firstEntity */ $firstEntity = $episodeActionEntities[0]; + $this->assertCount(1, $episodeActionEntities); $this->assertSame( "https://example.com/feed.rss", $firstEntity->getPodcast()