diff --git a/.gitignore b/.gitignore
index ea15c2f..8071499 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ matrix-sync.json
MatrixRoomUtils.Bot/bot_data/
appsettings.Local*.json
nixpkgs/
+result
test.tsv
test-proxy.tsv
diff --git a/LibMatrix b/LibMatrix
-Subproject e5591eef3850a9796cc87386128651a828b7069
+Subproject 1eec6bb14f08124e1e8d6f2e0b072862590f1ff
diff --git a/OsuFederatedBeatmapApi.sln.DotSettings.user b/OsuFederatedBeatmapApi.sln.DotSettings.user
new file mode 100644
index 0000000..d5ce503
--- /dev/null
+++ b/OsuFederatedBeatmapApi.sln.DotSettings.user
@@ -0,0 +1,3 @@
+<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
+ <s:Int64 x:Key="/Default/Dpa/Thresholds/=AllocationClosure/@EntryIndexedValue">52428800</s:Int64>
+ <s:Int64 x:Key="/Default/Dpa/Thresholds/=AllocationLoh/@EntryIndexedValue">52428800</s:Int64></wpf:ResourceDictionary>
\ No newline at end of file
diff --git a/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs b/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
index 6c2bd31..6a1149d 100644
--- a/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
+++ b/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
@@ -1,24 +1,33 @@
using Microsoft.AspNetCore.Mvc;
using OsuFederatedBeatmapApi.Events.State;
+using OsuFederatedBeatmapApi.Services;
namespace OsuFederatedBeatmapApi.Controllers;
[ApiController]
[Route("/")]
-public class BeatmapRepositoryController(ILogger<BeatmapRepositoryController> logger, ) : ControllerBase {
-
+public class BeatmapRepositoryController(ILogger<BeatmapRepositoryController> logger, FederatedBeatmapApiBotAccountDataService ads) : ControllerBase {
[HttpGet("/beatmapset/all/info")]
public async IAsyncEnumerable<BeatmapSetInfo> GetAllInfo() {
+ await ads.LoadAccountDataAsync();
+ foreach (var repo in ads.ListedRepositories) {
+ var states = repo.GetFullStateAsync();
+ await foreach (var state in states) {
+ if (state?.TypedContent is BeatmapSetInfo info) yield return info;
+ }
+ }
}
- [HttpGet("/beatmapset/{id:int}/info")]
- public IEnumerable<WeatherForecast> Get(int id) {
- return Enumerable.Range(1, 5).Select(index => new WeatherForecast {
- Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
- TemperatureC = Random.Shared.Next(-20, 55),
- Summary = Summaries[Random.Shared.Next(Summaries.Length)]
- })
- .ToArray();
- }
+ [HttpGet("/beatmapset/{id:int}/info")]
+ public async Task<BeatmapSetInfo?> Get(int id) {
+ await ads.LoadAccountDataAsync();
+
+ foreach (var repo in ads.ListedRepositories) {
+ var states = await repo.GetStateAsync<BeatmapSetInfo>("gay.rory.beatmap_api.beatmap_set_info", id.ToString());
+ return states as BeatmapSetInfo;
+ }
+
+ return null;
+ }
}
diff --git a/OsuFederatedBeatmapApi/Events/AccountData/BotData.cs b/OsuFederatedBeatmapApi/Events/AccountData/BotData.cs
index 0c9744a..1eccf03 100644
--- a/OsuFederatedBeatmapApi/Events/AccountData/BotData.cs
+++ b/OsuFederatedBeatmapApi/Events/AccountData/BotData.cs
@@ -8,4 +8,7 @@ public class BotData {
[JsonPropertyName("log_room")]
public string? LogRoom { get; set; } = "";
+
+ [JsonPropertyName("listed_repositories")]
+ public List<string> ListedRepositories { get; set; } = new();
}
diff --git a/OsuFederatedBeatmapApi/Events/State/BeatmapSetInfo.cs b/OsuFederatedBeatmapApi/Events/State/BeatmapSetInfo.cs
index 2c9367e..8cfcf0d 100644
--- a/OsuFederatedBeatmapApi/Events/State/BeatmapSetInfo.cs
+++ b/OsuFederatedBeatmapApi/Events/State/BeatmapSetInfo.cs
@@ -1,10 +1,11 @@
using LibMatrix;
using LibMatrix.EventTypes;
+using LibMatrix.Interfaces;
namespace OsuFederatedBeatmapApi.Events.State;
[MatrixEvent(EventName = "gay.rory.beatmap_api.beatmap_set_info")]
-public class BeatmapSetInfo : StateEvent {
+public class BeatmapSetInfo : EventContent {
diff --git a/OsuFederatedBeatmapApi/Program.cs b/OsuFederatedBeatmapApi/Program.cs
index 27175f1..15f9b12 100644
--- a/OsuFederatedBeatmapApi/Program.cs
+++ b/OsuFederatedBeatmapApi/Program.cs
@@ -21,7 +21,8 @@ builder.Services.AddScoped<TieredStorageService>(x =>
builder.Services.AddRoryLibMatrixServices();
builder.Services.AddBot(withCommands: true);
-builder.Services.AddSingleton<FederatedBeatmapApiBotAccountDataService>();
+builder.Services.AddSingleton<FederatedBeatmapApiBotConfiguration>();
+builder.Services.AddScoped<FederatedBeatmapApiBotAccountDataService>();
builder.Services.AddHostedService<FederatedBeatmapApiBot>();
var app = builder.Build();
diff --git a/OsuFederatedBeatmapApi/Services/FederatedBeatmapApiBot.cs b/OsuFederatedBeatmapApi/Services/FederatedBeatmapApiBot.cs
index 2b39d93..04d64ad 100644
--- a/OsuFederatedBeatmapApi/Services/FederatedBeatmapApiBot.cs
+++ b/OsuFederatedBeatmapApi/Services/FederatedBeatmapApiBot.cs
@@ -45,6 +45,9 @@ public class FederatedBeatmapApiBot(AuthenticatedHomeserverGeneric hs,
}, cancellationToken);
#pragma warning restore CS4014
+ foreach (var inviteTask in admins.Select(x=>accountDataService.ControlRoom.InviteUserAsync(x))) await inviteTask;
+ foreach (var inviteTask in admins.Select(x=>accountDataService.LogRoom.InviteUserAsync(x))) await inviteTask;
+
syncHelper.InviteReceivedHandlers.Add(async Task (args) => {
var inviteEvent =
args.Value.InviteState.Events.FirstOrDefault(x =>
@@ -69,7 +72,9 @@ public class FederatedBeatmapApiBot(AuthenticatedHomeserverGeneric hs,
logger.LogInformation(
"Got timeline event in {}: {}", @event.RoomId, @event.ToJson(indent: true, ignoreNull: true));
- if (@event is { Type: "m.room.message", TypedContent: RoomMessageEventContent message }) { }
+ if (@event is { Type: "m.room.message", TypedContent: RoomMessageEventContent message }) {
+
+ }
}
catch (Exception e) {
logger.LogError("{}", e.ToString());
diff --git a/OsuFederatedBeatmapApi/Services/FederatedBeatmapApiBotAccountDataService.cs b/OsuFederatedBeatmapApi/Services/FederatedBeatmapApiBotAccountDataService.cs
index 0f4aa6a..37b0d67 100644
--- a/OsuFederatedBeatmapApi/Services/FederatedBeatmapApiBotAccountDataService.cs
+++ b/OsuFederatedBeatmapApi/Services/FederatedBeatmapApiBotAccountDataService.cs
@@ -12,9 +12,10 @@ public class FederatedBeatmapApiBotAccountDataService(ILogger<FederatedBeatmapAp
public GenericRoom LogRoom;
public GenericRoom ControlRoom;
+ public List<GenericRoom> ListedRepositories;
private BotData botData;
- public async Task LoadAccountData() {
+ public async Task LoadAccountDataAsync() {
try {
botData = await hs.GetAccountDataAsync<BotData>(BotDataKey);
}
@@ -56,5 +57,6 @@ public class FederatedBeatmapApiBotAccountDataService(ILogger<FederatedBeatmapAp
LogRoom = hs.GetRoom(botData.LogRoom ?? botData.ControlRoom);
ControlRoom = hs.GetRoom(botData.ControlRoom);
+ ListedRepositories = botData.ListedRepositories.Select(hs.GetRoom).ToList();
}
}
diff --git a/OsuFederatedBeatmapApi/appsettings.Development.json b/OsuFederatedBeatmapApi/appsettings.Development.json
index 600efc3..0f6f318 100644
--- a/OsuFederatedBeatmapApi/appsettings.Development.json
+++ b/OsuFederatedBeatmapApi/appsettings.Development.json
@@ -14,7 +14,7 @@
// The command prefix
"Prefix": "?"
},
- "MediaMod": {
+ "BeatmapApiBot": {
// List of people who should be invited to the control room
"Admins": [
"@emma:conduit.rory.gay",
diff --git a/run b/run
new file mode 100755
index 0000000..088eefa
--- /dev/null
+++ b/run
@@ -0,0 +1,7 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i "bash -x" -p bash git dotnet-sdk_7 nix-output-monitor
+#git add -f OsuFederatedBeatmapApi/appsettings.Local.json
+nom build .?submodules=1
+#git rm --cached OsuFederatedBeatmapApi/appsettings.Local.json
+cd OsuFederatedBeatmapApi
+DOTNET_ENVIRONMENT=Local ../result/bin/OsuFederatedBeatmapApi
|