RSS: Fix bug in @remove that prevented it from fully deleting aliased feeds.

This commit is contained in:
Valentin Lorentz 2021-05-01 13:27:56 +02:00
parent e96633c1e3
commit 435f8de73a
2 changed files with 22 additions and 0 deletions

View File

@ -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'])

View File

@ -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