-
-
Notifications
You must be signed in to change notification settings - Fork 673
api [nfc]: Start relying on server 1.9+ #5192
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5cf9a3c
api [nfc]: Update ApiErrorCode jsdoc for Zulip 1.7+
gnprice b17eace
api [nfc]: Tighten up jsdoc for ApiErrorCode
gnprice cd14e83
api types: Mark realm_user_groups as required, relying on Zulip 1.8
gnprice 80be904
notif [nfc]: Simplify a comment about pre-1.8 servers
gnprice 0aba456
notif [nfc]: Simplify comment on APNs format, for Zulip 1.8+
gnprice 4028ee1
notif [nfc]: Simplify comment on APNs format, for Zulip 1.9+
gnprice e160f70
notif types: Document APNs payload with actual type syntax
gnprice c400d09
notif types: Document APNs payload format more fully
gnprice cc01b21
api types: Mark User#date_joined as required, relying on Zulip 1.9
gnprice 43f8b7a
api types [nfc]: Simplify comment on CrossRealmBot#timezone, for Zuli…
gnprice 1b03037
avatar [nfc]: Simplify comment on missing rawAvatarUrl, for Zulip 1.9+
gnprice 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// @flow strict-local | ||
|
||
import { type UserId } from './idTypes'; | ||
|
||
// This format is as of 2020-02, commit 3.0~3347. | ||
type BaseData = {| | ||
/** The realm URL, same as in the `/server_settings` response. */ | ||
+realm_uri: string, | ||
|
||
// The server and realm_id are an obsolete substitute for realm_uri. | ||
-server: string, // settings.EXTERNAL_HOST | ||
-realm_id: number, // server-internal realm identifier | ||
|
||
/** | ||
* The user this notification is addressed to; our self-user. | ||
* | ||
* (This lets us distinguish different accounts in the same realm.) | ||
*/ | ||
// added 2.1-dev-540-g447a517e6f, release 2.1.0+ | ||
// TODO(server-2.1): Simplify comment. | ||
+user_id: UserId, | ||
|
||
// The rest of the data is about the Zulip message we're being notified | ||
// about. | ||
|
||
+message_ids: [number], // single-element tuple! | ||
|
||
+sender_id: UserId, | ||
+sender_email: string, | ||
|
||
// (... And see StreamData and PmData below.) | ||
|}; | ||
|
||
/** For a notification about a stream message. */ | ||
type StreamData = {| | ||
...BaseData, | ||
+recipient_type: 'stream', | ||
|
||
/** | ||
* The name of the message's stream. | ||
* | ||
* Sadly no stream ID: https://github.com/zulip/zulip/issues/18067 | ||
*/ | ||
+stream: string, | ||
|
||
+topic: string, | ||
|}; | ||
|
||
/** For a notification about a PM. */ | ||
type PmData = {| | ||
...BaseData, | ||
+recipient_type: 'private', | ||
|
||
/** | ||
* The recipient user IDs, if this is a group PM; absent for 1:1 PMs. | ||
* | ||
* The user IDs are comma-separated ASCII decimal. | ||
* | ||
* (Does it include the self-user? Are they sorted? Unknown.) | ||
*/ | ||
+pm_users?: string, | ||
|}; | ||
|
||
/** An APNs message sent by the Zulip server. */ | ||
export type ApnsPayload = {| | ||
/** Our own data. */ | ||
+zulip: StreamData | PmData, | ||
|
||
/** | ||
* Various Apple-specified fields. | ||
* | ||
* Upstream docs here: | ||
* https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/generating_a_remote_notification | ||
*/ | ||
+aps: { ... }, | ||
|}; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Interesting. The
-
marks these properties as write-only. We do that…not because we'd ever want to write to them (we wouldn't), right, but because we want Flow to shout at us if we try to read them (seeing as they're obsolete)?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.
Right. This lets the type still document that they might be there, and it lets them appear when we construct one of these objects, like in tests, but prevents reading them.
We have another example of this on
Subscription
:Uh oh!
There was an error while loading. Please reload this page.
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.
Mm, right, I forgot about tests.
I guess if we have tests that use one of these objects, and we say that the object is of the
ApnsPayload
type, we'll have to include these write-only fields. That's because they're not marked as optional. I guess that's how we say that they're always present in the payloads we're getting…though it seems like they don't need to be present at all.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.
True. It is kind of nice to have this sort of property in objects we use in test data, because it makes the test data representative of what real servers send... but when it's one that's totally obsolete like this
server
andrealm_id
, it also risks just being noise. So if it comes up, I wouldn't be sad to just comment them out, like we do forMessage#recipient_id
:Commenting it out makes our test data less representative, so that effectively we're trusting that our code doesn't get confused by an unexpected extra property. In general we don't write code in patterns that would get confused by that -- I'm not even sure offhand what a realistic such pattern would be -- so that's acceptable.
OTOH for something like
audible_notifications
anddesktop_notifications
, they totally are something we'll want to handle in the future, and we're just marking them as unusable so one sees the comment before trying to use them. So those have a stronger reason to be present, as-
, rather than deleted or commented out.