about summary refs log tree commit diff
path: root/LibMatrix.EventTypes
diff options
context:
space:
mode:
Diffstat (limited to 'LibMatrix.EventTypes')
-rw-r--r--LibMatrix.EventTypes/Interop/Draupnir/DraupnirWatchedListsData.cs28
-rw-r--r--LibMatrix.EventTypes/Interop/Draupnir/DraupnirZtdManagementRoomData.cs19
2 files changed, 47 insertions, 0 deletions
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<string> References { get; set; } + + public List<(string RoomId, List<string>? Vias)> GetReferenceRooms() { + List<(string RoomId, List<string>? 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