Skip to content

messages state: Maintain edit_history to be reasonably current #5435

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 7 commits into from
Jul 7, 2022

Conversation

chrisbobbe
Copy link
Contributor

@chrisbobbe chrisbobbe commented Jul 5, 2022

Following the plan we made in #5422, toward #5306.

I'm not sure I'm quite happy with the last commit, where we set edit_history to null based on allowEditHistory. I've put the condition on allowEditHistory out to the edge (eventToAction, api.getMessages)…but that means plumbing allowEditHistory out to the edge. Is that OK?

@chrisbobbe chrisbobbe requested a review from gnprice July 5, 2022 22:00
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chrisbobbe! A few comments below, just about the tests; then please merge at will.

I'm not sure I'm quite happy with the last commit, where we set edit_history to null based on allowEditHistory. I've put the condition on allowEditHistory out to the edge (eventToAction, api.getMessages)…but that means plumbing allowEditHistory out to the edge. Is that OK?

Yeah, that isn't beautiful, but I think it's OK.

Effectively it means that the edge becomes a little bit stateful -- that there's a little bit of the data that's previously passed through it which it needs to remember, or be reminded of, in order to correctly interpret the new data coming through. Specifically, there's a little bit of the realm's settings that it needs to know.

That isn't much different in kind from the little bit of such knowledge it already needs, namely the server version. And I think it's natural that there might occasionally be bits of the realm settings (or server settings) that are needed as background information for the kind of processing that we do at the edge, just like there ends up being here.

subject: 'new topic',
edit_history: [
{
user_id: message1.sender_id,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this test case, there's three messages getting moved at once, and the user_id of each one's edit_history entry is the sender of that particular message. That seems like not the intended semantics -- it should instead be the same for all three entries, namely the user that did the move.

It looks like the actual implementation gets this right, though.

Part of why the test passes despite that is that the messages all have the same sender, and the action is attributed to that same user.

Probably the right fix is that the mkMoveAction call should pass an explicit user_id, so that these lines in the expected result can match that. And to fully exercise this part of the logic, it should be different from the user ID of the sender.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this also highlights that this expected data is fairly verbose and repetitive -- that makes this detail easy to miss. It'd be good to instead write it with [message0, message1, message2].map(…), so that the ways it's different between messages and the ways it's the same stand out better from each other.

Comment on lines 512 to 513
{
...message1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then here I guess [message1, message2].map(…) would be good. (Probably trying to unify the latter two with the content edit that happens to message0 would be more unhelpful than helpful.)

According to our types, the only case in which a message-update
event is missing an edit_timestamp is when it's a rendering-only
event that comes from a server pre-FL 114.

So, fix some events that we don't mean to be rendering-only but that
we haven't given an edit_timestamp.
…vents

In FL 114, servers stopped representing rendering-only events with
missing edit_timestamp, and started representing them with
`rendering_only: true`. Handle both representations, not just the
old one.
In particular, all the update-message events we simulate in this
file have rendering_only, user_id, and edit_timestamp.
@chrisbobbe chrisbobbe force-pushed the pr-maintain-edit-history branch from 7d207b8 to 77e97fc Compare July 7, 2022 22:20
@chrisbobbe chrisbobbe merged commit 77e97fc into zulip:main Jul 7, 2022
@chrisbobbe
Copy link
Contributor Author

A few comments below, just about the tests; then please merge at will.

Done, thanks for the review!

@chrisbobbe chrisbobbe deleted the pr-maintain-edit-history branch July 7, 2022 22:33
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.

2 participants