-
-
Notifications
You must be signed in to change notification settings - Fork 672
Permit use of commas in stream names #3734
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,17 +50,40 @@ export const trySendMessages = (dispatch: Dispatch, getState: GetState): boolean | |
| const state = getState(); | ||
| const auth = getAuth(state); | ||
| const outboxToSend = state.outbox.filter(outbox => !outbox.isSent); | ||
| const oneWeekAgoTimestamp = Date.now() / 1000 - 60 * 60 * 24 * 7; | ||
| try { | ||
| outboxToSend.forEach(async item => { | ||
| await api.sendMessage( | ||
| auth, | ||
| item.type, | ||
| isPrivateOrGroupNarrow(item.narrow) ? item.narrow[0].operand : item.display_recipient, | ||
| item.subject, | ||
| item.markdownContent, | ||
| item.timestamp, | ||
| state.session.eventQueueId, | ||
| ); | ||
| // If a message has spent over a week in the outbox, it's probably too | ||
| // stale to try sending it. | ||
| // | ||
| // TODO: instead of just throwing these away, create an "unsendable" state | ||
| // (including a reason for unsendability), and transition old messages to | ||
| // that instead. | ||
| if (item.timestamp < oneWeekAgoTimestamp) { | ||
| dispatch(deleteOutboxMessage(item.id)); | ||
| return; // i.e., continue | ||
| } | ||
|
|
||
| const to = ((): string => { | ||
| const { narrow } = item; | ||
| // TODO: can this test be `if (item.type === private)`? | ||
| if (isPrivateOrGroupNarrow(narrow)) { | ||
| return narrow[0].operand; | ||
| } else { | ||
| // HACK: the server attempts to interpret this argument as JSON, then | ||
| // CSV, then a literal. To avoid misparsing, always use JSON. | ||
| return JSON.stringify([item.display_recipient]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, interesting that this is a list -- so I think it'll be like The API docs, fwiw, say (at https://zulipchat.com/api/send-message):
which suggests a list is only applicable for PMs. When changing the format of what we send in a request, it'd also be good to confirm that older server versions already accept the new format; then if they don't, we'll figure out how to handle that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JSON has been accepted since at least zulip/zulip@97d7d31 – sometime in the Humbug 0.1.4 period, in mid-2013 – and given the presence of (I'll make a note in the commit message.)
Arguably it's a server bug that it tries to interpret
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool. That sure is reassuringly old. :-) I think then my remaining question is: the commit message says "Always use JSON" for this field; but it looks like the code actually uses JSON just for the stream case, and continues to use a simple CSV for the PMs case. I think I'd be OK with that difference between the two cases; but I'd want to have the commit message, and the comments, be in agreement with what's happening. Alternatively, I think it would work well to do as the commit message says: always use JSON. More specifically, always use a JSON-encoded list. In the PMs case, I think this would be just something like (And then perhaps celebrate the shared |
||
| } | ||
| })(); | ||
|
|
||
| await api.sendMessage(auth, { | ||
| type: item.type, | ||
| to, | ||
| subject: item.subject, | ||
| content: item.markdownContent, | ||
| localId: item.timestamp, | ||
| eventQueueId: state.session.eventQueueId, | ||
| }); | ||
| dispatch(messageSendComplete(item.timestamp)); | ||
| }); | ||
| return true; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.