From 107bf85658661631dc5bab26e0d768993ee54165 Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 15 Jul 2024 07:50:36 +0200 Subject: Import unit test fixes from dev/home-changes --- LibMatrix/RoomTypes/GenericRoom.cs | 6 +++--- LibMatrix/RoomTypes/SpaceRoom.cs | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'LibMatrix/RoomTypes') 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("m.room.member", userId) is not null) + if (skipExisting && await GetStateOrNullAsync("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 GetChildrenAsync(bool includeRemoved = false) { // var rooms = new List(); var state = GetFullStateAsync(); @@ -31,7 +33,7 @@ public class SpaceRoom(AuthenticatedHomeserverGeneric homeserver, string roomId) }); return resp; } - + public async Task AddChildByIdAsync(string id) { return await AddChildAsync(Homeserver.GetRoom(id)); } -- cgit 1.4.1