Every notice is written to the queue in the same transaction as what it tells, then sent every ten seconds. Each has a state: pending, sent, or failed with its error. Network failures and 429s are retried with growing pauses (Telegram's own wait when it gives one). Refusals are final. A notice that could not leave within a day is given up instead of arriving late. Every fill now also reaches the phone, and so do pause, resume and restart. Commands are read by long polling and obeyed only from the configured chat and only when fresh, so yesterday's /pausa never pauses today. They are /stato, /posizioni, /oggi, /pausa, /riprendi, /ferma (confirmed with /conferma within two minutes) and /aiuto. Restarting after "Ferma tutto", real money, limits and keys stay in the interface. Also added: - the heartbeat call every minute when an address is configured; - the morning summary at 08:00, caught up within four hours; - an optional hourly or evening status; - a Telegram section in Impostazioni: test-before-save, a test button, the queue's state and the last successful heartbeat; - on desktop, the first-run page recommends the heartbeat. Tests run against a fake Telegram server, including the commands through the real server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
4.6 KiB
Plaintext
84 lines
4.6 KiB
Plaintext
@page "/primo-avvio"
|
|
@layout ServiceLayout
|
|
@attribute [AllowAnonymous]
|
|
@inject AnubisHost Host
|
|
|
|
<PageTitle>Primo avvio · Anubis</PageTitle>
|
|
|
|
<h1>Primo avvio</h1>
|
|
@if (!_local)
|
|
{
|
|
<p class="notice notice-attention" role="alert"><Icon Name="lock" Size="16" />La prima configurazione si fa solo dal computer su cui gira Anubis.</p>
|
|
}
|
|
else
|
|
{
|
|
<p>Due passi: dove tenere i dati e la password per entrare. Conti, capitale, Telegram e segnale di vita si aggiungono dopo, dalle Impostazioni: Telegram ha un pulsante che manda un messaggio di prova.</p>
|
|
@if (Host.Config.Platform == Anubis.Platform.PlatformKind.Desktop)
|
|
{
|
|
<p class="hint">Su un computer di casa ti consiglio il segnale di vita (Impostazioni, sezione Telegram): un servizio esterno che ti avvisa quando il bot smette di chiamarlo. È l'unico modo per sapere che il bot è spento quando il computer è spento.</p>
|
|
}
|
|
@if (Message is { } message)
|
|
{
|
|
<p class="notice notice-loss" role="alert"><Icon Name="alert" Size="16" />@message</p>
|
|
}
|
|
|
|
<form method="post" action="/azioni/primo-avvio" class="form" data-wizard>
|
|
<AntiforgeryToken />
|
|
@if (!Host.Config.IsComplete)
|
|
{
|
|
<fieldset class="service-section">
|
|
<legend><span class="step">1</span>Database</legend>
|
|
<label class="choice">
|
|
<input type="radio" name="motore" value="sqlite" checked data-engine />
|
|
<span><strong>SQLite</strong> (consigliato): un file nella cartella dei dati, niente da installare.</span>
|
|
</label>
|
|
<label class="choice">
|
|
<input type="radio" name="motore" value="postgres" data-engine />
|
|
<span><strong>PostgreSQL</strong>: un server che hai già, con un database dedicato e vuoto.</span>
|
|
</label>
|
|
<div class="postgres-fields" data-postgres>
|
|
<label for="host">Indirizzo del server</label>
|
|
<input id="host" name="host" autocomplete="off" placeholder="192.168.1.10" />
|
|
<div class="row">
|
|
<div><label for="porta">Porta</label><input id="porta" name="porta" inputmode="numeric" value="5432" /></div>
|
|
<div><label for="nome">Nome del database</label><input id="nome" name="nome" value="anubis" /></div>
|
|
</div>
|
|
<div class="row">
|
|
<div><label for="utente">Utente</label><input id="utente" name="utente" value="anubis" autocomplete="off" /></div>
|
|
<div><label for="dbpassword">Password del database</label><input id="dbpassword" name="dbpassword" type="password" autocomplete="off" /></div>
|
|
</div>
|
|
<p class="hint">La password del database non va in <code>config.toml</code>: la custodisce Windows per il tuo utente.</p>
|
|
<button class="btn" type="submit" formaction="/azioni/primo-avvio/prova" data-test-connection>Prova la connessione</button>
|
|
<p class="test-result" data-test-result role="status"></p>
|
|
</div>
|
|
</fieldset>
|
|
}
|
|
<fieldset class="service-section">
|
|
<legend><span class="step">@(Host.Config.IsComplete ? "1" : "2")</span>Password</legend>
|
|
<p class="hint">Serve per entrare nell'interfaccia, anche da questo computer. Almeno @Passwords.MinimumLength caratteri.</p>
|
|
<label for="password">Password</label>
|
|
<input id="password" name="password" type="password" autocomplete="new-password" minlength="@Passwords.MinimumLength" required />
|
|
<label for="conferma">Scrivila di nuovo</label>
|
|
<input id="conferma" name="conferma" type="password" autocomplete="new-password" minlength="@Passwords.MinimumLength" required />
|
|
</fieldset>
|
|
<p class="hint">Anubis lavora solo quando il computer è acceso. Dopo un'assenza ricostruisce cosa è successo prima di riprendere.</p>
|
|
<button class="btn btn-primary" type="submit">Crea l'installazione</button>
|
|
</form>
|
|
}
|
|
|
|
@code {
|
|
private bool _local;
|
|
|
|
[CascadingParameter]
|
|
public HttpContext? HttpContext { get; set; }
|
|
|
|
[SupplyParameterFromQuery(Name = "errore")]
|
|
public string? Errore { get; set; }
|
|
|
|
protected override void OnInitialized() => _local = HttpContext is not null && CurrentUser.IsLocal(HttpContext);
|
|
|
|
private string? Message => Errore == "database"
|
|
? "Non riesco a collegarmi al database con questi dati. Controlla indirizzo, porta, nome, utente e password, poi riprova."
|
|
: PasswordMessages.For(Errore);
|
|
}
|