about summary refs log tree commit diff
path: root/LibMatrix
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-07-15 07:50:36 +0200
committerRory& <root@rory.gay>2024-07-15 07:50:36 +0200
commit107bf85658661631dc5bab26e0d768993ee54165 (patch)
tree010b0d55dd284e4027a30f0894f84efeeb91269d /LibMatrix
parentReturn null on TryGetFromJson if a JsonException happens (diff)
downloadLibMatrix-107bf85658661631dc5bab26e0d768993ee54165.tar.xz
Import unit test fixes from dev/home-changes
Diffstat (limited to 'LibMatrix')
-rw-r--r--LibMatrix/RoomTypes/GenericRoom.cs6
-rw-r--r--LibMatrix/RoomTypes/SpaceRoom.cs4
2 files changed, 6 insertions, 4 deletions
diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs
index fe2ee8d..b906f08 100644
--- a/LibMatrix/RoomTypes/GenericRoom.cs
+++ b/LibMatrix/RoomTypes/GenericRoom.cs
@@ -388,12 +388,12 @@ public class GenericRoom {
         await Homeserver.ClientHttpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/ban",
             new UserIdAndReason { UserId = userId, Reason = reason });
 
-    public async Task UnbanAsync(string userId) =>
+    public async Task UnbanAsync(string userId, string? reason = null) =>
         await Homeserver.ClientHttpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/unban",
-            new UserIdAndReason { UserId = userId });
+            new UserIdAndReason { UserId = userId, Reason = reason});
 
     public async Task InviteUserAsync(string userId, string? reason = null, bool skipExisting = true) {
-        if (skipExisting && await GetStateAsync<RoomMemberEventContent>("m.room.member", userId) is not null)
+        if (skipExisting && await GetStateOrNullAsync<RoomMemberEventContent>("m.room.member", userId) is not null)
             return;
         await Homeserver.ClientHttpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/invite", new UserIdAndReason(userId, reason));
     }
diff --git a/LibMatrix/RoomTypes/SpaceRoom.cs b/LibMatrix/RoomTypes/SpaceRoom.cs
index b40ccc6..4563ed3 100644
--- a/LibMatrix/RoomTypes/SpaceRoom.cs
+++ b/LibMatrix/RoomTypes/SpaceRoom.cs
@@ -4,6 +4,8 @@ using LibMatrix.Homeservers;
 namespace LibMatrix.RoomTypes;
 
 public class SpaceRoom(AuthenticatedHomeserverGeneric homeserver, string roomId) : GenericRoom(homeserver, roomId) {
+    public const string TypeName = "m.space";
+
     public async IAsyncEnumerable<GenericRoom> GetChildrenAsync(bool includeRemoved = false) {
         // var rooms = new List<GenericRoom>();
         var state = GetFullStateAsync();
@@ -31,7 +33,7 @@ public class SpaceRoom(AuthenticatedHomeserverGeneric homeserver, string roomId)
         });
         return resp;
     }
-    
+
     public async Task<EventIdResponse> AddChildByIdAsync(string id) {
         return await AddChildAsync(Homeserver.GetRoom(id));
     }