From 435f8de73a38e78717c6f01874b29bbf0b46e039 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sat, 1 May 2021 13:27:56 +0200 Subject: [PATCH] RSS: Fix bug in @remove that prevented it from fully deleting aliased feeds. --- plugins/RSS/plugin.py | 11 +++++++++++ plugins/RSS/test.py | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/plugins/RSS/plugin.py b/plugins/RSS/plugin.py index 311a04c4e..03694de5d 100644 --- a/plugins/RSS/plugin.py +++ b/plugins/RSS/plugin.py @@ -514,6 +514,17 @@ class RSS(callbacks.Plugin): irc.error(_('That\'s not a valid RSS feed command name.')) return self.remove_feed(feed) + + # If the feed was first created "anonymously", eg. with + # `@rss announce add http://example.org/rss`, then as a named feed + # with `@rss add example http://example.org/rss`, + # `self.get_feed(name)` above gets only one of them; so let's + # remove the aliased name or URL from the feed names too, + # or we would have a dangling entry here. + self.feed_names.pop(name, None) + self.feed_names.pop(feed.url, None) + assert self.get_feed(name) is None + irc.replySuccess() remove = wrap(remove, ['feedName']) diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index 3e7a1a7a9..73ebfef2d 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -100,6 +100,17 @@ class RSSTestCase(ChannelPluginTestCase): finally: self.assertNotError('rss remove xkcd') + @mock_urllib + def testRemoveAliasedFeed(self, mock): + try: + self.assertNotError('rss announce add http://xkcd.com/rss.xml') + self.assertNotError('rss add xkcd http://xkcd.com/rss.xml') + finally: + self.assertNotError('rss announce remove http://xkcd.com/rss.xml') + self.assertNotError('rss remove xkcd') + self.assertEqual(self.irc.getCallback('RSS').feed_names, {}) + self.assertEqual(self.irc.getCallback('RSS').feeds, {}) + @mock_urllib def testInitialAnnounceNewest(self, mock): mock._data = xkcd_new