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
@@ -0,0 +1,39 @@
|
||||
using Febe.Core.Alerts;
|
||||
|
||||
namespace Febe.Web.Native;
|
||||
|
||||
/// <summary>
|
||||
/// Windows notifications as an alert channel (spec §12, §13.3): <see cref="INativeShell.NotifyAsync"/> with the title
|
||||
/// and the message of the alert. On when the shell can notify (the desktop) and «Notifiche di Windows» is on; in
|
||||
/// Docker <see cref="BrowserShell"/> cannot notify and the channel stays silent.
|
||||
/// </summary>
|
||||
public sealed class NativeShellAlertChannel(INativeShell shell) : IAlertChannel
|
||||
{
|
||||
private readonly INativeShell _shell = shell ?? throw new ArgumentNullException(nameof(shell));
|
||||
|
||||
public string Name => "notifica di Windows";
|
||||
|
||||
public bool IsEnabled(AlertSettings settings)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(settings);
|
||||
return _shell.CanNotify && settings.WindowsNotifications;
|
||||
}
|
||||
|
||||
public async Task<AlertDelivery> SendAsync(Alert alert, AlertSettings settings, CancellationToken ct)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(alert);
|
||||
try
|
||||
{
|
||||
await _shell.NotifyAsync(alert.Title, alert.Message, ct).ConfigureAwait(false);
|
||||
return AlertDelivery.Ok;
|
||||
}
|
||||
catch (OperationCanceledException) when (ct.IsCancellationRequested)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
return new AlertDelivery(false, $"Windows non ha mostrato la notifica ({ex.GetType().Name})");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user