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

fix: prevent truncating message timestamps when updating references to deleted quoted message #1141

Merged
merged 2 commits into from
Jul 3, 2023

Conversation

MartinCupela
Copy link
Contributor

CLA

  • [ X ] I have signed the Stream CLA (required).
  • [ X ] Code changes are tested

Description of the changes, What, Why and How?

When message.deleted event was delivered, the client code invoked channelState.removeQuotedMessageReferences(event.message);. This function was converting created_at, pinned_at, updated_at values of each quoting message to string using toString() method. That lead to truncation of milliseconds from each timestamp. Later the truncated timestamps distorted the decision logic in ChannelState._addToMessageList() in the following way,

  1. the last message B in the list was also quoting another message A
  2. the quoted message was deleted (timestamps of message B now truncated)
  3. the message B was then updated and the WS event message.updated carried created_at timestamp with milliseconds
  4. the message B in the state carried created_at timestamp without milliseconds
  5. the updated B message was considered a new message but addIfDoesNotExist param for ChannelState._addToMessageList() is set to false when handling message.updated events
  6. that leads to pure copying of the previous message list state without adding the updates

Solution is not to truncate the message timestamps, when updating references to deleted quoted message.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 2, 2023

Size Change: +26 B (0%)

Total Size: 318 kB

Filename Size Change
dist/browser.es.js 69.6 kB +6 B (0%)
dist/browser.js 70.6 kB +7 B (0%)
dist/index.es.js 69.6 kB +7 B (0%)
dist/index.js 70.6 kB +6 B (0%)
ℹ️ View Unchanged
Filename Size
dist/browser.full-bundle.min.js 37.6 kB

compressed-size-action

@MartinCupela MartinCupela merged commit ab54f94 into master Jul 3, 2023
6 checks passed
@MartinCupela MartinCupela deleted the fix/prevent-message-datetime-truncating branch July 3, 2023 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants