From 2d8a5f33bb58c85825e057fcc0e56de9a9fe1c0b Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 17 Jul 2025 20:49:18 +0200 Subject: Throw an exception on MessageBuilder.HtmlFormatMessageLink when ommitting vias with v12+ rooms --- LibMatrix/Helpers/MessageFormatter.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'LibMatrix') diff --git a/LibMatrix/Helpers/MessageFormatter.cs b/LibMatrix/Helpers/MessageFormatter.cs index 1b9b4f3..780ac0e 100644 --- a/LibMatrix/Helpers/MessageFormatter.cs +++ b/LibMatrix/Helpers/MessageFormatter.cs @@ -30,8 +30,11 @@ public static class MessageFormatter { public static string HtmlFormatMention(string id, string? displayName = null) => $"{displayName ?? id}"; - public static string HtmlFormatMessageLink(string roomId, string eventId, string[]? servers = null, string? displayName = null) { - if (servers is not { Length: > 0 }) servers = new[] { roomId.Split(':', 2)[1] }; + public static string HtmlFormatMessageLink(string roomId, string eventId, string[] servers, string? displayName = null) { + if (servers is not { Length: > 0 }) + servers = roomId.Contains(':') + ? [roomId.Split(':', 2)[1]] + : throw new ArgumentException("Message links must contain a list of via's for v12+ rooms!", nameof(servers)); return $"{displayName ?? eventId}"; } -- cgit 1.5.1