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

Handle pre-shared invite keys #271

Closed
wants to merge 3 commits into from
Closed

Handle pre-shared invite keys #271

wants to merge 3 commits into from

Conversation

AndrewFerr
Copy link
Contributor

Signed-off-by: Andrew Ferrazzutti [email protected]

Checklist

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

Signed-off-by: Andrew Ferrazzutti <[email protected]>
Copy link
Owner

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the other thing I'm not sure on is whether this is actually recommended by the spec/rust-sdk - it doesn't appear to come up in documentation, though I'm willing to admit I might be blind.

src/e2ee/RustEngine.ts Outdated Show resolved Hide resolved
src/e2ee/RustEngine.ts Outdated Show resolved Hide resolved
@AndrewFerr
Copy link
Contributor Author

the other thing I'm not sure on is whether this is actually recommended by the spec/rust-sdk - it doesn't appear to come up in documentation, though I'm willing to admit I might be blind.

FWIW this is the behaviour Element Web uses. If you've invited a user with an encryption-enabled device to an encrypted room, EW will send the room key to that user (via a to-device message) even before they've joined the room. In fact, it sends the key even before you post a message -- it sends it as soon as you starting typing a message!

@AndrewFerr AndrewFerr requested a review from turt2live November 23, 2022 19:21
Treat an error in looking up room members of a particular membership
type as there being no members of that type.

Return early if no members are found.
AndrewFerr added a commit to element-hq/matrix-bot-sdk that referenced this pull request Dec 8, 2022
* Handle pre-shared invite keys

Signed-off-by: Andrew Ferrazzutti <[email protected]>

* Use assignment for changes to membership array

* Catch member lookup errors in prepareEncrypt

Treat an error in looking up room members of a particular membership
type as there being no members of that type.

Return early if no members are found.

* Resolve conflict on `members` variable

Signed-off-by: Andrew Ferrazzutti <[email protected]>
AndrewFerr added a commit to element-hq/matrix-bot-sdk that referenced this pull request Dec 8, 2022
* Handle pre-shared invite keys

Signed-off-by: Andrew Ferrazzutti <[email protected]>

* Use assignment for changes to membership array

* Catch member lookup errors in prepareEncrypt

Treat an error in looking up room members of a particular membership
type as there being no members of that type.

Return early if no members are found.

* Resolve conflict on `members` variable

Signed-off-by: Andrew Ferrazzutti <[email protected]>
AndrewFerr added a commit to element-hq/matrix-bot-sdk that referenced this pull request Dec 9, 2022
* Handle pre-shared invite keys

Signed-off-by: Andrew Ferrazzutti <[email protected]>

* Use assignment for changes to membership array

* Catch member lookup errors in prepareEncrypt

Treat an error in looking up room members of a particular membership
type as there being no members of that type.

Return early if no members are found.

* Resolve conflict on `members` variable

Signed-off-by: Andrew Ferrazzutti <[email protected]>
AndrewFerr added a commit to element-hq/matrix-bot-sdk that referenced this pull request Dec 9, 2022
* Handle pre-shared invite keys

Signed-off-by: Andrew Ferrazzutti <[email protected]>

* Use assignment for changes to membership array

* Catch member lookup errors in prepareEncrypt

Treat an error in looking up room members of a particular membership
type as there being no members of that type.

Return early if no members are found.

* Resolve conflict on `members` variable

Signed-off-by: Andrew Ferrazzutti <[email protected]>
AndrewFerr added a commit to element-hq/matrix-bot-sdk that referenced this pull request Dec 9, 2022
* Handle pre-shared invite keys

Signed-off-by: Andrew Ferrazzutti <[email protected]>

* Use assignment for changes to membership array

* Catch member lookup errors in prepareEncrypt

Treat an error in looking up room members of a particular membership
type as there being no members of that type.

Return early if no members are found.

* Resolve conflict on `members` variable

Signed-off-by: Andrew Ferrazzutti <[email protected]>
.map(u => new UserId(u.membershipFor))
.forEach(u => void members.add(u));
} catch (err) {
LogService.warn("RustEngine", `Failed to get room members for membership type "${membership}" in ${roomId}`, extractRequestError(err));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should be consuming this error tbh

try {
(await this.client.getRoomMembersByMembership(roomId, membership))
.map(u => new UserId(u.membershipFor))
.forEach(u => void members.add(u));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

preferably we use a real for loop for this, as one-liners mixed in with try/catch is a bit confusing imo

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, we shouldn't need a Set here as someone can't exist in two states. Appending to an array (using push(...userIds)) should be fine?

@AndrewFerr AndrewFerr closed this by deleting the head repository Sep 27, 2023
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