From cb8846a7a3310f8513989da5aadb5202f048a1b3 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 14 Aug 2023 19:46:11 +0200 Subject: Code cleanup --- LibMatrix/RoomTypes/GenericRoom.cs | 10 +++++----- LibMatrix/RoomTypes/SpaceRoom.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'LibMatrix/RoomTypes') diff --git a/LibMatrix/RoomTypes/GenericRoom.cs b/LibMatrix/RoomTypes/GenericRoom.cs index b935b9d..df1eb52 100644 --- a/LibMatrix/RoomTypes/GenericRoom.cs +++ b/LibMatrix/RoomTypes/GenericRoom.cs @@ -100,8 +100,8 @@ public class GenericRoom { public async IAsyncEnumerable GetMembersAsync(bool joinedOnly = true) { var res = GetFullStateAsync(); await foreach (var member in res) { - if (member.Type != "m.room.member") continue; - if (joinedOnly && (member.TypedContent as RoomMemberEventData).Membership is not "join") continue; + if (member?.Type != "m.room.member") continue; + if (joinedOnly && (member.TypedContent as RoomMemberEventData)?.Membership is not "join") continue; yield return member; } } @@ -147,15 +147,15 @@ public class GenericRoom { public async Task KickAsync(string userId, string? reason = null) => await _httpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/kick", - new UserIdAndReason() { UserId = userId, Reason = reason }); + new UserIdAndReason { UserId = userId, Reason = reason }); public async Task BanAsync(string userId, string? reason = null) => await _httpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/ban", - new UserIdAndReason() { UserId = userId, Reason = reason }); + new UserIdAndReason { UserId = userId, Reason = reason }); public async Task UnbanAsync(string userId) => await _httpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/unban", - new UserIdAndReason() { UserId = userId }); + new UserIdAndReason { UserId = userId }); public async Task SendStateEventAsync(string eventType, object content) => await (await _httpClient.PostAsJsonAsync($"/_matrix/client/v3/rooms/{RoomId}/state/{eventType}", content)) diff --git a/LibMatrix/RoomTypes/SpaceRoom.cs b/LibMatrix/RoomTypes/SpaceRoom.cs index ff2c228..5393ee7 100644 --- a/LibMatrix/RoomTypes/SpaceRoom.cs +++ b/LibMatrix/RoomTypes/SpaceRoom.cs @@ -3,7 +3,7 @@ using LibMatrix.Extensions; namespace LibMatrix.RoomTypes; public class SpaceRoom : GenericRoom { - private readonly AuthenticatedHomeServer _homeServer; + private new readonly AuthenticatedHomeServer _homeServer; private readonly GenericRoom _room; public SpaceRoom(AuthenticatedHomeServer homeServer, string roomId) : base(homeServer, roomId) { -- cgit 1.4.1