famedly / matrix-dart-sdk

Matrix SDK written in pure Dart.
GNU Affero General Public License v3.0
62 stars 32 forks source link

Old left rooms reappear in broken state #1916

Closed emgrav closed 1 month ago

emgrav commented 2 months ago

Checklist

In which Project did the bug appear?

Famedly App

If you selected \"Other\" as Project, please enter in which project the bug occurred.

No response

On which platform did the bug appear?

Firefox

SDK Version

Unknown, but app v2.39.1-0-g0b66f4b1

Describe the problem caused by this bug

I logged into my account using element-desktop. After this, a dozen old left rooms from the archive appeared at the top of my room list in Famedly. The rooms are not visible in Element, and appear to be in a broken state. The "last activity" indicator in the room list is always the current time, meaning the rooms are pinned to the top of the room list sorted by activity. The rooms are all called "Empty chat", and attempting to leave them does nothing. Attempting to send a message in the rooms set the last activity to an actual timestamp, unpinning them from the room list. Sending the even did however not succeed.

Nico theorized that element did something with the room archive and account data which caused this to happen.

Steps To Reproduce

  1. Have old rooms from 2022 and 2023 in the archive
  2. Log into element-desktop

Screenshots or Logs

No response

Security related

No response

nico-famedly commented 1 month ago

I have also experienced that sometimes when opening the archive, possibly some account data events cause the room to be populated? Needs some debugging.

Clemens-Toegel commented 1 month ago

We also experience this problem with our client. In our setup no other client is involved which may cause a problem, we only tested with the matrix-dart-sdk. The behaviour is the following: In the same session no bug occurs, we can leave a room (lets say Room A) and find it then in the room list as archived room with membership leave. After a new login, however, we see Room A as 'Empty chat' room in our rooms list instead of in the archived rooms list. After debugging I have noticed that the left room Room A is in the archived rooms list as expected, but also in the rooms list (with membership joined!), which is why we see Room A in the rooms list with title 'Empty chat' and membership joined.

I have pinned this behaviour down to the version V30.0, before this version we don't see such a behaviour.

Having a look at the changelog I may think that https://github.com/famedly/matrix-dart-sdk/pull/1866 introduced this behaviour. Specifically, this change: https://github.com/famedly/matrix-dart-sdk/blob/4fd616bcbf483104d6a1be3c5b3b295b7687b87c/lib/encryption/key_manager.dart#L204

The JoinedRoomUpdate may cause the room to be added in the rooms list where it does not belong.

nico-famedly commented 1 month ago

Oh, that is very helpful, that indeed would explain the issue, thanks a lot! I will try and draft a fix for it later.