Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting favourite via CLI with URL deletes others #559

Closed
CDrummond opened this issue Apr 3, 2021 · 1 comment
Closed

Deleting favourite via CLI with URL deletes others #559

CDrummond opened this issue Apr 3, 2021 · 1 comment

Comments

@CDrummond
Copy link
Contributor

If ["favorites", "delete", "url:http://...."] is used to remove a favourite, the plugin also removes others. Looking at cliDelete in Slim/Plugin/Favorites/Plugin.pm, line 932 checks if no index is supplied and deletes via the URL. However, line 941 then attempts to delete via this non-existent index.

I think the $favs->deleteIndex($index); should be in an else section. i.e. re-write function as follows:

sub cliDelete {
	my $request = shift;

	if ($request->isNotCommand([['favorites'], ['delete']])) {
		$request->setStatusBadDispatch();
		return;
	}

	my $client = $request->client();
	my $index  = $request->getParam('item_id');
	my $url    = $request->getParam('url');
	my $title  = $request->getParam('title');

	# XXX: refactor to use Slim::Utils::Favorites
	my $favs = Slim::Plugin::Favorites::OpmlFavorites->new($client);

	if (!defined $index || !defined $favs->entry($index)) {
		if ($url) {
			$favs->deleteUrl($url);
		} else {
			$request->setStatusBadParams();
			return;
		}
	} else {
		$favs->deleteIndex($index);
        }

	# show feedback if this action came from jive cometd session
	if ($request->source && $request->source =~ /\/slim\/request/) {
		my $deleteMsg = $title?$title:$url;
		$client->showBriefly({
			'jive' => {
			'text' => [ $client->string('FAVORITES_DELETING'),
						$deleteMsg ],
			}
		});
	}

	$request->setStatusDone();
}

p.s. I would have created a pull request, but my ISP seems to be going really slow with a git checkout of slimserver!

@CDrummond CDrummond changed the title Deleteing favourite via CLI with URL deletes others Deleting favourite via CLI with URL deletes others Apr 3, 2021
mherger added a commit that referenced this issue Apr 4, 2021
@mherger
Copy link
Contributor

mherger commented Apr 4, 2021

Thanks!

@mherger mherger closed this as completed Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants