-
Notifications
You must be signed in to change notification settings - Fork 309
Handle unknown users everywhere #716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
HI @gnprice I also noticed some had the correct changes you explain such as the |
Sure, go ahead. I recommend sending a small PR first that updates a handful of these places in the code. Then after that's been reviewed, you can use the feedback when writing the remaining changes, in order to make something that's as easy as possible for us to review and merge. |
Okay, i will do just that. |
Our local store has a map with all the users we know about, in
PerAccountStore.users
akastore.users
. But this might not be all the users in the realm. In particular, if the self-user is a guest user, there may be users we don't have permission to know about.For the most part the users we actually encounter will be users we do have data on: for example, a guest user still has permission to know about users that are subscribed to any of the same streams they are, which means that most of the messages they see there will be sent by users they know about. But there could be older messages by users who've since unsubscribed, and other scenarios. So we will sometimes encounter a user ID that doesn't exist in
store.users
.We should therefore make sure we never crash when we encounter a user that's not in
store.users
. This means:When we look up a user with an expression like
store.users[userId]
, we should explicitly handle the possibility that the result is null.This means no
!
and noassert
saying it's non-null. Depending on the context, the code might use?.
and??
to fall back to a placeholder likeZulipLocalizations.unknownUserName
, or might return without doing anything, or something else as appropriate.store.selfUser
.When we have a context like a
Message
that provides its own details on a user (like the message sender), we should fall back to those if the user is unknown. That way we not only don't crash, but provide helpful information, in cases like a guest user looking at older messages sent by someone no longer subscribed to their streams.We already do these correctly in many places, but there are several places we don't. So this task is about sweeping through those, probably in one commit per call site, and fixing them.
A key part of doing this is to find an exhaustive list of places that are potentially affected. You can do this in an IDE by going to the definition of
PerAccountStore.users
and then using the "find references" feature.The text was updated successfully, but these errors were encountered: