matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

redundant top-level `membership` field in m.room.member events #6226

Open hugecheese opened 5 years ago

hugecheese commented 5 years ago

When doing an initial /sync, the matrix.org homeserver returned the following event:

{
  "content": {
    "avatar_url": "mxc://t2bot.io/07d8a5673f277eb13a7ceb68bc554fef",
    "displayname": "pad (Telegram)",
    "membership": "join"
  },
  "event_id": "$154217899961853PiOIa:t2bot.io",
  "membership": "join",
  "origin_server_ts": 1542178999598,
  "sender": "@telegram_727304627:t2bot.io",
  "state_key": "@telegram_727304627:t2bot.io",
  "type": "m.room.member",
  "unsigned": {
    "age": 29364346302
  }
}

This is a State Event. For some reason, it has both a top-level membership field (which it probably shouldn't?), and one inside the content (as required by the spec).

This is particularly strange because in almost all m.room.member events this will not occur, but it sometimes does, returning two membership fields rather than one. This is harmless for clients, but there may be some underlying bug in synapse?

richvdh commented 5 years ago

I thought we had an open issue for this, but I can't find it.

It's not an underlying bug: the field used to live at the top level, and when we moved it into content, we added some code to copy it to the top level for compatibility with older clients.

We should get rid of it though.