From aa7026a17ededf7c181ed269c6388491d96e1b1e Mon Sep 17 00:00:00 2001 From: "Emma@Rory&" Date: Mon, 14 Aug 2023 05:07:51 +0200 Subject: Split LibMatrix into submodule --- MatrixRoomUtils.Core/Interfaces/IHomeServer.cs | 31 ------------ MatrixRoomUtils.Core/Interfaces/IStateEventType.cs | 5 -- .../Interfaces/Services/IStorageProvider.cs | 58 ---------------------- 3 files changed, 94 deletions(-) delete mode 100644 MatrixRoomUtils.Core/Interfaces/IHomeServer.cs delete mode 100644 MatrixRoomUtils.Core/Interfaces/IStateEventType.cs delete mode 100644 MatrixRoomUtils.Core/Interfaces/Services/IStorageProvider.cs (limited to 'MatrixRoomUtils.Core/Interfaces') diff --git a/MatrixRoomUtils.Core/Interfaces/IHomeServer.cs b/MatrixRoomUtils.Core/Interfaces/IHomeServer.cs deleted file mode 100644 index 3521a51..0000000 --- a/MatrixRoomUtils.Core/Interfaces/IHomeServer.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System.Net.Http.Json; -using System.Text.Json; -using MatrixRoomUtils.Core.Extensions; -using MatrixRoomUtils.Core.StateEventTypes; -using MatrixRoomUtils.Core.StateEventTypes.Spec; - -namespace MatrixRoomUtils.Core.Interfaces; - -public class IHomeServer { - private readonly Dictionary _profileCache = new(); - public string HomeServerDomain { get; set; } - public string FullHomeServerDomain { get; set; } - - public MatrixHttpClient _httpClient { get; set; } = new(); - - public async Task GetProfile(string mxid) { - if(mxid is null) throw new ArgumentNullException(nameof(mxid)); - if (_profileCache.ContainsKey(mxid)) { - if (_profileCache[mxid] is SemaphoreSlim s) await s.WaitAsync(); - if (_profileCache[mxid] is ProfileResponseEventData p) return p; - } - _profileCache[mxid] = new SemaphoreSlim(1); - - var resp = await _httpClient.GetAsync($"/_matrix/client/v3/profile/{mxid}"); - var data = await resp.Content.ReadFromJsonAsync(); - if (!resp.IsSuccessStatusCode) Console.WriteLine("Profile: " + data); - _profileCache[mxid] = data; - - return data; - } -} diff --git a/MatrixRoomUtils.Core/Interfaces/IStateEventType.cs b/MatrixRoomUtils.Core/Interfaces/IStateEventType.cs deleted file mode 100644 index 053f50c..0000000 --- a/MatrixRoomUtils.Core/Interfaces/IStateEventType.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace MatrixRoomUtils.Core.Interfaces; - -public interface IStateEventType { - -} \ No newline at end of file diff --git a/MatrixRoomUtils.Core/Interfaces/Services/IStorageProvider.cs b/MatrixRoomUtils.Core/Interfaces/Services/IStorageProvider.cs deleted file mode 100644 index 1de9885..0000000 --- a/MatrixRoomUtils.Core/Interfaces/Services/IStorageProvider.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace MatrixRoomUtils.Core.Interfaces.Services; - -public interface IStorageProvider { - // save all children of a type with reflection - public Task SaveAllChildrenAsync(string key, T value) { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement SaveAllChildren(key, value)!"); - throw new NotImplementedException(); - } - - // load all children of a type with reflection - public Task LoadAllChildrenAsync(string key) { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement LoadAllChildren(key)!"); - throw new NotImplementedException(); - } - - - public Task SaveObjectAsync(string key, T value) { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement SaveObject(key, value)!"); - throw new NotImplementedException(); - } - - // load - public Task LoadObjectAsync(string key) { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement LoadObject(key)!"); - throw new NotImplementedException(); - } - - // check if exists - public Task ObjectExistsAsync(string key) { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement ObjectExists(key)!"); - throw new NotImplementedException(); - } - - // get all keys - public Task> GetAllKeysAsync() { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement GetAllKeys()!"); - throw new NotImplementedException(); - } - - - // delete - public Task DeleteObjectAsync(string key) { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement DeleteObject(key)!"); - throw new NotImplementedException(); - } - - // save stream - public Task SaveStreamAsync(string key, Stream stream) { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement SaveStream(key, stream)!"); - throw new NotImplementedException(); - } - - // load stream - public Task LoadStreamAsync(string key) { - Console.WriteLine($"StorageProvider<{GetType().Name}> does not implement LoadStream(key)!"); - throw new NotImplementedException(); - } -} -- cgit 1.5.1