Add method room:get_alias_or_id()

This new methods returns the most adequate identifier for a room:

1. If defined, the room's canonical alias.
2. Otherwise, the first alias.
3. As a last resort, the room identifier is returned.
This commit is contained in:
Adrian Perez de Castro
2016-07-09 00:30:59 +03:00
parent eee489678b
commit c2de4bfd85

View File

@@ -207,6 +207,16 @@ function Room:update_aliases()
return false
end
function Room:get_alias_or_id()
if self.canonical_alias then
return self.canonical_alias
elseif #self.aliases > 0 then
return self.aliases[1]
else
return self.room_id
end
end
local make_unimplemented_handler = function (self, event)
local env_value = os.getenv("MATRIX_CLIENT_LOG_UNHANDLED_EVENTS")
if env_value and #env_value > 0 and env_value ~= "0" then