Skip to content

Commit 531d6f4

Browse files
Xefirthrillfall
authored andcommitted
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 AntennaPod/AntennaPod#6957 (comment)) 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.
1 parent e7e07ca commit 531d6f4

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

lib/Controller/EpisodeActionController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function __construct(
4141
public function create(): JSONResponse {
4242

4343
$episodeActionsArray = $this->filterEpisodesFromRequestParams($this->request->getParams());
44+
$episodeActionsArray = $this->filterOnlyPlays($episodeActionsArray);
4445
$this->episodeActionSaver->saveEpisodeActions($episodeActionsArray, $this->userId);
4546

4647
return new JSONResponse(["timestamp" => time()]);
@@ -74,4 +75,12 @@ public function list(int $since = 0): JSONResponse {
7475
public function filterEpisodesFromRequestParams(array $data): array {
7576
return array_filter($data, "is_numeric", ARRAY_FILTER_USE_KEY);
7677
}
78+
79+
/**
80+
* @param array $data
81+
* @return array $episodeActionsArray
82+
*/
83+
public function filterOnlyPlays(array $data): array {
84+
return array_filter($data, fn($ep) => isset($ep['action']) && strtolower($ep['action']) === 'play');
85+
}
7786
}

0 commit comments

Comments
 (0)