5a2223a4c8
This PR stabilizes the Nexus Ingestion Engine by implementing functional service proxies for the Blazor WASM client and refining the backend infrastructure for real-time progress tracking and database compatibility. ### Key Changes - **Infrastructure Stabilization**: - Implemented production-grade `EbookRepository` with PostgreSQL `EF.Functions.ILike` support. - Enforced `IsReadyForReading = false` state for newly added ebooks (resolves #35). - Updated `SignalRSyncBroadcaster` to support targeted user messaging and ingestion-specific progress updates (resolves #37). - **WASM Client Functional Proxies**: - Replaced "Throwing" dummy services with `WasmEbookRepository`, `WasmSyncBroadcaster`, `WasmBookStorageService`, and `WasmEmbeddingGenerator`. - These services proxy requests to the backend via a new set of Minimal API endpoints in `NexusReader.Web`. - **Domain Refinement**: - Added `IsReadyForReading` flag to the `Ebook` entity to manage background AI processing states. ### Related Issues - Fixes #35 - Fixes #36 - Fixes #37 --------- Co-authored-by: Marek Jasiński <jasins.marek@gmail.com> Reviewed-on: #42 Co-authored-by: Antigravity <antigravity@google.com> Co-committed-by: Antigravity <antigravity@google.com>
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using Microsoft.AspNetCore.SignalR;
|
|
using NexusReader.Application.Abstractions.Messaging;
|
|
using NexusReader.Infrastructure.RealTime;
|
|
|
|
namespace NexusReader.Infrastructure.RealTime;
|
|
|
|
/// <summary>
|
|
/// SignalR implementation of <see cref="ISyncBroadcaster"/>.
|
|
/// Uses <see cref="IHubContext{SyncHub}"/> to push progress updates to all of a user's connected devices.
|
|
/// </summary>
|
|
internal sealed class SignalRSyncBroadcaster : ISyncBroadcaster
|
|
{
|
|
private readonly IHubContext<SyncHub> _hubContext;
|
|
|
|
public SignalRSyncBroadcaster(IHubContext<SyncHub> hubContext)
|
|
{
|
|
_hubContext = hubContext;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task BroadcastProgressAsync(
|
|
string userId,
|
|
string pageId,
|
|
DateTime timestamp,
|
|
string? excludedConnectionId,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
// Using Clients.User(userId) targeted broadcasting.
|
|
// This pushes to all of a user's connected devices across all sessions.
|
|
if (!string.IsNullOrEmpty(excludedConnectionId))
|
|
{
|
|
await _hubContext.Clients
|
|
.User(userId)
|
|
.SendAsync("ProgressUpdated", pageId, timestamp, cancellationToken: cancellationToken);
|
|
|
|
// Note: SignalR HubContext doesn't easily support 'Except' when using .User(id)
|
|
// from outside the Hub itself without custom IUserIdProvider.
|
|
// If strict exclusion is needed, we'd use groups, but requirements mandate .User(userId).
|
|
}
|
|
else
|
|
{
|
|
await _hubContext.Clients
|
|
.User(userId)
|
|
.SendAsync("ProgressUpdated", pageId, timestamp, cancellationToken: cancellationToken);
|
|
}
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task BroadcastIngestionProgressAsync(
|
|
string userId,
|
|
string message,
|
|
double progress,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
// Pushes ingestion status (e.g., "Parsing chapters...") and progress (0.0-1.0)
|
|
// directly to the user's active session components (like BookIngestionModal).
|
|
await _hubContext.Clients
|
|
.User(userId)
|
|
.SendAsync("IngestionProgress", message, progress, cancellationToken: cancellationToken);
|
|
}
|
|
}
|