🌻Infrastructure And OperationsMatrix-Synapse

how to set retention period on matrix rooms

SEE: github.com/matrix-org/matrix-spec-proposals/blob/matthew/msc1763/proposals/1763-configurable-retention-periods.md

TBH i'm struggling a bit to set the retention in an automated fashion at all. We don't have a tool for it and it requires having admin in the room.
The best I was able to figure out so far

1. go to the cyberia space with the network tab of the dev tools open

2. look for the _matrix/client/v1/rooms/!XJhdXteYnRMldzWFyX%3Acyberia.club/hierarchy?suggested_only=true&max_depth=1&limit=20 GET request and copy its json response

3. extract the room ids with jq
4. ssh into the matrix server and run ./reset-password ed-209:cyberia.club
5. log in as ed-209
6. go to a room then type /devtools to open the devtools, and make sure the browser network tab is open
7. send a custom room state event with event type m.room.retention and body {"max_lifetime":86400000000}
8. find the PUT _matrix/client/r0/rooms/!roqAKCndauLBfhLdGs%3Acyberia.club/state/m.room.retention/ request in the network tab and right click -> copy as curl
9. write a script that runs this curl command for every room ID that you collected


  const list = `!JFYMcOkcWtccikJlkA%3Acyberia.club

const space = `

  console.log(space + 
  list.map(roomid => {
    return `curl 'https://matrix.cyberia.club/_matrix/client/r0/rooms/${roomid}/state/m.room.retention/' -X PUT  AUTH HEADER GOES HERE!!!  --data-raw '{"max_lifetime":86400000000}'`


so far its been slightly hit and miss but I'll check a few rooms and make sure it at least appears to have worked

( you can check a room by typing /devtools in the message box and then going to the explore room state section, there should be an entry for m.room.retention )