Sessione salvata: copia alla chiusura della finestra e alla fine della guida, «Serve «Ho finito»», scelta per la copia incompleta e stato in Collegamento (#36, S4b)
Risposte 1, 5, 6, 9 e 10 di Alberto a S4. I valori __spin_r, __spin_b e __spin_t si copiano dalla pagina come gli altri (su Instagram da SiteData, ipotesi H23, operazioni ancora non configurate; nel sito di prova dal modulo GiroProva). La sessione si copia anche quando si chiude la finestra del browser su Windows e quando il permesso di guida finisce, sempre prima che la pagina torni al motore e con le garanzie di «Ho finito». Con «richieste» «Collegato» vuole una sessione salvata leggibile, altrimenti lo stato è «Serve «Ho finito»» e il motore aspetta. Nuova impostazione sessione.copia-incompleta (sostituisci, predefinita, o tieni-completa) e riquadro della sessione salvata nella pagina Collegamento, con soli conteggi e nomi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9958745e53
commit
883ea4683c
41 files changed
+1349
-101
No files matched your search
@@ -1,4 +1,6 @@
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Collection.Requests;
|
||||
using Febe.Core.Storage;
|
||||
using Febe.Web.Connection;
|
||||
using Febe.Web.Engine;
|
||||
using Febe.Web.Native;
|
||||
@@ -57,19 +59,54 @@ public static class ConnectionApi
|
||||
await connection.DisconnectAsync(ct).ConfigureAwait(false);
|
||||
return Results.NoContent();
|
||||
});
|
||||
|
||||
// What an incomplete copy of the session does (issue #36, S4b, answer 9): read at every copy, no restart.
|
||||
endpoints.MapGet("/api/connection/settings", async (IFebeStorage storage, CancellationToken ct) =>
|
||||
ApiHttp.Json(await SettingsAsync(storage, ct).ConfigureAwait(false), FebeJsonContext.Default.ConnectionSettingsDto));
|
||||
|
||||
endpoints.MapPut("/api/connection/settings", async (HttpContext context, IFebeStorage storage, CancellationToken ct) =>
|
||||
{
|
||||
var body = await ApiHttp.BodyAsync(context, FebeJsonContext.Default.ConnectionSettingsDto).ConfigureAwait(false);
|
||||
var choice = SessionCopySettings.Parse(body.IncompleteCopy)
|
||||
?? throw new BadRequestException($"Scelta sconosciuta per la copia incompleta: ammesse «{SessionCopySettings.ReplaceText}» e «{SessionCopySettings.KeepCompleteText}».");
|
||||
await new SessionCopySettings(choice).SaveAsync(storage.Settings, ct).ConfigureAwait(false);
|
||||
return ApiHttp.Json(await SettingsAsync(storage, ct).ConfigureAwait(false), FebeJsonContext.Default.ConnectionSettingsDto);
|
||||
});
|
||||
}
|
||||
|
||||
private static async Task<ConnectionSettingsDto> SettingsAsync(IFebeStorage storage, CancellationToken ct)
|
||||
{
|
||||
var settings = await SessionCopySettings.LoadAsync(storage.Settings, ct).ConfigureAwait(false);
|
||||
return new ConnectionSettingsDto(SessionCopySettings.ToText(settings.IncompleteCopy));
|
||||
}
|
||||
|
||||
public static ConnectionStatusDto ToDto(ConnectionStatus status)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(status);
|
||||
return new ConnectionStatusDto(State(status.State), status.Username, status.DisplayName, status.UserIsDriving, status.CurrentUrl);
|
||||
return new ConnectionStatusDto(State(status.State), status.Username, status.DisplayName, status.UserIsDriving, status.CurrentUrl, ToDto(status.SavedSession));
|
||||
}
|
||||
|
||||
/// <summary>The saved session in counts and names; null without one.</summary>
|
||||
public static SavedSessionDto? ToDto(SavedSessionStatus? saved) => saved is null
|
||||
? null
|
||||
: new SavedSessionDto(
|
||||
saved.State,
|
||||
saved.CopiedAt?.ToUnixTimeMilliseconds(),
|
||||
saved.Cookies,
|
||||
saved.ValuesPresent,
|
||||
saved.ValuesExpected,
|
||||
saved.MissingValues,
|
||||
saved.DocIdsPresent,
|
||||
saved.DocIdsExpected,
|
||||
saved.MissingDocIds,
|
||||
saved.NeededMissing);
|
||||
|
||||
public static string State(ConnectionState state) => state switch
|
||||
{
|
||||
ConnectionState.NotConnected => "notConnected",
|
||||
ConnectionState.Connected => "connected",
|
||||
ConnectionState.VerificationRequired => "verificationRequired",
|
||||
ConnectionState.SessionCopyMissing => "copyMissing",
|
||||
_ => "browserUnavailable",
|
||||
};
|
||||
}
|
||||
@@ -98,10 +98,16 @@ public static class EngineApi
|
||||
var mine = await storage.Accounts.GetMineAsync(ct).ConfigureAwait(false);
|
||||
var state = snapshot.Mode switch
|
||||
{
|
||||
EngineMode.NotConnected => "notConnected",
|
||||
// The cookie is there but the copy for the requests is missing (S4b): «Serve «Ho finito»», with the account.
|
||||
EngineMode.NotConnected => (await connection.GetStatusAsync(ct).ConfigureAwait(false)).State == ConnectionState.SessionCopyMissing ? "copyMissing" : "notConnected",
|
||||
EngineMode.StoppedForVerification => "verification",
|
||||
EngineMode.Disconnected => "disconnected",
|
||||
EngineMode.Off => (await connection.GetStatusAsync(ct).ConfigureAwait(false)).State == ConnectionState.Connected ? "connected" : "notConnected",
|
||||
EngineMode.Off => (await connection.GetStatusAsync(ct).ConfigureAwait(false)).State switch
|
||||
{
|
||||
ConnectionState.Connected => "connected",
|
||||
ConnectionState.SessionCopyMissing => "copyMissing",
|
||||
_ => "notConnected",
|
||||
},
|
||||
_ => "connected",
|
||||
};
|
||||
var link = state == "notConnected"
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Febe.Web.Api;
|
||||
[JsonSerializable(typeof(LoginDto))]
|
||||
[JsonSerializable(typeof(Library.LibraryChange))]
|
||||
[JsonSerializable(typeof(ConnectionStatusDto))]
|
||||
[JsonSerializable(typeof(ConnectionSettingsDto))]
|
||||
[JsonSerializable(typeof(BeginDrivingRequest))]
|
||||
[JsonSerializable(typeof(CancelDrivingRequest))]
|
||||
[JsonSerializable(typeof(FinishDto))]
|
||||
|
||||
@@ -5,8 +5,33 @@ namespace Febe.Web.Api;
|
||||
|
||||
// ---------------------------------------------------------------- connection (PROTOCOLLO.md)
|
||||
|
||||
/// <summary><c>GET /api/connection</c>. <see cref="State"/>: notConnected, connected, verificationRequired, browserUnavailable.</summary>
|
||||
public sealed record ConnectionStatusDto(string State, string? Username, string? DisplayName, bool UserIsDriving, string? CurrentUrl);
|
||||
/// <summary>
|
||||
/// <c>GET /api/connection</c>. <see cref="State"/>: notConnected, connected, copyMissing, verificationRequired,
|
||||
/// browserUnavailable. <see cref="SavedSession"/> only with the raccolta «richieste».
|
||||
/// </summary>
|
||||
public sealed record ConnectionStatusDto(string State, string? Username, string? DisplayName, bool UserIsDriving, string? CurrentUrl, SavedSessionDto? SavedSession = null);
|
||||
|
||||
/// <summary>
|
||||
/// The saved session in counts and names (issue #36, S4b): <see cref="State"/> present, none or unreadable;
|
||||
/// <see cref="CopiedAt"/> Unix milliseconds. Never a value.
|
||||
/// </summary>
|
||||
public sealed record SavedSessionDto(
|
||||
string State,
|
||||
long? CopiedAt,
|
||||
int Cookies,
|
||||
int ValuesPresent,
|
||||
int ValuesExpected,
|
||||
IReadOnlyList<string> MissingValues,
|
||||
int DocIdsPresent,
|
||||
int DocIdsExpected,
|
||||
IReadOnlyList<string> MissingDocIds,
|
||||
int NeededMissing);
|
||||
|
||||
/// <summary>
|
||||
/// <c>GET/PUT /api/connection/settings</c>: what an incomplete copy of the session does, <c>sostituisci</c> (the
|
||||
/// default) or <c>tieni-completa</c>.
|
||||
/// </summary>
|
||||
public sealed record ConnectionSettingsDto(string IncompleteCopy);
|
||||
|
||||
/// <summary><c>POST /api/connection/begin</c>.</summary>
|
||||
public sealed record BeginDrivingRequest(bool OpenLogin);
|
||||
|
||||
Reference in new issue
Block a user