[FIX]Renaming of channel breaks links/references.
Closes #7108.
I have fixed the issue but I am not able to change the unit tests accordingly. Help appreciated. :)
Since earlier, channel names were used in data-channel attribute in anchor tags around the channel mentioned(e.g #general), they could be directly be put in the unit tests, now we cannot do that.
Also since I am fetching from the database the room details( room._id ), which then become the value of data-channel, I cannot hard code.
And while testing RocketChat.models is recognized as undefined if we do not pass externalRoom as argument to the function replaceChannels and check if its defined and proceed with it.
I don't know if its the correct method, but its the best I could come up.
@sampaiodiego can you please help me with this? :)
thanks @Kailash0311 .. let me ask for @tassoevan and @ggazzo to also take a look on this.
@Kailash0311 from what I've seen, if a channel is renamed, even though the mention links to it will keep working, they'll still show with the old name right? I'm thinking if this should be fixed like we do for usernames, but I'm not sure.
No the link won't work once it has been renamed. Issue ( #7108 ) that I am solving is exactly that :)
@Kailash0311, I'm not sure if I've understood the resolution here. If I send a message like
Please look at #channel-a
and then rename channel-a as channel-b and create a new channel named channel-a, how would my message look like?
@tassoevan I don't think your message would change at all but your message would be directed to the new channel (which was not intended I suppose.) My resolution is that if we link channel-id ( which is now channel-name) with the channel mention we can still redirect to the old channel which was probably intended at the time of the mention. I didn't think of changing the message because we need to see all the messages to see if that channel was mentioned and then change it, which can be tedious task.
@tassoevan @sampaiodiego your comments on my resolution ? I'll be happy to change if anything is wrong(or missing) in my code.