Rifiniture (M8): avvisi su striscia, notifiche di Windows e Telegram con controllo dello spazio su disco; «Esporta l'elenco» della libreria; avvisi e ricette sospese in Attività; guida per il wiki in docs/guida
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
50 files changed
+3980
-28
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System.Globalization;
|
||||
using Febe.Browser.Recipes;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Alerts;
|
||||
using Febe.Core.Collection.Downloads;
|
||||
using Febe.Core.Domain;
|
||||
using Febe.Core.Engine;
|
||||
@@ -12,9 +13,11 @@ using Febe.Web;
|
||||
using Febe.Web.Connection;
|
||||
using Febe.Web.Engine;
|
||||
using Febe.Web.Library;
|
||||
using Febe.Web.Native;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Febe.Server;
|
||||
|
||||
@@ -32,6 +35,12 @@ internal sealed record ServerHooks
|
||||
|
||||
/// <summary>How long the web host waits for open requests (events, remote view) when stopping.</summary>
|
||||
public TimeSpan ShutdownTimeout { get; init; } = TimeSpan.FromSeconds(3);
|
||||
|
||||
/// <summary>Fake Telegram (tests never reach the real API).</summary>
|
||||
public HttpMessageHandler? TelegramHandler { get; init; }
|
||||
|
||||
/// <summary>Fake free-space probe for the «Disco quasi pieno» alert.</summary>
|
||||
public IFreeSpaceProbe? FreeSpace { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -89,6 +98,9 @@ internal sealed class FebeServer : IAsyncDisposable
|
||||
|
||||
public PerceptualHashIndex? HashIndex { get; private set; }
|
||||
|
||||
/// <summary>The alerts of spec §13.3 (Telegram; Windows notifications through the shell, on the desktop).</summary>
|
||||
public AlertService? Alerts { get; private set; }
|
||||
|
||||
/// <summary>Completes when browser, pipeline and engine are running (never, with a configuration problem).</summary>
|
||||
public Task Running => _running.Task;
|
||||
|
||||
@@ -241,6 +253,8 @@ internal sealed class FebeServer : IAsyncDisposable
|
||||
Engine = engine;
|
||||
connection.AttachEngine(engine);
|
||||
browser.Host.UserDriving.Changed += (_, _) => engine.NotifyUserDrivingChanged();
|
||||
var telegram = new TelegramClient(hooks.TelegramHandler);
|
||||
var telegramChannel = new TelegramAlertChannel(telegram);
|
||||
|
||||
await StartWebAsync(hooks, s =>
|
||||
{
|
||||
@@ -258,13 +272,31 @@ internal sealed class FebeServer : IAsyncDisposable
|
||||
s.AddSingleton<IConfigurationProblems>(new StartupProblems([]));
|
||||
s.AddSingleton(Import);
|
||||
s.AddSingleton(new DailyBackup(Database, Clock, data.Backups));
|
||||
s.AddSingleton<IAlertTestSender>(telegramChannel);
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
// Alerts (spec §13.3): from the engine's timeline and the free space of the two folders, to the shell's
|
||||
// notifications (none in Docker) and Telegram. The strip of the interface is the engine snapshot's.
|
||||
Alerts = new AlertService(
|
||||
Database.Settings,
|
||||
Clock,
|
||||
services.Events,
|
||||
[new NativeShellAlertChannel(Web.Services.GetRequiredService<INativeShell>()), telegramChannel],
|
||||
new AlertServiceOptions
|
||||
{
|
||||
Folders = [WatchedFolder.Library(layout.Root), WatchedFolder.Data(data.Root)],
|
||||
FreeSpace = hooks.FreeSpace ?? new DriveFreeSpaceProbe(),
|
||||
Log = (level, message) => _log.Write(level == AlertLogLevel.Warning ? LogLevel.Warning : LogLevel.Information, "avvisi", message),
|
||||
}).Attach();
|
||||
_disposables.Add(Alerts);
|
||||
_disposables.Add(telegram);
|
||||
|
||||
// Housekeeping in the background: temporary files of an interrupted run, the daily copy of the database.
|
||||
var lifetime = _lifetime.Token;
|
||||
_background.Add(Task.Run(() => CleanTemporaryFilesAsync(staging, layout, lifetime), CancellationToken.None));
|
||||
_background.Add(Task.Run(() => BackupLoopAsync(new DailyBackup(Database, Clock, data.Backups), lifetime), CancellationToken.None));
|
||||
_background.Add(Task.Run(() => BringUpBrowserAsync(ingest, staging, services, engine, runner, lifetime), CancellationToken.None));
|
||||
_background.Add(Task.Run(() => Alerts.WatchDiskSpaceAsync(lifetime), CancellationToken.None));
|
||||
}
|
||||
|
||||
private async Task StartWebAsync(ServerHooks hooks, Action<IServiceCollection> register)
|
||||
|
||||
Reference in new issue
Block a user