La tappa E1 della 0.3.0 prepara il database per le copie esterne senza cambiare comportamento: nulla in interfaccia, motore o API usa ancora ciò che segue. - Migrazione 0003: export_destination, export_account, export_copy, export_run, export_item, video_analysis e media_conversion (risposta di Alberto del 26 novembre: i convertiti per la libreria in una tabella a parte, media non cambia), con i vincoli e gli indici di §8.3. - Archivi IExportStore, IVideoAnalysisStore e IMediaConversionStore in IFebeStorage; ExportSettings sulle cinque chiavi esportazione.*. - AccountStore.DeleteAsync spegne «Automatica» delle cartelle dell'account e vi scrive il suo nome prima di cancellarlo (finché non ci sono destinazioni non fa nulla). - Prove: aggiornamento dei database delle versioni 1 e 2 con foreign_key_check pulito, database più nuovo rifiutato e lasciato intatto, vincoli, archivi, piani delle ricerche, impostazioni e documenti. - SPECIFICA §4.10, §8.3 e §15, decisioni.md e stato.md aggiornati. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
107 lines
4.8 KiB
C#
107 lines
4.8 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). Its export destinations stay, without account and with the user name;
|
|
/// its «Esporta questo account» choice goes with it (spec §4.10).
|
|
/// </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)
|
|
{
|
|
}
|
|
}
|