diff --git a/lib/src/Room.dart b/lib/src/Room.dart index b333f23..94a6d91 100644 --- a/lib/src/Room.dart +++ b/lib/src/Room.dart @@ -70,7 +70,9 @@ class Room { Map 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"]; diff --git a/lib/src/User.dart b/lib/src/User.dart index 311c5fe..dcd08eb 100644 --- a/lib/src/User.dart +++ b/lib/src/User.dart @@ -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