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>
66 lines
3.0 KiB
C#
66 lines
3.0 KiB
C#
using Febe.Core.Storage;
|
|
|
|
namespace Febe.Core.Collection.Requests;
|
|
|
|
/// <summary>What a copy of the browser's session does when some value the requests need is missing (issue #36, S4b).</summary>
|
|
public enum IncompleteCopyChoice
|
|
{
|
|
/// <summary>
|
|
/// «Sostituisci comunque» (the default): the new copy replaces the saved one all the same, because keeping an older
|
|
/// copy could keep the cookies of another login (§6.0).
|
|
/// </summary>
|
|
Replace,
|
|
|
|
/// <summary>
|
|
/// «Tieni la copia completa»: when the saved copy has every value the configured operations need and the new one
|
|
/// does not, the saved one stays and the message says so.
|
|
/// </summary>
|
|
KeepComplete,
|
|
}
|
|
|
|
/// <summary>
|
|
/// The settings of the copy of the session (issue #36, S4b; decision of Alberto of 18 November 2026, answer 9), in the
|
|
/// <c>setting</c> table like the other settings. Read at every copy: a change holds from the next copy, no restart.
|
|
/// </summary>
|
|
/// <param name="IncompleteCopy">What an incomplete copy does.</param>
|
|
public sealed record SessionCopySettings(IncompleteCopyChoice IncompleteCopy)
|
|
{
|
|
/// <summary>The key of <see cref="IncompleteCopy"/>: <c>sostituisci</c> or <c>tieni-completa</c>.</summary>
|
|
public const string IncompleteCopyKey = "sessione.copia-incompleta";
|
|
|
|
/// <summary>The text of <see cref="IncompleteCopyChoice.Replace"/> in the table and in the API.</summary>
|
|
public const string ReplaceText = "sostituisci";
|
|
|
|
/// <summary>The text of <see cref="IncompleteCopyChoice.KeepComplete"/> in the table and in the API.</summary>
|
|
public const string KeepCompleteText = "tieni-completa";
|
|
|
|
/// <summary>The settings of a database that never stored them: an incomplete copy replaces the saved one.</summary>
|
|
public static SessionCopySettings Default { get; } = new(IncompleteCopyChoice.Replace);
|
|
|
|
/// <summary>The text of <paramref name="choice"/>.</summary>
|
|
public static string ToText(IncompleteCopyChoice choice) => choice == IncompleteCopyChoice.KeepComplete ? KeepCompleteText : ReplaceText;
|
|
|
|
/// <summary>The choice of <paramref name="text"/>; null for any other text.</summary>
|
|
public static IncompleteCopyChoice? Parse(string? text) => text switch
|
|
{
|
|
ReplaceText => IncompleteCopyChoice.Replace,
|
|
KeepCompleteText => IncompleteCopyChoice.KeepComplete,
|
|
_ => null,
|
|
};
|
|
|
|
/// <summary>The stored settings; an unknown or missing value is the default.</summary>
|
|
public static async Task<SessionCopySettings> LoadAsync(ISettingsStore settings, CancellationToken ct)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(settings);
|
|
var text = await settings.GetAsync(IncompleteCopyKey, ct).ConfigureAwait(false);
|
|
return Parse(text) is { } choice ? new SessionCopySettings(choice) : Default;
|
|
}
|
|
|
|
/// <summary>Stores these settings.</summary>
|
|
public Task SaveAsync(ISettingsStore settings, CancellationToken ct)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(settings);
|
|
return settings.SetAsync(IncompleteCopyKey, ToText(IncompleteCopy), ct);
|
|
}
|
|
}
|