about summary refs log tree commit diff
path: root/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs')
-rw-r--r--OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs7
1 files changed, 4 insertions, 3 deletions
diff --git a/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs b/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
index 6a1149d..b1fa4f1 100644
--- a/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
+++ b/OsuFederatedBeatmapApi/Controllers/BeatmapRepositoryController.cs
@@ -6,7 +6,7 @@ namespace OsuFederatedBeatmapApi.Controllers;
 
 [ApiController]
 [Route("/")]
-public class BeatmapRepositoryController(ILogger<BeatmapRepositoryController> logger, FederatedBeatmapApiBotAccountDataService ads) : ControllerBase {
+public class BeatmapRepositoryController(ILogger<BeatmapRepositoryController> logger, FederatedBeatmapApiBotAccountDataService ads, BeatmapFetcherService bfs) : ControllerBase {
     [HttpGet("/beatmapset/all/info")]
     public async IAsyncEnumerable<BeatmapSetInfo> GetAllInfo() {
         await ads.LoadAccountDataAsync();
@@ -24,8 +24,9 @@ public class BeatmapRepositoryController(ILogger<BeatmapRepositoryController> lo
         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;
+            var state = await repo.GetStateOrNullAsync<BeatmapSetInfo>("gay.rory.beatmap_api.beatmap_set_info", id.ToString());
+            if (state is not null) return state;
+            return await bfs.FetchBeatmapSetInfo(id);
         }
 
         return null;