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
@@ -7,6 +7,7 @@ using Febe.Core.Domain;
|
||||
using Febe.Core.Library;
|
||||
using Febe.Core.Storage;
|
||||
using Febe.SitoDiProva;
|
||||
using Febe.Tests.Alerts.Support;
|
||||
using Febe.Tests.Server.Support;
|
||||
using Febe.Web.Connection;
|
||||
|
||||
@@ -38,7 +39,9 @@ public sealed partial class ServerEndToEndTests
|
||||
public async Task TheRealServerCollectsFromTheTestSiteStopsAtTheVerificationAndShowsTheBrowser()
|
||||
{
|
||||
var ct = TestContext.CancellationToken;
|
||||
await using var bed = await ServerTestBed.StartAsync();
|
||||
var telegram = new FakeTelegramHandler();
|
||||
var disk = new FakeFreeSpaceProbe();
|
||||
await using var bed = await ServerTestBed.StartAsync(telegram: telegram, freeSpace: disk);
|
||||
var server = bed.Server;
|
||||
Assert.IsEmpty(server.Problems);
|
||||
await server.Running.WaitAsync(TimeSpan.FromSeconds(60), ct);
|
||||
@@ -130,6 +133,11 @@ public sealed partial class ServerEndToEndTests
|
||||
// The site asks for a verification: at its next action toward the site the engine stops and the banner appears
|
||||
// in /api/engine. Usually still in the first session (two accounts to read in full); if that session already
|
||||
// ended, in the next one, after the minimum pause (20 minutes at 10×: two real minutes).
|
||||
// Alerts on Telegram (M8): token and chat set from Impostazioni ▸ Notifiche; the composition sends through the fake.
|
||||
const string token = "4839574812:AAF-gettoneDelServerDiProva_123";
|
||||
var events = """{"verification":true,"disconnection":true,"throttle":true,"backfillDone":true,"diskLow":true,"unknownFormat":true}""";
|
||||
await bed.JsonAsync(HttpMethod.Put, "/api/settings/notifications", $$"""{"events":{{events}},"windows":false,"telegramChatId":"42","telegramToken":"{{token}}","removeTelegramToken":false}""");
|
||||
|
||||
var servedBefore = bed.Site.Control.CdnFilesServed;
|
||||
bed.Site.Control.Set(StopMode.Challenge);
|
||||
await ServerTestBed.WaitUntilAsync(
|
||||
@@ -144,6 +152,24 @@ public sealed partial class ServerEndToEndTests
|
||||
Assert.AreEqual(ConnectionState.VerificationRequired, (await connection.GetStatusAsync(ct)).State);
|
||||
TestContext.WriteLine($"CDN: {servedBefore} file prima del fermo, {bed.Site.Control.CdnFilesServed} adesso.");
|
||||
|
||||
// The same stop reached Telegram, with the Italian text, and the «Avvisi» list of Attività.
|
||||
await ServerTestBed.WaitUntilAsync(
|
||||
() => Task.FromResult(telegram.Requests.Any(r => r.Text.StartsWith("Febe · Instagram chiede una verifica\n", StringComparison.Ordinal))),
|
||||
TimeSpan.FromSeconds(20),
|
||||
"il messaggio Telegram della verifica");
|
||||
var message = telegram.Requests.First(r => r.Text.StartsWith("Febe · Instagram chiede una verifica", StringComparison.Ordinal));
|
||||
Assert.AreEqual($"/bot{token}/sendMessage", message.Uri.AbsolutePath);
|
||||
Assert.AreEqual("42", message.ChatId);
|
||||
StringAssert.Contains(message.Text, "premi «Riprendi»");
|
||||
var alerts = await bed.JsonAsync(HttpMethod.Get, "/api/alerts");
|
||||
Assert.IsTrue(alerts.GetProperty("items").EnumerateArray().Any(i => i.GetProperty("kind").GetString() == "verification"));
|
||||
foreach (var file in Directory.EnumerateFiles(server.Data!.Logs))
|
||||
{
|
||||
var log = await ReadSharedAsync(file, ct);
|
||||
Assert.DoesNotContain(token, log, file);
|
||||
Assert.DoesNotContain("api.telegram.org", log, file);
|
||||
}
|
||||
|
||||
// The remote view: meta first, then JPEG frames; Alberto is driving while it is open.
|
||||
using (var socket = await bed.OpenRemoteViewAsync(ct))
|
||||
{
|
||||
@@ -262,4 +288,11 @@ public sealed partial class ServerEndToEndTests
|
||||
|
||||
[GeneratedRegex(@"^(post|storie|evidenza/[^/]+|taggati)/(\d{4}/)?\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}_[^_/]+_\d+\.(jpg|mp4)$")]
|
||||
private static partial Regex NamePattern();
|
||||
|
||||
private static async Task<string> ReadSharedAsync(string path, CancellationToken ct)
|
||||
{
|
||||
await using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
using var reader = new StreamReader(stream);
|
||||
return await reader.ReadToEndAsync(ct);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user