compose: Ensure valid destination stream in typeahead completion.

If we complete a typeahead with an invalid stream name in composebox,
we would get 'compose_stream is undefined' error while running the
checks to prevent accidentally mentioning private streams.

We can safely early-return from this function and let the 'send'
event handler show the error to the user.
This commit is contained in:
Rohitt Vashishtha 2019-07-19 17:55:53 +00:00 committed by Tim Abbott
parent 5d20c4b8fb
commit 3f03ae66f0
1 changed files with 6 additions and 0 deletions

View File

@ -962,6 +962,12 @@ exports.initialize = function () {
}
var compose_stream = stream_data.get_sub(compose_state.stream_name());
if (compose_stream === undefined) {
// We have an invalid stream name, don't warn about this here as
// we show an error to the user when they try to send the message.
return;
}
if (compose_stream.subscribers && data.stream.subscribers) {
var compose_stream_sub = compose_stream.subscribers.keys();
var mentioned_stream_sub = data.stream.subscribers.keys();