From f72f5b43e1e0293dca19fc48255e0df3a9a7fde4 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 14 Aug 2018 14:27:08 +0100 Subject: [PATCH] Add getVersion to Room To get the version number of the room as per https://github.com/matrix-org/matrix-doc/issues/1425 --- src/models/room.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/models/room.js b/src/models/room.js index 4f7ac3911..7e01eab64 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -174,6 +174,18 @@ function Room(roomId, opts) { } utils.inherits(Room, EventEmitter); +/** + * Gets the version of the room + * @returns {string} The version of the room, or null if it could not be determined + */ +Room.prototype.getVersion = function() { + const createEvent = this.currentState.getStateEvents("m.room.create", ""); + if (!createEvent) return null; + const ver = createEvent.getContent()['room_version']; + if (ver === undefined) return '1'; + return ver; +}; + /** * Get the list of pending sent events for this room *