From 28adb35ab9b6905eebcd83b6caa1b12d49b26be7 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 18 May 2025 22:52:21 +0200 Subject: Various bug fixes --- LibMatrix/Helpers/MessageBuilder.cs | 10 ++++++++++ LibMatrix/Responses/LoginResponse.cs | 5 ----- LibMatrix/StateEvent.cs | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'LibMatrix') diff --git a/LibMatrix/Helpers/MessageBuilder.cs b/LibMatrix/Helpers/MessageBuilder.cs index 5e2b1b7..87a9992 100644 --- a/LibMatrix/Helpers/MessageBuilder.cs +++ b/LibMatrix/Helpers/MessageBuilder.cs @@ -94,6 +94,16 @@ public class MessageBuilder(string msgType = "m.text", string format = "org.matr public MessageBuilder WithMention(string id, string? displayName = null) { Content.Body += $"@{displayName ?? id}"; Content.FormattedBody += $"{displayName ?? id}"; + if(id == "@room") { + Content.Mentions ??= new(); + Content.Mentions.Room = true; + } + else if (id.StartsWith('@')) { + Content.Mentions ??= new(); + Content.Mentions.Users ??= new(); + Content.Mentions.Users.Add(id); + } + return this; } diff --git a/LibMatrix/Responses/LoginResponse.cs b/LibMatrix/Responses/LoginResponse.cs index 2f78932..1944276 100644 --- a/LibMatrix/Responses/LoginResponse.cs +++ b/LibMatrix/Responses/LoginResponse.cs @@ -19,11 +19,6 @@ public class LoginResponse { [JsonPropertyName("user_id")] public string UserId { get; set; } - - // public async Task GetAuthenticatedHomeserver(string? proxy = null) { - // var urls = await new HomeserverResolverService().ResolveHomeserverFromWellKnown(Homeserver); - // await AuthenticatedHomeserverGeneric.Create(Homeserver, AccessToken, proxy); - // } } public class LoginRequest { diff --git a/LibMatrix/StateEvent.cs b/LibMatrix/StateEvent.cs index e2ac87e..a1ca9dc 100644 --- a/LibMatrix/StateEvent.cs +++ b/LibMatrix/StateEvent.cs @@ -121,7 +121,7 @@ public class StateEvent { public string InternalContentTypeName => TypedContent?.GetType().Name ?? "null"; public static bool TypeKeyPairMatches(StateEventResponse x, StateEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey; - public static bool Equals(StateEventResponse x, StateEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey && x.RawContent.Equals(y.RawContent); + public static bool Equals(StateEventResponse x, StateEventResponse y) => x.Type == y.Type && x.StateKey == y.StateKey && JsonNode.DeepEquals(x.RawContent, y.RawContent); } public class StateEventResponse : StateEvent { -- cgit 1.5.1