Unknown changes
2 files changed, 23 insertions, 3 deletions
diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs
index b557e47..349c8a7 100644
--- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs
+++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomJoinRulesEventContent.cs
@@ -43,6 +43,10 @@ public class RoomJoinRulesEventContent : EventContent {
[JsonPropertyName("room_id")]
public required string RoomId { get; set; }
+
+ public static class Types {
+ public const string RoomMembership = "m.room_membership";
+ }
}
public enum JoinRules {
diff --git a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs
index cb9ebb7..49a1b62 100644
--- a/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs
+++ b/LibMatrix.EventTypes/Spec/State/RoomInfo/RoomPowerLevelEventContent.cs
@@ -59,15 +59,31 @@ public class RoomPowerLevelEventContent : EventContent {
public bool UserHasStatePermission(string userId, string eventType) {
ArgumentNullException.ThrowIfNull(userId);
- return Users.TryGetValue(userId, out var level) && level >= Events.GetValueOrDefault(eventType, StateDefault ?? 50);
+ var userLevel = GetUserPowerLevel(userId);
+ var eventLevel = GetStateEventPowerLevel(eventType);
+
+ Console.WriteLine($"{userId}={userLevel} >= {eventType}={eventLevel} = {userLevel >= eventLevel}");
+
+ return userLevel >= eventLevel;
}
public long GetUserPowerLevel(string userId) {
ArgumentNullException.ThrowIfNull(userId);
- return Users.TryGetValue(userId, out var level) ? level : UsersDefault ?? UsersDefault ?? 0;
+ if (Users is null) return UsersDefault ?? 0;
+ return Users.TryGetValue(userId, out var level) ? level : UsersDefault ?? 0;
}
- public long GetEventPowerLevel(string eventType) => Events.TryGetValue(eventType, out var level) ? level : EventsDefault ?? EventsDefault ?? 0;
+ public long GetStateEventPowerLevel(string eventType) {
+ ArgumentNullException.ThrowIfNull(eventType);
+ if (Events is null) return StateDefault ?? 0;
+ return Events.TryGetValue(eventType, out var level) ? level : StateDefault ?? 0;
+ }
+
+ public long GetTimelineEventPowerLevel(string eventType) {
+ ArgumentNullException.ThrowIfNull(eventType);
+ if (Events is null) return EventsDefault ?? 0;
+ return Events.TryGetValue(eventType, out var level) ? level : EventsDefault ?? 0;
+ }
public void SetUserPowerLevel(string userId, long powerLevel) {
ArgumentNullException.ThrowIfNull(userId);
|