about summary refs log tree commit diff
path: root/BugMine.Sdk/BugMineProject.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2024-04-25 06:31:52 +0200
committerRory& <root@rory.gay>2024-04-25 06:31:52 +0200
commit3054b456dcb54f069a5d8aaa615c1dfe060eef9b (patch)
treece89fbd1478206ac19fefa23035b68801bd25d4e /BugMine.Sdk/BugMineProject.cs
parentAdd basic project management (diff)
downloadBugMine-3054b456dcb54f069a5d8aaa615c1dfe060eef9b.tar.xz
Add projects logic, start of issues
Diffstat (limited to 'BugMine.Sdk/BugMineProject.cs')
-rw-r--r--BugMine.Sdk/BugMineProject.cs16
1 files changed, 12 insertions, 4 deletions
diff --git a/BugMine.Sdk/BugMineProject.cs b/BugMine.Sdk/BugMineProject.cs

index c90ba6e..babb680 100644 --- a/BugMine.Sdk/BugMineProject.cs +++ b/BugMine.Sdk/BugMineProject.cs
@@ -1,4 +1,5 @@ using System.Text.Json.Nodes; +using LibMatrix.EventTypes.Spec.State; using LibMatrix.Homeservers; using LibMatrix.RoomTypes; @@ -13,27 +14,34 @@ public class BugMineProject(GenericRoom room) { public async Task<BugMineProject> InitializeAsync() { Info = (await Room.GetStateAsync<ProjectInfo>(ProjectInfo.EventId))!; var alias = await room.GetCanonicalAliasAsync(); - + if (alias != null) ProjectSlug = alias.Alias?[1..] ?? room.RoomId; else ProjectSlug = room.RoomId; - + return this; } public async Task<BugMineIssue> CreateIssue(BugMineIssueData issue) { // add relation to room creation event issue.RelatesTo = new() { - EventId = (await Room.GetStateEventAsync("m.room.create")).EventId, + EventId = await room.GetStateEventIdAsync(RoomCreateEventContent.EventId), RelationType = "gay.rory.bugmine.issue" }; var eventId = await Room.SendTimelineEventAsync(BugMineIssueData.EventId, issue); - + // return new BugMineIssueAccessor(Room, await Room.GetEventAsync<>(eventId)); var evt = await room.GetEventAsync(eventId.EventId); Console.WriteLine(evt); return new BugMineIssue(Room, evt); } + + public async IAsyncEnumerable<BugMineIssue> GetIssues() { + var creationEventId = await room.GetStateEventIdAsync(RoomCreateEventContent.EventId); + await foreach (var evt in room.GetRelatedEventsAsync(creationEventId, "gay.rory.bugmine.issue", BugMineIssueData.EventId)) { + yield return new BugMineIssue(Room, evt); + } + } } public static class ProjectRoomExtensions {