[User] Add powerLevel

This commit is contained in:
Christian Pauly 2019-09-03 17:57:27 +02:00
parent 769c5a0697
commit c85308d8d4
2 changed files with 7 additions and 2 deletions

View File

@ -70,7 +70,9 @@ class Room {
Map<String, RoomAccountData> roomAccountData = {};
/// ID of the fully read marker event.
String get fullyRead => roomAccountData["m.fully_read"] != null ? roomAccountData["m.fully_read"].content["event_id"] : "";
String get fullyRead => roomAccountData["m.fully_read"] != null
? roomAccountData["m.fully_read"].content["event_id"]
: "";
/// If something changes, this callback will be triggered.
onRoomUpdate onUpdate;
@ -579,7 +581,7 @@ class Room {
return Event.fromJson(resp, this);
}
/// Returns the user's own power level.
/// Returns the power level of the given user ID.
int getPowerLevelByUserId(String userId) {
int powerLevel = 0;
RoomState powerLevelState = states["m.room.power_levels"];

View File

@ -83,6 +83,9 @@ class User extends RoomState {
/// The displayname of the user if the user has set one.
String get displayName => content != null ? content["displayname"] : null;
/// Returns the power level of this user.
int get powerLevel => room?.getPowerLevelByUserId(id);
/// The membership status of the user. One of:
/// join
/// invite