-
-
Notifications
You must be signed in to change notification settings - Fork 654
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: Sync updateStream and createStream with their API docs #5341
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
65ddf3f
api.updateStream [nfc]: Accept multiple properties at once
chrisbobbe be12766
streamsActions: Send one update-stream request for all changed proper…
chrisbobbe 3fc7aa3
api types [nfc]: Express updateStream's params by referring to Stream…
chrisbobbe eb50271
modelTypes [nfc]: Order Stream type's properties to follow a doc
chrisbobbe dd6fea1
modelTypes: Update Stream type, to match `streams` initial data at FL…
chrisbobbe 0c56883
api types: Sync updateStream's params with API doc at FL 121
chrisbobbe 2668bde
stream [nfc]: Assimilate to name "invite_only" in create/edit stream …
gnprice 08c0697
api [nfc]: Have createStream use params objects
chrisbobbe 94d7a59
api [nfc]: Remove some param-defaulting within our api.createStream b…
chrisbobbe 9148ab3
api: Remove more param-defaulting within our api.createStream binding
chrisbobbe ffc44bc
CreateStreamScreen: Let server apply its own fallback for `principals`
chrisbobbe 2a5bcd2
userSelectors [nfc]: Bring a comment up-to-date
chrisbobbe aba93ee
userSelectors [nfc]: Remove now-unused getOwnEmail
chrisbobbe 7fee95b
api types [nfc]: Express createStream's params by referring to Stream…
chrisbobbe d002af0
api [nfc]: Use spreads, to reduce duplication
chrisbobbe 6eff27a
api types: Sync createStream's params with API doc at FL 121
chrisbobbe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,64 @@ | ||
/* @flow strict-local */ | ||
import type { ApiResponse, Auth } from '../transportTypes'; | ||
import type { Stream } from '../modelTypes'; | ||
import { apiPost } from '../apiFetch'; | ||
|
||
/** See https://zulip.com/api/create-stream */ | ||
/** | ||
* See https://zulip.com/api/create-stream | ||
* | ||
* NB the caller must adapt for old-server compatibility; see comments. | ||
*/ | ||
// Current to FL 121. | ||
// TODO(#4659): Once we pass the feature level to API methods, this one | ||
// should encapsulate various feature-level switches; see comments. | ||
export default ( | ||
auth: Auth, | ||
name: string, | ||
description?: string = '', | ||
// TODO(server-3.0): Send numeric user IDs (#3764), not emails. | ||
principals?: $ReadOnlyArray<string> = [], | ||
inviteOnly?: boolean = false, | ||
announce?: boolean = false, | ||
): Promise<ApiResponse> => | ||
apiPost(auth, 'users/me/subscriptions', { | ||
streamAttributes: $ReadOnly<{| | ||
// Ordered by their appearance in the doc. | ||
|
||
name: $PropertyType<Stream, 'name'>, | ||
description?: $PropertyType<Stream, 'description'>, | ||
invite_only?: $PropertyType<Stream, 'invite_only'>, | ||
|
||
// TODO(server-5.0): New in FL 98 | ||
is_web_public?: $PropertyType<Stream, 'is_web_public'>, | ||
|
||
history_public_to_subscribers?: $PropertyType<Stream, 'history_public_to_subscribers'>, | ||
|
||
// TODO(server-3.0): New in FL 1; for older servers, pass is_announcement_only. | ||
stream_post_policy?: $PropertyType<Stream, 'stream_post_policy'>, | ||
|
||
// Doesn't take the same special values as Stream.is_announcement_only! | ||
// https://chat.zulip.org/#narrow/stream/412-api-documentation/topic/message_retention_days/near/1367895 | ||
// TODO(server-3.0): New in FL 17 | ||
message_retention_days?: | ||
| number | ||
| 'realm_default' | ||
// TODO(server-5.0): New in FL 91, replacing 'forever'. | ||
| 'unlimited' | ||
// TODO(server-5.0): Replaced in FL 91 by 'unlimited'. | ||
| 'forever', | ||
|
||
// TODO(server-3.0): Replaced in FL 1 by 'stream_post_policy'. | ||
// Commented out because this isn't actually in the doc. It probably | ||
// exists though? Copied from api.updateStream. | ||
// is_announcement_only?: $PropertyType<Stream, 'is_announcement_only'>, | ||
|}>, | ||
options?: $ReadOnly<{| | ||
// TODO(server-3.0): Send numeric user IDs (#3764), not emails. | ||
principals?: $ReadOnlyArray<string>, | ||
|
||
authorization_errors_fatal?: boolean, | ||
announce?: boolean, | ||
|}>, | ||
): Promise<ApiResponse> => { | ||
const { name, description, ...restAttributes } = streamAttributes; | ||
const { principals, ...restOptions } = options ?? {}; | ||
return apiPost(auth, 'users/me/subscriptions', { | ||
subscriptions: JSON.stringify([{ name, description }]), | ||
...restAttributes, | ||
|
||
principals: JSON.stringify(principals), | ||
invite_only: inviteOnly, | ||
announce, | ||
...restOptions, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,47 @@ | ||
/* @flow strict-local */ | ||
import type { ApiResponse, Auth } from '../transportTypes'; | ||
import type { Stream } from '../modelTypes'; | ||
import { apiPatch } from '../apiFetch'; | ||
|
||
/** | ||
* https://zulip.com/api/update-stream | ||
* | ||
* NB the caller must adapt for old-server compatibility; see comment. | ||
* NB the caller must adapt for old-server compatibility; see comments. | ||
*/ | ||
// TODO(#4659): Once we pass the feature level to API methods, this one | ||
// should encapsulate a switch at feature level 64. See its call sites. | ||
// TODO(server-4.0): Simplify that away. | ||
// Current to FL 121; property ordering follows the doc. | ||
export default ( | ||
auth: Auth, | ||
id: number, | ||
property: string, | ||
value: string | boolean, | ||
): Promise<ApiResponse> => | ||
apiPatch(auth, `streams/${id}`, { | ||
[property]: value, | ||
}); | ||
params: $ReadOnly<{| | ||
// TODO(#4659): Once we pass the feature level to API methods, this one | ||
// should encapsulate a switch at FL 64 related to these two parameters. | ||
// See call sites. | ||
description?: $PropertyType<Stream, 'description'>, | ||
new_name?: $PropertyType<Stream, 'name'>, | ||
|
||
// controls the invite_only property | ||
is_private?: $PropertyType<Stream, 'invite_only'>, | ||
|
||
// TODO(server-5.0): New in FL 98. | ||
is_web_public?: $PropertyType<Stream, 'is_web_public'>, | ||
|
||
// TODO(server-3.0): New in FL 1; for older servers, pass is_announcement_only. | ||
stream_post_policy?: $PropertyType<Stream, 'stream_post_policy'>, | ||
|
||
history_public_to_subscribers?: $PropertyType<Stream, 'history_public_to_subscribers'>, | ||
|
||
// Doesn't take the same special values as Stream.is_announcement_only! | ||
// https://chat.zulip.org/#narrow/stream/412-api-documentation/topic/message_retention_days/near/1367895 | ||
// TODO(server-3.0): New in FL 17 | ||
message_retention_days?: | ||
| number | ||
| 'realm_default' | ||
// TODO(server-5.0): Added in FL 91, replacing 'forever'. | ||
| 'unlimited' | ||
// TODO(server-5.0): Replaced in FL 91 by 'unlimited'. | ||
| 'forever', | ||
|
||
// TODO(server-3.0): Replaced in FL 1 by 'stream_post_policy'. | ||
is_announcement_only?: $PropertyType<Stream, 'is_announcement_only'>, | ||
|}>, | ||
): Promise<ApiResponse> => apiPatch(auth, `streams/${id}`, params); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Huh, curious.