We allow rss handles to be of any case on creation, even though matching
is case-insentivie. However, when renaming an rss using 'rss change
handle' and only changing the case, two things prevented this from
working correctly:
* since the new downcased handle was equal to the old downcased handle,
the bot would prevent the renaming due to the existence of the new
handle
* the new handle was forcefully downcased, preventing the user
from renaming handle 'case' to 'CaSe'.
Fix by checking for this case explicitly, and handling it separately.
end
case params[:what].intern
when :handle
end
case params[:what].intern
when :handle
- new = params[:new].downcase
- if @feeds.key?(new) and @feeds[new]
+ # preserve rename case, but beware of key
+ realnew = params[:new]
+ new = realnew.downcase
+ if feed.handle.downcase == new
+ if feed.handle == realnew
+ m.reply _("You want me to rename %{handle} to itself?") % {
+ :handle => feed.handle
+ }
+ return false
+ else
+ feed.mutex.synchronize do
+ feed.handle = realnew
+ end
+ end
+ elsif @feeds.key?(new) and @feeds[new]
m.reply "There already is a feed with handle #{new}"
return
else
feed.mutex.synchronize do
@feeds[new] = feed
@feeds.delete(handle)
m.reply "There already is a feed with handle #{new}"
return
else
feed.mutex.synchronize do
@feeds[new] = feed
@feeds.delete(handle)