L'ordine dei tipi (storie, evidenza, post, reel, taggati) ora vale anche per il singolo account: nella scheda account → Impostazioni si sceglie «Come le impostazioni generali» o un ordine suo, con lo stesso elenco da trascinare (o Su/Giù da tastiera) di Limiti e comportamento, ora un modulo solo (download-order.js). Il motore pesa le visite con l'ordine dell'account, la coda dei file mette ogni file al posto del suo tipo nell'ordine del suo account, stabile dentro il tipo (scadenza, scoperta, elemento, posizione). Perché nessun tipo resti fermo per sempre quando il tetto dei dati finisce prima della coda, un posto su otto di ogni giro della coda va al file che aspetta da più tempo, di qualunque tipo. I reel non si inventano (regola 9): un post è reel se viene dalla scheda Reel o se la risposta ha product_type «clips», valore visto nei campioni ripuliti. Il segno si scrive da solo e non si toglie mai, così una copia vecchia non sposta di nuovo i file in coda. Migrazione 0002_ordine_scaricamento (account.download_order, entry.is_reel): prende il primo numero dopo quelle unite, E1 userà il successivo. Prove su motore (seme fisso), coda, lettori, ricette e API; dimostrazione con un account che ha l'ordine suo; guida e decisioni aggiornate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
106 lines
4.7 KiB
C#
106 lines
4.7 KiB
C#
using Febe.Core.Domain;
|
|
|
|
namespace Febe.Core.Storage;
|
|
|
|
/// <summary>Accounts (spec §4.2, §8.3 <c>account</c>).</summary>
|
|
public interface IAccountStore
|
|
{
|
|
Task<Account?> GetAsync(long accountId, CancellationToken ct = default);
|
|
|
|
/// <summary>The account with this Instagram identifier: the identity of an account.</summary>
|
|
Task<Account?> FindByInstagramIdAsync(string instagramId, CancellationToken ct = default);
|
|
|
|
/// <summary>Case-insensitive lookup by current user name.</summary>
|
|
Task<Account?> FindByUsernameAsync(string username, CancellationToken ct = default);
|
|
|
|
/// <summary>Alberto's own profile («Tu»), when known.</summary>
|
|
Task<Account?> GetMineAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>All accounts, ordered by user name.</summary>
|
|
Task<IReadOnlyList<Account>> ListAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// The stored text of «Cosa scaricare prima» of the accounts that have an order of their own (spec §4.4), by local
|
|
/// key; the accounts that follow the general order are left out. Read by the queue of the files at every batch.
|
|
/// </summary>
|
|
Task<IReadOnlyDictionary<long, string>> ListDownloadOrdersAsync(CancellationToken ct = default);
|
|
|
|
/// <summary>All accounts with their counts; «new» counts are entries discovered at or after <paramref name="newSince"/>.</summary>
|
|
Task<IReadOnlyList<AccountSummary>> ListSummariesAsync(DateTimeOffset newSince, CancellationToken ct = default);
|
|
|
|
Task<AccountStats> GetStatsAsync(long accountId, CancellationToken ct = default);
|
|
|
|
/// <summary>Adds an account and returns it with its key.</summary>
|
|
/// <exception cref="DuplicateRecordException">Another account has the same Instagram identifier, or is already «Tu».</exception>
|
|
Task<Account> AddAsync(Account account, CancellationToken ct = default);
|
|
|
|
/// <summary>Replaces every field of an existing account (settings screen).</summary>
|
|
Task UpdateAsync(Account account, CancellationToken ct = default);
|
|
|
|
Task SetStateAsync(long accountId, AccountState state, DateTimeOffset at, UnreachableReason? reason = null, CancellationToken ct = default);
|
|
|
|
/// <summary>Updates last and next check times. Null values leave the stored value unchanged.</summary>
|
|
Task UpdateChecksAsync(long accountId, AccountCheckTimes times, CancellationToken ct = default);
|
|
|
|
/// <summary>Stores the backfill resume point; <paramref name="completedAt"/> marks the backfill as finished.</summary>
|
|
Task SetBackfillAsync(long accountId, string? cursor, DateTimeOffset? completedAt, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Records a rename seen in the data (spec §4.2): updates the user name, keeps the folder (a default folder is
|
|
/// pinned to the old name) and raises the «Renamed» notice.
|
|
/// </summary>
|
|
Task RenameAsync(long accountId, string newUsername, DateTimeOffset at, CancellationToken ct = default);
|
|
|
|
/// <summary>Adds notices (e.g. unrecognized format) to an account.</summary>
|
|
Task AddNoticesAsync(long accountId, AccountNotices notices, DateTimeOffset at, CancellationToken ct = default);
|
|
|
|
/// <summary>Clears notices once Alberto has seen them.</summary>
|
|
Task ClearNoticesAsync(long accountId, AccountNotices notices, CancellationToken ct = default);
|
|
|
|
/// <summary>
|
|
/// Removes the account record and, by cascade, its entries, files records and highlights. Files on disk are not
|
|
/// touched: removing an account with its files is a library operation, and the default is to keep them and make
|
|
/// the account «Solo archivio» (spec §4.2).
|
|
/// </summary>
|
|
Task DeleteAsync(long accountId, CancellationToken ct = default);
|
|
}
|
|
|
|
/// <summary>Check times of an account; null values are left unchanged.</summary>
|
|
public sealed record AccountCheckTimes
|
|
{
|
|
public DateTimeOffset? LastProfileCheckAt { get; init; }
|
|
|
|
public DateTimeOffset? NextProfileCheckAt { get; init; }
|
|
|
|
public DateTimeOffset? LastStoriesCheckAt { get; init; }
|
|
|
|
public DateTimeOffset? NextStoriesCheckAt { get; init; }
|
|
|
|
/// <summary>Profile facts read with the check (null: unchanged).</summary>
|
|
public int? PostCount { get; init; }
|
|
|
|
public bool? IsPrivate { get; init; }
|
|
|
|
public bool? IsFollowed { get; init; }
|
|
|
|
public string? DisplayName { get; init; }
|
|
}
|
|
|
|
/// <summary>A unique constraint refused a record (duplicate Instagram identifier, second «Tu», ...).</summary>
|
|
public sealed class DuplicateRecordException : Exception
|
|
{
|
|
public DuplicateRecordException()
|
|
{
|
|
}
|
|
|
|
public DuplicateRecordException(string message)
|
|
: base(message)
|
|
{
|
|
}
|
|
|
|
public DuplicateRecordException(string message, Exception innerException)
|
|
: base(message, innerException)
|
|
{
|
|
}
|
|
}
|