♻️ Remove the discovery service in the Sphere.

This commit is contained in:
2026-01-06 22:32:02 +08:00
parent 6b592156c9
commit 0cc6f86f3b
9 changed files with 58 additions and 55 deletions

View File

@@ -1,18 +0,0 @@
using Microsoft.AspNetCore.Mvc;
namespace DysonNetwork.Sphere.Discovery;
[ApiController]
[Route("/api/discovery")]
public class DiscoveryController(DiscoveryService discoveryService) : ControllerBase
{
[HttpGet("realms")]
public Task<List<Shared.Models.SnRealm>> GetPublicRealms(
[FromQuery] string? query,
[FromQuery] int take = 10,
[FromQuery] int offset = 0
)
{
return discoveryService.GetCommunityRealmAsync(query, take, offset);
}
}

View File

@@ -1,17 +0,0 @@
using DysonNetwork.Shared.Registry;
namespace DysonNetwork.Sphere.Discovery;
public class DiscoveryService(RemoteRealmService remoteRealmService)
{
public async Task<List<Shared.Models.SnRealm>> GetCommunityRealmAsync(
string? query,
int take = 10,
int offset = 0,
bool random = false
)
{
var allRealms = await remoteRealmService.GetPublicRealms(random ? "random" : "popularity");
return allRealms.Where(r => r.IsCommunity).Skip(offset).Take(take).ToList();
}
}

View File

@@ -46,10 +46,6 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Discovery\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources\SharedResource.resx">
<Generator>ResXFileCodeGenerator</Generator>

View File

@@ -5,7 +5,6 @@ using DysonNetwork.Shared.Cache;
using DysonNetwork.Shared.Geometry;
using DysonNetwork.Sphere.ActivityPub;
using DysonNetwork.Sphere.Autocompletion;
using DysonNetwork.Sphere.Discovery;
using DysonNetwork.Sphere.Localization;
using DysonNetwork.Sphere.Poll;
using DysonNetwork.Sphere.Post;
@@ -94,7 +93,6 @@ public static class ServiceCollectionExtensions
services.AddScoped<PublisherSubscriptionService>();
services.AddScoped<TimelineService>();
services.AddScoped<PostService>();
services.AddScoped<DiscoveryService>();
services.AddScoped<PollService>();
services.AddScoped<StickerService>();
services.AddScoped<AutocompletionService>();

View File

@@ -1,7 +1,6 @@
using DysonNetwork.Shared.Models;
using DysonNetwork.Shared.Proto;
using DysonNetwork.Shared.Registry;
using DysonNetwork.Sphere.Discovery;
using DysonNetwork.Sphere.Post;
using Microsoft.EntityFrameworkCore;
using NodaTime;
@@ -13,7 +12,6 @@ public class TimelineService(
Publisher.PublisherService pub,
Post.PostService ps,
RemoteRealmService rs,
DiscoveryService ds,
AccountService.AccountServiceClient accounts,
RemoteWebArticleService webArticles
)
@@ -194,7 +192,7 @@ public class TimelineService(
private async Task<SnTimelineEvent?> GetRealmDiscoveryActivity(int count = 5)
{
var realms = await ds.GetCommunityRealmAsync(null, count, 0, true);
var realms = await rs.GetPublicRealms("random", count);
return realms.Count > 0
? new TimelineDiscoveryEvent(
realms.Select(x => new DiscoveryItem("realm", x)).ToList()