Add new client:find_room(room_id_or_alias) method

This allows searching a (previosly joined) room given either their room
identifier or any of the room aliases.
This commit is contained in:
Adrian Perez de Castro
2016-07-10 02:43:50 +03:00
parent 876ca4ccc7
commit e6da7d88c3

View File

@@ -400,6 +400,21 @@ function Client:_make_room(room_id)
return room
end
function Client:find_room(room_id_or_alias)
for room_id, room in pairs(self.rooms) do
if room_id_or_alias == room_id or
room_id_or_alias == room.canonical_alias
then
return room
end
for _, alias in ipairs(room.aliases) do
if room_id_or_alias == alias then
return room
end
end
end
end
function Client:_make_user(user_id, display_name, avatar_url)
local user = self.presence[user_id]
if not user then