1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2026-01-03 23:22:30 +03:00

add method to room to check for unverified devices

This commit is contained in:
Bruno Windels
2019-02-01 14:37:11 +01:00
parent 5e3ff7fc27
commit bc99c1f3ce

View File

@@ -589,6 +589,24 @@ Room.prototype._fixUpLegacyTimelineFields = function() {
.getState(EventTimeline.FORWARDS);
};
/**
* Returns whether there are any devices in the room that are unverified
* @return {bool} the result
*/
Room.prototype.hasUnverifiedDevices = async function() {
if (!this._client.isRoomEncrypted(this.roomId)) {
return false;
}
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;
}
}
return false;
};
/**
* Return the timeline sets for this room.
* @return {EventTimelineSet[]} array of timeline sets for this room