Skip to content
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

Drop three User fields we aren't keeping up to date; verify that's all #876

Merged
merged 2 commits into from
Aug 14, 2024

Conversation

gnprice
Copy link
Member

@gnprice gnprice commented Aug 10, 2024

This was prompted by noticing recently that we weren't updating
[User.isActive]:
#816 (comment)
(/cc @sm-sayedi)

After we fixed that, I looked and found there were actually three
other fields on User which we weren't updating -- a latent bug,
since we never looked at those fields, but a bug. Fix that.

Then add a comment showing my work on verifying that that's it,
and giving us a head start on re-verifying that in the future
with whatever's changed in the API between now and then.

@gnprice gnprice added the maintainer review PR ready for review by Zulip maintainers label Aug 10, 2024
@@ -465,6 +465,10 @@ class PerAccountStore extends ChangeNotifier with ChannelStore, MessageStore {
if (user == null) {
return; // TODO log
}
// Fields on [User] not updated here:
// userId, dateJoined, isBot, botType, isSystemBot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have a reference on User, so that we remember to update this comment when there is another immutable field?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the more important case is when adding a mutable field, so that we add the code to update it.

Anyway, switched to a comment on User, in conjunction with making the immutable fields final.

Comment on lines 468 to 469
// Fields on [User] not updated here:
// userId, dateJoined, isBot, botType, isSystemBot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about also making these immutable fields final?!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, thanks. Switched to that.

These are obsoleted by [User.role] (which dates to Zulip 4.0).
We never looked at these fields, but had a latent bug because
we weren't keeping them up to date on RealmUserUpdateEvent.
To fix the bug, just stop having the fields around at all.

(Later if we find we want booleans with these handy names,
we can always add getters that just inspect [User.role].)
This was prompted by noticing recently that we weren't updating
[User.isActive]:
  zulip#816 (comment)

After fixing that, I looked and found there were actually three
other fields on User which we weren't updating -- a latent bug,
since we never looked at those fields, but a bug.  Fixed that in
the preceding commit.

Now the remaining fields that don't get updated are fields that
really are immutable on a Zulip user.  Mark those as final, and
add a comment to help maintain the pattern.
@chrisbobbe chrisbobbe merged commit 156c693 into zulip:main Aug 14, 2024
1 check passed
@chrisbobbe
Copy link
Collaborator

Thanks, LGTM! Merged.

@gnprice gnprice deleted the pr-user-update branch August 15, 2024 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer review PR ready for review by Zulip maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants