do not add subscriptions that have no url (i.e. antennapod local folder subscriptions)

This commit is contained in:
thrillfall 2021-12-09 20:19:35 +01:00
parent a9e29e269c
commit e119d41c86
3 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,9 @@
# Changelog
## upcoming
### Changed
- Ignore subscriptions that have no url
## 3.1.0 - 2021-10-18
### Changed
- Add timestamp to subscription change response @JonOfUs

View File

@ -13,6 +13,7 @@ class SubscriptionChangesReader {
*/
public static function mapToSubscriptionsChanges(array $urls, bool $subscribed): array {
$subscriptionChanges = [];
$urls = array_filter($urls, function(string $url) {return filter_var($url, FILTER_VALIDATE_URL) !== false; });
foreach ($urls as $url) {
$subscriptionChanges[] = new SubscriptionChange($url, $subscribed);
}

View File

@ -14,4 +14,14 @@ class SubscriptionChangeReaderTest extends TestCase {
$this->assertSame("https://feeds.megaphone.fm/another", $subscriptionChange[1]->getUrl());
}
public function testNonUrisAreOmmited(): void {
$subscriptionChange = SubscriptionChangesReader::mapToSubscriptionsChanges([
"https://feeds.megaphone.fm/HSW8286374095",
"antennapod_local:content://com.android.externalstorage.documents/tree/home:podcast"
], true);
$this->assertCount(1, $subscriptionChange);
$this->assertSame("https://feeds.megaphone.fm/HSW8286374095", $subscriptionChange[0]->getUrl());
}
}