Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache non-encrypted rooms and skip fetching encrypted rooms on startup #39

Merged
merged 8 commits into from
Dec 4, 2023

Conversation

Half-Shot
Copy link
Member

We need this for specific situations where a bot is joined to a LOT of rooms, but the encrypted rooms are in the minority.

This should:

  • Cache rooms that explicitly do not have a encryption state event.
  • Recheck every time we see an encryption state event.

Checklist

  • Tests written for all new code
  • Linter has been satisfied
  • Sign-off given on the changes (see CONTRIBUTING.md)

@Half-Shot Half-Shot requested a review from a team as a code owner November 24, 2023 10:58
@Half-Shot Half-Shot force-pushed the hs/cache-non-encrypted-rooms branch from 93096bb to b2774e1 Compare November 24, 2023 11:07
@Half-Shot Half-Shot changed the title Cache non-encrypted rooms. Cache non-encrypted rooms and skip fetching encrypted rooms on startup Nov 27, 2023
@Half-Shot Half-Shot force-pushed the hs/cache-non-encrypted-rooms branch from c524ade to 6c129f1 Compare November 27, 2023 17:24
@Half-Shot Half-Shot force-pushed the hs/cache-non-encrypted-rooms branch from 6c129f1 to be459b0 Compare November 27, 2023 17:25
src/e2ee/RoomTracker.ts Outdated Show resolved Hide resolved
@Half-Shot Half-Shot requested a review from AndrewFerr November 29, 2023 20:31
@AndrewFerr
Copy link
Member

Looks like this introduces the possibility of the RoomTracker of an appservice intent's crypto client not doing a room check (via queueRoomCheck) on a known-encrypted room.

I believe the only consequence of that would be the bot-sdk's crypto store being slightly out-of-date until something else triggers a room check (and plenty of actions do trigger such a check). It shouldn't prevent events from being decryptable, however.

What would fix it is calling CryptoClient#isRoomEncrypted before each call to CryptoClient#decryptRoomEvent in Appservice.handleTransaction.

@Half-Shot
Copy link
Member Author

What would fix it is calling CryptoClient#isRoomEncrypted before each call to CryptoClient#decryptRoomEvent in Appservice.handleTransaction.

So the only place we don't do this is in appservice, the MatrixClient always does a check first. I'll update that in my appservice PR.

@Half-Shot Half-Shot merged commit da2792e into element-hq:main Dec 4, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants