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

Fix: dont check for unverified devices in left members #838

Merged
merged 2 commits into from
Feb 13, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/models/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,14 @@ Room.prototype.hasUnverifiedDevices = async function() {
}
const memberIds = Object.keys(this.currentState.members);
for (const userId of memberIds) {
const devices = await this._client.getStoredDevicesForUser(userId);
if (devices.some((device) => device.isUnverified())) {
return true;
const membership = this.currentState.members[userId].membership;
// check for negative values rather than positive to be
// extra careful to not report false positives here
Copy link
Member

Choose a reason for hiding this comment

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

This isn't specific to your change, but this isn't actually a question of being extra careful: this is (currently) a tristate where a device can be verified, unverified or blocked, so it depends what you want to do in the case where the room contains blocked devices. In this case the presence of blocked devices won't affect the return of Room. hasUnverifiedDevices() which I think is probably the correct behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I meant being careful with checking the membership, but actually I should probably use getEncryptionTargetMembers instead.

if (membership !== "leave") {
const devices = await this._client.getStoredDevicesForUser(userId);
if (devices.some((device) => device.isUnverified())) {
return true;
}
}
}
return false;
Expand Down