-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Support optionally not sending read receipts to other users/servers #5990
Conversation
return [ | ||
r | ||
for r in receipts | ||
if not r.data.get("hidden", False) or r.user_id == user_id |
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.
I'm not entirely convinced that this works because I didn't test initialSync. I am hoping to pawn all this imperfect python over to someone else eventually.
@@ -0,0 +1 @@ | |||
Support a way for clients to not send read receipts to other users/servers. |
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.
link to MSC?
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.
could do with some tests, please.
@@ -262,6 +262,8 @@ def _on_new_receipts(self, rows): | |||
# we only want to send on receipts for our own users | |||
if not self._is_mine_id(receipt.user_id): | |||
continue | |||
if receipt.data.get("hidden", False): | |||
return # do not send over federation |
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.
we don't want to skip all receipts in the list, aiui:
return # do not send over federation | |
continue # do not send over federation |
@@ -49,6 +49,7 @@ def on_POST(self, request, room_id): | |||
"m.read", | |||
user_id=requester.user.to_string(), | |||
event_id=read_event_id, | |||
hidden=body.get("m.hidden", False), |
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.
we should check this is a bool before accepting it
receipt_type, | ||
user_id=requester.user.to_string(), | ||
event_id=event_id, | ||
hidden=body.get("m.hidden", False), |
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.
again, needs a type check
ephemeral_by_room.setdefault(room_id, []).append(event_copy) | ||
|
||
# filter out receipts the user shouldn't see | ||
content = event_copy.get("content", {}) |
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.
I've not really managed to grok what this lump of code is doing. If it's just filtering events, shouldn't that be handled in receipt_source.get_new_events
?
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.
Ideally yes, however there's a comment in a similar area around typing notifications that says the results from that are cached. Didn't want to risk all read receipts being dropped due to a caching issue.
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.
the comment says you shouldn't modify returned event objects, which is true... I don't think there's any reason you can't modify get_new_events
to return a different set of events (modulo checking where else it is used).
This code feels super-complicated at the moment.
@richvdh are there any examples of tests for this kind of thing? I'm not going to be able to do this without heavy amounts of documentation and/or examples :/ |
(also I don't know why this ended up in the review queue - I know it's terrible code and didn't intend to try and push this feature anywhere for months. Likewise for the MSC) |
you could either add some sytests (look in
I assumed the fact that you'd submitted a PR meant you wanted it reviewed and merged... generally we try to avoid having open PRs sitting around for months (though we often fail at it) |
ah, I tend to open PRs for things so I don't lose the code (and it might be useful for others who aren't me). Didn't really intend on adding this to the queue until the MSC was past FCP. Thanks for the early review though - will take a look at those tests, but is a p2 thing on my list. |
This has a massive bug in initial sync:
|
I've created a fork and rebased this branch onto the master. I've also fixed some proposed changes. To fix the sync: |
It would probably be best to create a separate PR and we can replace this one if necessary!
It looks like it is a |
Sorry, I'm going to close this as it's massively bitrotted and unlikely to be helpful for the synapse team to review in this state. @symptog if you're able to take this on, a new PR is appreciated. |
See matrix-org/matrix-react-sdk#3395
Pull Request Checklist
This is done with my NV hat.