Skip to content

Stop using surprising subsets of users; use getAllUsersBy* instead #4083

Closed
@gnprice

Description

@gnprice

We have selectors getUsersById and getUsersByEmail that return maps from user IDs or emails to user objects.

Despite their names, they actually return only certain subsets of users:

  • no "deactivated" users, i.e. people who've left the organization (but you might be looking at messages they sent, or PM threads with them, etc.)
  • none of the "cross-realm bots", which are a handful of special built-in bots -- but OTOH normal bots are included, so it's not like this has a meaning like "only human users"

That particular subset is basically an artifact of the way the Zulip server returns the lists of users in the initial data on /register -- those two categories, and the remaining users, come in three separate lists. It's quite uncommon that this list is actually the data that a piece of code really wants to be working with.

That means that most places we use getUsersById or getUsersByEmail are a bug. One of these we just fixed was #4068 -- see discussion here: #4068 (comment) .

Instead, what we almost always want is getAllUsersById, or getAllUsersByEmail.

Thankfully we have only a handful of call-sites left for the getUsersBy* versions. We should fix each of them to use the getAllUsersBy* form -- or, if there's a reason it really should be the subset form, make that choice explicit with a comment.

(Then we should probably also switch around the names. But that can come after fixing the call sites.)

Here's a list of call sites, from rg getUsersBy:

  • src/message/messagesActions.js -- should be getAll..., and I think this may be a live bug
  • src/common/PresenceStatusIndicator.js -- should be getAll..., though I think not currently a live bug (because the code bails out if the user isn't found)
  • src/notification/notificationActions.js -- should be getAll..., and I think this may be a live bug
  • src/outbox/outboxActions.js -- should be getAll..., and I think this may be a live bug
  • src/user-picker/UserPickerCard.js -- should be getAll..., though I think not currently a live bug
  • src/users/userSelectors.js in getOwnUser and the similar getSelfUserDetail -- hmm, this one might be annoying if a lot of things care because cross-realm bots have a slightly different set of properties. We can do this one last.

The ones that are live bugs all involve a PM thread with a cross-realm bot or a deactivated user (including a group PM thread with one such bot/user).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions