Store content for state, not the full events
Problem
Right now we are storing the full ClientEventWithoutRoomId
for every state event in the room's state.
That works fine until we hit the /rooms/{roomId}/state
API endpoint to get the latest version of some state.
Then we can't save the state that we receive, because the endpoint only provides the event content, not the full event with sender and event id etc.
Solution
Change the database schema, and the Room
's internal state representation, so that we only save the event type
, stateKey
, and content
for each event in the room state. Then we can keep the response from the /state
endpoint cached in the Room
's memory, and we can persist it to the database for future use.