From 2f6e1fc0a63540942c013ce3f054e96fb38b23f2 Mon Sep 17 00:00:00 2001 From: Rory& Date: Sun, 5 Jul 2026 22:24:15 +0200 Subject: Event types for more Draupnir types --- .../Interop/Draupnir/DraupnirWatchedListsData.cs | 28 ++++++++++++++++++++++ .../Draupnir/DraupnirZtdManagementRoomData.cs | 19 +++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 LibMatrix.EventTypes/Interop/Draupnir/DraupnirWatchedListsData.cs create mode 100644 LibMatrix.EventTypes/Interop/Draupnir/DraupnirZtdManagementRoomData.cs (limited to 'LibMatrix.EventTypes/Interop') diff --git a/LibMatrix.EventTypes/Interop/Draupnir/DraupnirWatchedListsData.cs b/LibMatrix.EventTypes/Interop/Draupnir/DraupnirWatchedListsData.cs new file mode 100644 index 0000000..bf5f148 --- /dev/null +++ b/LibMatrix.EventTypes/Interop/Draupnir/DraupnirWatchedListsData.cs @@ -0,0 +1,28 @@ +using System.Text.Json.Serialization; +using System.Web; + +namespace LibMatrix.EventTypes.Interop.Draupnir; + +[MatrixEvent(EventName = EventId)] +public class DraupnirWatchedListsData : EventContent { + public const string EventId = "org.matrix.mjolnir.watched_lists"; + + [JsonPropertyName("references")] + public List References { get; set; } + + public List<(string RoomId, List? Vias)> GetReferenceRooms() { + List<(string RoomId, List? Vias)> results = []; + foreach (var reference in References) { + var id = HttpUtility.UrlDecode(reference.Split("/#/")[1].Split("?via")[0]); + var vias = + reference.Contains('?') + ? reference.Split('?')[1].Split('&').Select(x => HttpUtility.UrlDecode(x.Replace("via=", ""))) + : id.Contains(':') + ? [id.Split(':')[1]] + : null; + results.Add((id, vias?.ToList())); + } + + return results; + } +} \ No newline at end of file diff --git a/LibMatrix.EventTypes/Interop/Draupnir/DraupnirZtdManagementRoomData.cs b/LibMatrix.EventTypes/Interop/Draupnir/DraupnirZtdManagementRoomData.cs new file mode 100644 index 0000000..33f44a5 --- /dev/null +++ b/LibMatrix.EventTypes/Interop/Draupnir/DraupnirZtdManagementRoomData.cs @@ -0,0 +1,19 @@ +using System.Diagnostics.CodeAnalysis; +using System.Text.Encodings.Web; +using System.Text.Json.Serialization; +using System.Web; + +namespace LibMatrix.EventTypes.Interop.Draupnir; + +[MatrixEvent(EventName = EventId)] +public class DraupnirZtdManagementRoomData : EventContent { + public const string EventId = "space.draupnir.zero_touch_deploy_room"; + + [JsonPropertyName("room")] + public string? Room { get; set; } + + public string? GetPlainRoomId() { + var val = Room?.Split("/#/")[1].Split("?via")[0]; + return HttpUtility.UrlDecode(val); + } +} \ No newline at end of file -- cgit 1.5.1