Add Client.get_room_by_alias
This commit is contained in:
parent
0e4a572058
commit
3ddac22f78
@ -205,4 +205,16 @@ public interface Matrix.Client : GLib.Object {
|
|||||||
public abstract Room
|
public abstract Room
|
||||||
get_room_by_id(string room_id)
|
get_room_by_id(string room_id)
|
||||||
throws Matrix.Error;
|
throws Matrix.Error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a room object by the room alias specified
|
||||||
|
* in @param room_alias. If room data is not cached yet,
|
||||||
|
* {@link Matrix.Error.UNAVAILABLE} is thrown.
|
||||||
|
*
|
||||||
|
* @param room_alias a room alias
|
||||||
|
* @return a Matrix.Room object
|
||||||
|
*/
|
||||||
|
public abstract Room
|
||||||
|
get_room_by_alias(string room_alias)
|
||||||
|
throws Matrix.Error;
|
||||||
}
|
}
|
||||||
|
@ -453,4 +453,24 @@ public class Matrix.HTTPClient : Matrix.HTTPAPI, Matrix.Client {
|
|||||||
|
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Room
|
||||||
|
get_room_by_alias(string room_alias)
|
||||||
|
throws Matrix.Error
|
||||||
|
{
|
||||||
|
foreach (var entry in _rooms.entries) {
|
||||||
|
var room = entry.value;
|
||||||
|
|
||||||
|
if (room.canonical_alias == room_alias) {
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (room_alias in room.aliases) {
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Matrix.Error.UNAVAILABLE(
|
||||||
|
"Noo room data found for alias %s", room_alias);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user