Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Make label-based filtering support edits #6374

Closed
wants to merge 22 commits into from

Conversation

babolivier
Copy link
Contributor

@babolivier babolivier commented Nov 18, 2019

Support the latest changes on MSC2326 wrt edits.

The summary is that, when an edit of an event with labels comes through (whether it changes the list of labels or not), we need to:

  • return the edit when filtering on one of the labels from the edit's list of labels (and not the original event, nor both)
  • don't return any event that's either the original event or one of its edits when filtering on a label that's been removed by an edit

To do this, every time we process an edit, we:

  • delete every label that was associated with the edit's original event (or another edit of that original event)
  • if the edit features a list of labels, store those with the event ID of the edit

Blocked on #6329 because I plan on iterating on its changes to add tests for this one.

@babolivier babolivier requested a review from a team November 18, 2019 17:22
@richvdh richvdh assigned richvdh and unassigned richvdh Nov 28, 2019
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

before I dig any more deeply into this:

what is the permissions model here? it looks like I could generate an edit event which changes the labels on an event sent by someone else? (Edit: I'm going to take this to the MSC)

Edit edit: I've spent the last hour chasing MSCs and concluded that MSC1849 doesn't really discuss the permission model, but synapse does do some basic permissions checks. It does so by only checking for edits when it serves them to the client, and checking that the senders match. We'll need to do the equivalent here.

synapse/storage/data_stores/main/events.py Outdated Show resolved Hide resolved
@babolivier babolivier self-assigned this Dec 5, 2019
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

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

I still think this approach is somewhat flawed.

synapse/storage/data_stores/main/events.py Outdated Show resolved Hide resolved
# Make sure that the sender of the edit match the original event's sender,
# otherwise ignore this edit. We do this here because _store_labels_txn and
# the background update converge here.
original_sender = self.simple_select_one_onecol_txn(
Copy link
Member

Choose a reason for hiding this comment

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

what if the update arrives before the original event?

@babolivier
Copy link
Contributor Author

This is the wrong approach for handling edits, in that we can't ensure that updates arrive in the right order, or that updates even arrive after the original event. A correct implementation would be calculating the list of labels when processing edits when the client requests events.

@babolivier babolivier closed this Dec 12, 2019
@babolivier babolivier deleted the babolivier/msc2326-edits branch October 28, 2021 15:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants