element-hq / element-hq/dendrite

Timeline filter impacts `state` in `/sync` response

Open
#1,886 2 comments 0 reactions 0 assignees View on GitHub
C-Sync-API F-Filters T-Defect
Dominant language
Go
Stars
965
Forks
101
PR merge metrics
No merged PRs in 30d

Description

*This issue was originally created by [**@PiotrKozimor**](https://github.com/PiotrKozimor) at .*

### Background information

- **Dendrite version or git SHA**: v0.3.11
- **Monolith or Polylith?**: monolith
- **SQLite3 or Postgres?**: postgres and sqlite3
- **Running in Docker?**: yes
- **`go version`**: 1.16

### Description

When state events are filtered out from timeline, they are transferred to `state` object. However, in https://github.com/matrix-org/matrix-doc/issues/627 it is suggested that this behaviour is incorrect.

The incorrect behaviour popped out in https://github.com/matrix-org/synapse/issues/10081.

Please also see https://github.com/matrix-org/synapse/issues/10081#issuecomment-866331619 for link to documentation.

### Steps to reproduce

Follow the instructions in https://github.com/matrix-org/synapse/issues/10081#issue-903848773. Please note that test case passes for `dendrite` and fails for `synapse`.

Please look below for expected (`synapse`) and actual (`dendrite`) `/sync` response.

Actual

```
{
"rooms": {
"invite": {},
"join": {
"!aZTcnTfR6Alyeps1:dendrite": {
"account_data": {
"events": []
},
"ephemeral": {
"events": []
},
"state": {
"events": [
{
"content": {
"foo": "grfuouzgqzviuj"
},
"event_id": "$nnO6JoCEM9e236giMMVqcjG4JTF1xNhotOeOFWLIJfw",
"origin_server_ts": 1624387876862,
"sender": "@zcncsunwogrlyv:dendrite",
"state_key": "one",
"type": "my.custom.event",
"unsigned": {
"prev_content": {
"foo": "ckqnycychntthy"
},
"prev_sender": "@zcncsunwogrlyv:dendrite",
"replaces_state": "$Snb87KMkje-LSv2u1gyn0d-ZuKXZonFn8Wm3NxLGjJE"
}
},
{
"content": {
"foo": "mnbhhzjpxkecqh"
},
"event_id": "$Y1nfLP7g9QuNsbW6EdF6l7ilrsZMrw6o-9QmcBwyMvw",
"origin_server_ts": 1624387876943,
"sender": "@zcncsunwogrlyv:dendrite",
"state_key": "two",
"type": "my.custom.event",
"unsigned": {
"prev_content": {
"foo": "zdcmzyrkpdsqaa"
},
"prev_sender": "@zcncsunwogrlyv:dendrite",
"replaces_state": "$vAcFSEx0o1I1VdJ007xlL2NtVS4rY6zi0CrIxO6y8jI"
}
},
{
"content": {
"foo": "gclqecjbstavcz"
},
"event_id": "$BNyGed2A5GUwuWX5rdyRPrdHn732hTa1-Z6oJfsnts0",
"origin_server_ts": 1624387877024,
"sender": "@zcncsunwogrlyv:dendrite",
"state_key": "three",
"type": "my.custom.event",
"unsigned": {
"prev_content": {
"foo": "iedxpoqshjioxu"
},
"prev_sender": "@zcncsunwogrlyv:dendrite",
"replaces_state": "$Lx8pLmR_3NGORxWfXDVkeSLknplDwMR-BpCGrHv4T-s"
}
}
]
},
"timeline": {
"events": [
{
"content": {
"creator": "@zcncsunwogrlyv:dendrite",
"room_version": "6"
},
"event_id": "$0uatKQUYDRAIxBqBNt8BXS1EDqJtygy-_Vba0Vr9-Z8",
"origin_server_ts": 1624387874692,
"sender": "@zcncsunwogrlyv:dendrite",
"state_key": "",
"type": "m.room.create"
},
{
"content": {
"displayname": "zcncsunwogrlyv",
"membership": "join"
},
"event_id": "$e9m9qUPAs6HBY1viZr2tO0nW00HSC7zlsqpzHfGqAwE",
"origin_server_ts": 1624387874692,
"sender": "@zcncsunwogrlyv:dendrite",
"state_key": "@zcncsunwogrlyv:dendrite",
"type": "m.room.member"
},
{
"content": {
"ban": 50,
"events": {
"m.room.aliases": 0,
"m.room.avatar": 50,
"m.room.canonical_alias": 50,
"m.room.history_visibility": 100,
"m.room.name": 50,
"m.room.power_levels": 100
},
"events_default": 0,
"invite": 0,
"kick": 50,
"notifications": {
"room": 50
},
"redact": 50,
"state_default": 50,
"users": {
"@zcncsunwogrlyv:dendrite": 100
},
"users_default": 0
},
"event_id": "$at7envb_kxr6dlX5jJUCFQQ9t7D6z2XTDMoUQEgT-6c",
"origin_server_ts": 1624387874692,
"sender": "@zcncsunwogrlyv:dendrite",
"state_key": "",
"type": "m.room.power_levels"
},
{
"content": {
"join_rule": "invite"
},
"event_id": "$DWq6ZgD7DSWsLt7XBiQYvzNSKtQ6jz7RZQizVXTnWyQ",
"origin_server_ts": 1624387874692,
"sender": "@zcncsunwogrlyv:dendrite",
"state_key": "",
"type": "m.room.join_rules"
},
{
"content": {
"history_visibility": "shared"
},
"event_id": "$R-5vjra24dMUfOfG0SEEbic6MKimoivFENqNBQjJDSc",
"origin_server_ts": 1624387874692,
"sender": "@zcncsunwogrlyv:dendrite",
"state_key": "",
"type": "m.room.history_visibility"
}
],
"limited": false,
"prev_batch": "t1_1"
}
}
},
"leave": {},
"peek": {}
}
}
```


Expected

```json
{
"rooms": {
"invite": {},
"join": {
"!syZVgKbGjBXuhlAzmb:dendrite": {
"account_data": {
"events": []
},
"ephemeral": {
"events": []
},
"org.matrix.msc2654.unread_count": 0,
"state": {
"events": []
},
"summary": {},
"timeline": {
"events": [
{
"content": {
"creator": "@zjangdesopjibi:dendrite",
"room_version": "6"
},
"event_id": "$fSssSjeYPxOHk27MNBtje8LxeNfoE5jtlg__bb6_3kU",
"origin_server_ts": 1624387692833,
"sender": "@zjangdesopjibi:dendrite",
"state_key": "",
"type": "m.room.create",
"unsigned": {
"age": 1921
}
},
{
"content": {
"displayname": "zjangdesopjibi",
"membership": "join"
},
"event_id": "$L-KYnoDt4d4mToBZK4rO2zLDNkie-Ktgh_4uM6MrCkY",
"origin_server_ts": 1624387692899,
"sender": "@zjangdesopjibi:dendrite",
"state_key": "@zjangdesopjibi:dendrite",
"type": "m.room.member",
"unsigned": {
"age": 1855
}
},
{
"content": {
"ban": 50,
"events": {
"m.room.avatar": 50,
"m.room.canonical_alias": 50,
"m.room.encryption": 100,
"m.room.history_visibility": 100,
"m.room.name": 50,
"m.room.power_levels": 100,
"m.room.server_acl": 100,
"m.room.tombstone": 100
},
"events_default": 0,
"invite": 50,
"kick": 50,
"redact": 50,
"state_default": 50,
"users": {
"@zjangdesopjibi:dendrite": 100
},
"users_default": 0
},
"event_id": "$WQjk12jM5ElmniWNvkp3MbQiHomrNyl9EsCs565HgZc",
"origin_server_ts": 1624387692943,
"sender": "@zjangdesopjibi:dendrite",
"state_key": "",
"type": "m.room.power_levels",
"unsigned": {
"age": 1811
}
},
{
"content": {
"join_rule": "public"
},
"event_id": "$dC0CofzAFpH0KIXoquI_c3FASTVIZnqAN99sppD96us",
"origin_server_ts": 1624387692978,
"sender": "@zjangdesopjibi:dendrite",
"state_key": "",
"type": "m.room.join_rules",
"unsigned": {
"age": 1776
}
},
{
"content": {
"history_visibility": "shared"
},
"event_id": "$F9vwOBKEqglsLwCijxk1rCa1ge7tqGMN05n9P79UQNg",
"origin_server_ts": 1624387693024,
"sender": "@zjangdesopjibi:dendrite",
"state_key": "",
"type": "m.room.history_visibility",
"unsigned": {
"age": 1730
}
}
],
"limited": false,
"prev_batch": "s36_2_0_1_1_1_1_2_1"
},
"unread_notifications": {
"highlight_count": 0,
"notification_count": 0
}
}
},
"leave": {}
}
}
```


Contributor guide

Open the contributing guide

Research direction

Start at the `/sync` endpoint and reproduce the timeline-filter scenario using the instructions linked from the issue and Synapse. Compare the actual and expected responses against the Matrix specification references, then verify that filtered state events are returned in the correct response section for both PostgreSQL and SQLite deployments.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, postgresql, sqlite
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.