mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
people: Make get_by_user_id type-safe.
We should make `get_by_user_id` type-safe in the sense that it's caller should not expect undefined values and hence it's caller should not need to validate the user ids. To do this I extracted a method `maybe_get_user_by_id` which is type-unsafe version of this function which will allow undefined values and will behave exactly the same as the previous version. So the callers which expects the undefined values from this function should use this new function `maybe_get_user_by_id`. Probably about half of these callers are implicitly iterating through all users in the people.js data set and thus by construction should never fail, but it's simpler to just convert all existing callers than do that audit.
This commit is contained in:
@@ -39,7 +39,7 @@ export function needs_subscribe_warning(user_id, stream_id) {
|
||||
// We expect the caller to already have verified that we're
|
||||
// sending to a valid stream and trying to mention the user.
|
||||
|
||||
const user = people.get_by_user_id(user_id);
|
||||
const user = people.maybe_get_user_by_id(user_id);
|
||||
|
||||
if (!user) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user