matrix-org / matrix-viewer

View the history of public and world readable Matrix rooms
https://archive.matrix.org
Apache License 2.0
74 stars 11 forks source link

Join event spam because of unstable URL in `reason` #267

Closed MadLittleMods closed 1 year ago

MadLittleMods commented 1 year ago

Join event spam because of unstable URL in reason which means any time it's different, will create a new state event. Depending on how someone views the archive, the reason text will include a different URL.

Example:

Flip-flopping between https://archive.matrix.org/roomid/wOlkWNmgkAZFxbTaqj:matrix.org with the room ID and https://archive.matrix.org/r/raspberrypi:matrix.org with the room alias depending on how the URL is visited.

{
  "content": {
    "displayname": "archive.matrix.org/faq",
    "membership": "join",
    "reason": "Joining room to check history visibility. If your room is public with shared or world readable history visibility, it will be accessible at https://archive.matrix.org/roomid/wOlkWNmgkAZFxbTaqj:matrix.org. See the FAQ for more details: https://github.com/matrix-org/matrix-public-archive/blob/main/docs/faq.md#why-did-the-archive-bot-join-my-room"
  },
  "origin_server_ts": 1687415330265,
  "sender": "@archive:matrix.org",
  "state_key": "@archive:matrix.org",
  "type": "m.room.member",
  "unsigned": {
    "replaces_state": "$wlnRuzw6mTVYvUMkBmHD5jXGROSZglqnzG7ZrRQtmOA",
    "prev_content": {
      "displayname": "archive.matrix.org/faq",
      "membership": "join",
      "reason": "Joining room to check history visibility. If your room is public with shared or world readable history visibility, it will be accessible at https://archive.matrix.org/r/raspberrypi:matrix.org. See the FAQ for more details: https://github.com/matrix-org/matrix-public-archive/blob/main/docs/faq.md#why-did-the-archive-bot-join-my-room"
    },
    "prev_sender": "@archive:matrix.org",
    "age": 2558
  },
  "event_id": "$cyfYrA3MW6w2c44z1_VWNfeRgUko2HkBlTM11EZqB1E",
  "room_id": "!wOlkWNmgkAZFxbTaqj:matrix.org"
}

Potential solutions

It would be nice if we could always use the room ID so it's consistent regardless of the alias someone visits from. But we don't have access to the room ID before we join.

Another simple option is to just remove the URL altogether.

Dev notes

The join reason logic was originally added in https://github.com/matrix-org/matrix-public-archive/pull/262