diff options
15 files changed, 25 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore index 69e0722..fd6064a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ matrix-sync.json MatrixRoomUtils.Bot/bot_data/ appsettings.Local*.json cache/ +token_map diff --git a/MxApiExtensions.Classes.LibMatrix/MxApiExtensions.Classes.LibMatrix.csproj b/MxApiExtensions.Classes.LibMatrix/MxApiExtensions.Classes.LibMatrix.csproj index db9f354..fa9885d 100644 --- a/MxApiExtensions.Classes.LibMatrix/MxApiExtensions.Classes.LibMatrix.csproj +++ b/MxApiExtensions.Classes.LibMatrix/MxApiExtensions.Classes.LibMatrix.csproj @@ -4,6 +4,7 @@ <TargetFramework>net7.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> + <LangVersion>preview</LangVersion> </PropertyGroup> <ItemGroup> diff --git a/MxApiExtensions.Classes.LibMatrix/MxApiMatrixException.cs b/MxApiExtensions.Classes.LibMatrix/MxApiMatrixException.cs index e5f434a..387e47b 100644 --- a/MxApiExtensions.Classes.LibMatrix/MxApiMatrixException.cs +++ b/MxApiExtensions.Classes.LibMatrix/MxApiMatrixException.cs @@ -1,7 +1,7 @@ using ArcaneLibs.Extensions; using LibMatrix; -namespace MxApiExtensions; +namespace MxApiExtensions.Classes.LibMatrix; public class MxApiMatrixException : MatrixException { public string? GetAsJson() => new { ErrorCode, Error, SoftLogout, RetryAfterMs }.ToJson(ignoreNull: true); diff --git a/MxApiExtensions.Classes.LibMatrix/RoomInfoEntry.cs b/MxApiExtensions.Classes.LibMatrix/RoomInfoEntry.cs index 6ea188e..a406b0e 100644 --- a/MxApiExtensions.Classes.LibMatrix/RoomInfoEntry.cs +++ b/MxApiExtensions.Classes.LibMatrix/RoomInfoEntry.cs @@ -1,7 +1,6 @@ -using System.Text.Json.Serialization; -using LibMatrix.Responses; +using LibMatrix.Responses; -namespace LibMatrix.MxApiExtensions; +namespace MxApiExtensions.Classes.LibMatrix; /// <summary> /// Generic room info, this will most likely be out of date due to caching! diff --git a/MxApiExtensions.Classes/MxApiExtensions.Classes.csproj b/MxApiExtensions.Classes/MxApiExtensions.Classes.csproj index 6836c68..332d516 100644 --- a/MxApiExtensions.Classes/MxApiExtensions.Classes.csproj +++ b/MxApiExtensions.Classes/MxApiExtensions.Classes.csproj @@ -4,6 +4,7 @@ <TargetFramework>net7.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> + <LangVersion>preview</LangVersion> </PropertyGroup> </Project> diff --git a/MxApiExtensions/Controllers/ClientVersionsController.cs b/MxApiExtensions/Controllers/ClientVersionsController.cs index 60a3364..518b954 100644 --- a/MxApiExtensions/Controllers/ClientVersionsController.cs +++ b/MxApiExtensions/Controllers/ClientVersionsController.cs @@ -19,7 +19,7 @@ public class ClientVersionsController : ControllerBase { [HttpGet("/_matrix/client/versions")] public async Task<ClientVersionsResponse> Proxy([FromQuery] string? access_token, string? _) { - var clientVersions = new ClientVersionsResponse() { + var clientVersions = new ClientVersionsResponse { Versions = new() { "r0.0.1", "r0.1.0", diff --git a/MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs b/MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs index 3c4161d..912d1da 100644 --- a/MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs +++ b/MxApiExtensions/Controllers/Extensions/JoinedRoomListController.cs @@ -2,10 +2,10 @@ using System.Collections.Concurrent; using System.Net.Http.Headers; using ArcaneLibs.Extensions; using LibMatrix.Homeservers; -using LibMatrix.MxApiExtensions; using LibMatrix.RoomTypes; using LibMatrix.StateEventTypes.Spec; using Microsoft.AspNetCore.Mvc; +using MxApiExtensions.Classes.LibMatrix; using MxApiExtensions.Services; namespace MxApiExtensions.Controllers.Extensions; @@ -82,8 +82,6 @@ public class JoinedRoomListController : ControllerBase { } } - private SemaphoreSlim _roomInfoSemaphore = new(100, 100); - private async Task<RoomInfoEntry> GetRoomInfo(AuthenticatedHomeserverGeneric hs, string roomId) { _logger.LogInformation("Getting room info for {room} for {user} ({hs})", roomId, hs.UserId, hs.FullHomeServerDomain); var room = await hs.GetRoom(roomId); @@ -101,8 +99,8 @@ public class JoinedRoomListController : ControllerBase { result.StateCount++; if (@event.Type != "m.room.member") result.RoomState.Add(@event); else { - if(!result.MemberCounts.ContainsKey((@event.TypedContent as RoomMemberEventData)?.Membership)) result.MemberCounts.Add((@event.TypedContent as RoomMemberEventData)?.Membership, 0); - result.MemberCounts[(@event.TypedContent as RoomMemberEventData)?.Membership]++; + if(!result.MemberCounts.ContainsKey((@event.TypedContent as RoomMemberEventContent)?.Membership)) result.MemberCounts.Add((@event.TypedContent as RoomMemberEventContent)?.Membership, 0); + result.MemberCounts[(@event.TypedContent as RoomMemberEventContent)?.Membership]++; } } diff --git a/MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs b/MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs index 71bf167..0dcc3bb 100644 --- a/MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs +++ b/MxApiExtensions/Controllers/Extensions/ProxyConfigurationController.cs @@ -1,6 +1,6 @@ using System.Collections.Concurrent; -using LibMatrix.MxApiExtensions; using Microsoft.AspNetCore.Mvc; +using MxApiExtensions.Classes.LibMatrix; using MxApiExtensions.Services; namespace MxApiExtensions.Controllers.Extensions; diff --git a/MxApiExtensions/Controllers/GenericProxyController.cs b/MxApiExtensions/Controllers/GenericProxyController.cs index 4e27b4a..3481914 100644 --- a/MxApiExtensions/Controllers/GenericProxyController.cs +++ b/MxApiExtensions/Controllers/GenericProxyController.cs @@ -1,5 +1,6 @@ using System.Net.Http.Headers; using Microsoft.AspNetCore.Mvc; +using MxApiExtensions.Classes.LibMatrix; using MxApiExtensions.Services; namespace MxApiExtensions.Controllers; diff --git a/MxApiExtensions/Controllers/LoginController.cs b/MxApiExtensions/Controllers/LoginController.cs index 1a7970a..1ad3247 100644 --- a/MxApiExtensions/Controllers/LoginController.cs +++ b/MxApiExtensions/Controllers/LoginController.cs @@ -4,6 +4,7 @@ using LibMatrix.Extensions; using LibMatrix.Responses; using LibMatrix.Services; using Microsoft.AspNetCore.Mvc; +using MxApiExtensions.Classes.LibMatrix; using MxApiExtensions.Services; namespace MxApiExtensions.Controllers; @@ -31,7 +32,7 @@ public class LoginController : ControllerBase { Response.StatusCode = (int)StatusCodes.Status403Forbidden; Response.ContentType = "application/json"; await Response.StartAsync(); - await Response.WriteAsync(new MxApiMatrixException() { + await Response.WriteAsync(new MxApiMatrixException { ErrorCode = "M_FORBIDDEN", Error = "[MxApiExtensions] Invalid username, must be of the form @user#domain:" + Request.Host.Value }.GetAsJson() ?? ""); diff --git a/MxApiExtensions/Controllers/SyncController.cs b/MxApiExtensions/Controllers/SyncController.cs index 382d670..2bc47c1 100644 --- a/MxApiExtensions/Controllers/SyncController.cs +++ b/MxApiExtensions/Controllers/SyncController.cs @@ -12,6 +12,7 @@ using LibMatrix.RoomTypes; using LibMatrix.StateEventTypes.Spec; using Microsoft.AspNetCore.Mvc; using MxApiExtensions.Classes; +using MxApiExtensions.Classes.LibMatrix; using MxApiExtensions.Extensions; using MxApiExtensions.Services; @@ -201,7 +202,7 @@ public class SyncController : ControllerBase { Join = new() { { room.RoomId, - new SyncResult.RoomsDataStructure.JoinedRoomDataStructure() { + new SyncResult.RoomsDataStructure.JoinedRoomDataStructure { AccountData = new() { Events = new() }, @@ -246,7 +247,7 @@ public class SyncController : ControllerBase { .Where(x => x.Type == "m.room.member" && x.StateKey != syncState.Homeserver.WhoAmI.UserId - && (x.TypedContent as RoomMemberEventData).Membership == "join" + && (x.TypedContent as RoomMemberEventContent).Membership == "join" ) .Select(x => x.StateKey)); joinRoom.Summary.JoinedMemberCount = joinRoom.Summary.Heroes.Count; @@ -256,8 +257,8 @@ public class SyncController : ControllerBase { } private async Task<StateEventResponse> GetStatusMessage(SyncState syncState, string message) { - return new StateEventResponse() { - TypedContent = new PresenceStateEventData() { + return new StateEventResponse { + TypedContent = new PresenceEventContent { DisplayName = "MxApiExtensions", Presence = "online", StatusMessage = message, diff --git a/MxApiExtensions/MxApiExtensions.csproj b/MxApiExtensions/MxApiExtensions.csproj index 86bc290..3939012 100644 --- a/MxApiExtensions/MxApiExtensions.csproj +++ b/MxApiExtensions/MxApiExtensions.csproj @@ -5,11 +5,12 @@ <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <InvariantGlobalization>true</InvariantGlobalization> + <LangVersion>preview</LangVersion> </PropertyGroup> <ItemGroup> - <PackageReference Include="ArcaneLibs" Version="1.0.0-preview5671923708.4c89a6e" /> - <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-preview.6.23329.11" /> + <PackageReference Include="ArcaneLibs" Version="1.0.0-preview6067543155.b32af48" /> + <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-preview.7.23375.9" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> </ItemGroup> diff --git a/MxApiExtensions/Program.cs b/MxApiExtensions/Program.cs index a219e83..cdbdb59 100644 --- a/MxApiExtensions/Program.cs +++ b/MxApiExtensions/Program.cs @@ -1,6 +1,7 @@ using LibMatrix.Services; using Microsoft.AspNetCore.Http.Timeouts; using MxApiExtensions; +using MxApiExtensions.Classes.LibMatrix; using MxApiExtensions.Services; var builder = WebApplication.CreateBuilder(args); diff --git a/MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs b/MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs index 96b0254..dc8a8dc 100644 --- a/MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs +++ b/MxApiExtensions/Services/AuthenticatedHomeserverProviderService.cs @@ -1,5 +1,6 @@ using LibMatrix.Homeservers; using LibMatrix.Services; +using MxApiExtensions.Classes.LibMatrix; namespace MxApiExtensions.Services; diff --git a/MxApiExtensions/Services/AuthenticationService.cs b/MxApiExtensions/Services/AuthenticationService.cs index 09a6e70..9eac20a 100644 --- a/MxApiExtensions/Services/AuthenticationService.cs +++ b/MxApiExtensions/Services/AuthenticationService.cs @@ -1,4 +1,5 @@ using LibMatrix.Services; +using MxApiExtensions.Classes.LibMatrix; namespace MxApiExtensions.Services; |