From dc3201d641a03e051c6f0db07612eb6b0bb506c3 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Thu, 4 May 2023 15:26:17 +0200 Subject: Dark theme, fancier room list --- MatrixRoomUtils.Core/AuthenticatedHomeServer.cs | 1 - MatrixRoomUtils.Core/Extensions/StringExtensions.cs | 2 -- MatrixRoomUtils.Core/RemoteHomeServer.cs | 2 -- MatrixRoomUtils.Core/Responses/LoginResponse.cs | 1 - MatrixRoomUtils.Core/Room.cs | 10 +++------- 5 files changed, 3 insertions(+), 13 deletions(-) (limited to 'MatrixRoomUtils.Core') diff --git a/MatrixRoomUtils.Core/AuthenticatedHomeServer.cs b/MatrixRoomUtils.Core/AuthenticatedHomeServer.cs index 031b6b6..6f5df39 100644 --- a/MatrixRoomUtils.Core/AuthenticatedHomeServer.cs +++ b/MatrixRoomUtils.Core/AuthenticatedHomeServer.cs @@ -1,7 +1,6 @@ using System.Net.Http.Headers; using System.Net.Http.Json; using System.Text.Json; -using MatrixRoomUtils.Core.Extensions; using MatrixRoomUtils.Core.Interfaces; namespace MatrixRoomUtils.Core; diff --git a/MatrixRoomUtils.Core/Extensions/StringExtensions.cs b/MatrixRoomUtils.Core/Extensions/StringExtensions.cs index 7bed7a3..8fadc6d 100644 --- a/MatrixRoomUtils.Core/Extensions/StringExtensions.cs +++ b/MatrixRoomUtils.Core/Extensions/StringExtensions.cs @@ -1,5 +1,3 @@ -using MatrixRoomUtils.Core.Authentication; - namespace MatrixRoomUtils.Core.Extensions; public static class StringExtensions diff --git a/MatrixRoomUtils.Core/RemoteHomeServer.cs b/MatrixRoomUtils.Core/RemoteHomeServer.cs index 6bd2251..1acea89 100644 --- a/MatrixRoomUtils.Core/RemoteHomeServer.cs +++ b/MatrixRoomUtils.Core/RemoteHomeServer.cs @@ -1,7 +1,5 @@ -using System.Net.Http.Headers; using System.Net.Http.Json; using System.Text.Json; -using MatrixRoomUtils.Core.Extensions; using MatrixRoomUtils.Core.Interfaces; using MatrixRoomUtils.Core.Responses; diff --git a/MatrixRoomUtils.Core/Responses/LoginResponse.cs b/MatrixRoomUtils.Core/Responses/LoginResponse.cs index 4012d32..34b42d1 100644 --- a/MatrixRoomUtils.Core/Responses/LoginResponse.cs +++ b/MatrixRoomUtils.Core/Responses/LoginResponse.cs @@ -1,7 +1,6 @@ using System.Net.Http.Json; using System.Text.Json; using System.Text.Json.Serialization; -using MatrixRoomUtils.Core.Authentication; namespace MatrixRoomUtils.Core.Responses; diff --git a/MatrixRoomUtils.Core/Room.cs b/MatrixRoomUtils.Core/Room.cs index fff5013..d5eee2b 100644 --- a/MatrixRoomUtils.Core/Room.cs +++ b/MatrixRoomUtils.Core/Room.cs @@ -14,9 +14,8 @@ public class Room RoomId = roomId; } - public async Task GetStateAsync(string type, string state_key="") + public async Task GetStateAsync(string type, string state_key="", bool logOnFailure = false) { - Console.WriteLine($"{RoomId}::_qry[{type}::{state_key}]"); var url = $"/_matrix/client/r0/rooms/{RoomId}/state"; if (!string.IsNullOrEmpty(state_key)) url += $"/{type}/{state_key}"; else if (!string.IsNullOrEmpty(type)) url += $"/{type}"; @@ -24,21 +23,18 @@ public class Room var res = await _httpClient.GetAsync(url); if (!res.IsSuccessStatusCode) { - Console.WriteLine($"{RoomId}::_qry[{type}::{state_key}]->status=={res.StatusCode}"); + if(logOnFailure) Console.WriteLine($"{RoomId}/{state_key}/{type} - got status: {res.StatusCode}"); return null; } return await res.Content.ReadFromJsonAsync(); } public async Task GetNameAsync() - { - Console.WriteLine($"{RoomId}::_qry_name"); + { var res = await GetStateAsync("m.room.name"); if (!res.HasValue) { - Console.WriteLine($"{RoomId}::_qry_name->null"); return null; } - Console.WriteLine($"{RoomId}::_qry_name->{res.Value.ToString()}"); var resn = res?.TryGetProperty("name", out var name) ?? false ? name.GetString() : null; Console.WriteLine($"Got name: {resn}"); return resn; -- cgit 1.5.1