-
-
Notifications
You must be signed in to change notification settings - Fork 668
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
api types: Sync User and CrossRealmBot types with the doc, as of FL 121 #5351
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Comments below.
// For background on the "*bot*" fields, see user docs on bots: | ||
// https://zulip.com/help/add-a-bot-or-integration | ||
// Note that certain bots are represented by a different type entirely, | ||
// namely `CrossRealmBot`. | ||
is_bot: boolean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Let's keep this comment next to one of the fields it's about, to increase the chance that it's noticed when it's relevant. Perhaps is_bot
-- that seems like the one where you're most likely to be looking and be in need of the context that CrossRealmBot
is over there.
is_bot: boolean, | ||
bot_type?: number, | ||
bot_owner?: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sure is awkward that these three get scattered from each other. :-/ Also that user_id
is in a random place in the middle instead of at the top, and that is_guest
is nowhere near is_admin
and is_owner
.
I think the reordering is worth the trade-off in order to make it more tractable to bring the type up to date, but it's a shame that it actually gets harder to read.
Perhaps first reorder the API docs to match the more logical order that's in models.py and in this type? Then we don't have to regress on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replied with a proposed ordering in chat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sent zulip/zulip#21883; I guess I'll await that and apply the result to my next revision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my next revision, I'd appreciate the time saved by applying the new order on top of the existing commits in the branch, rather than having an early commit that takes the new ordering then resolve all the merge conflicts that'd create.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I've actually gone ahead and done it the proper way for my next revision. 🙂)
src/api/modelTypes.js
Outdated
// (This one doesn't appear in `/users` responses.) | ||
profile_data?: empty, // When we need this, describe its actual type. | ||
// If we use this, avoid `avatar_url` falling out of sync with it. | ||
-avatar_version: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api types: Add write-only `avatar_version` to User type
This doesn't end up having that effect, because the object type is wrapped in $ReadOnly<…>
.
In order to make it possible to start marking properties as write-only, you can have a prep commit replace the $ReadOnly
with a +
on each individual property. For an example: f551158
src/api/modelTypes.js
Outdated
// TODO(server-3.0): Replaced in FL 1 by bot_owner_id | ||
bot_owner?: string, | ||
|
||
is_active: boolean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api types: Add `is_active` to User type
The doc says it is present in `realm_users` and
`realm_non_active_users`; trust that.
Huh. It seems to actually contradict itself on that:
realm_non_active_users: (object)[]
Present if realm_user is present in fetch_event_types.
A array of dictionaries where each entry describes a user whose account has been deactivated. Note that unlike the usual User dictionary this does not contain the is_active key as all the users present in this array have deactivated accounts.
even though it then goes on to list is_active
in the actual list of properties for those objects.
Same for realm_users
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I'll bring it up in #api documentation
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/api/modelTypes.js
Outdated
// `null` if the user isn't a bot. | ||
// `1` for a `Generic` bot. | ||
// `2` for an `Incoming webhook` bot. | ||
// `3` for an `Outgoing webhook` bot. | ||
// `4` for an `Embedded` bot. | ||
bot_type: number | null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to leave this comment out, I think, in favor of deferring to the API docs.
src/api/modelTypes.js
Outdated
// Possible values are: | ||
// Organization owner => 100 | ||
// Organization administrator => 200 | ||
// Organization moderator => 300 | ||
// Member => 400 | ||
// Guest => 600 | ||
role?: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In principle I'd say the same thing about this as about bot_type
: leave these details to just be in the API docs. But maybe the role is an important enough property to make an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably fine to leave these details out. The comment doesn't reveal anything surprising or counterintuitive, and it seems like the kind of thing where the API doc might change. (For example, to add new roles, or to stop using =>
where :
would do fine and not get confused with ≥
.) And then if it changes, we don't have to go and make a change in our code comment.
8209de1
to
7b56564
Compare
Thanks for the review! Revision pushed. |
7b56564
to
a1cc583
Compare
…n doc Following the recent reordering applied to the doc in zulip/zulip#21918 .
This makes it easy to mark deprecated properties write-only.
The other two properties in the comment don't appear in `realm_user` items in the /register response, according to the doc. So, stop mentioning them. (They do appear at toplevel in the /register response, if `realm_user` is present in `fetch_event_types`; there, they presumably apply to the logged-in user.)
As the comment says, some ancient servers don't send this. But we don't support those ancient servers; so, no need to make the property optional.
This makes it easy to mark deprecated properties write-only.
These tighter types aren't made explicit in the doc (perhaps they should be), but they're inferrable from how cross-realm bots work.
Thanks for the revision! Looks good -- merging. |
a1cc583
to
900a007
Compare
As Greg pointed out in zulip#5351, at zulip#5351 (comment) : > [The write-only marker] doesn't end up having that effect, because > the object type is wrapped in $ReadOnly<…>.
As Greg pointed out in zulip#5351, at zulip#5351 (comment) : > [The write-only marker] doesn't end up having that effect, because > the object type is wrapped in $ReadOnly<…>.
After #5349, on the path to fixing #5250.