Files
Febe/src/Febe.Web/Api/Dtos.cs
T
Alby96andClaude Opus 5.5 58ff4e48b3 D1, correzioni della revisione: conteggi della Libreria più rapidi, frecce che seguono le tessere, Dashboard nei testi
- /api/library/days in «Tutte le foto» faceva due volte il passaggio su tutta la tabella media
  a ogni aggiornamento del mosaico: il totale dei file è ora la somma dei giorni
  (CountLibraryFilesAsync tolto).
- I totali e i conteggi per giorno di «Foto» e «Video» su tutta la libreria non pagano più un
  EXISTS per post (1,3-1,6 s): elenco degli elementi con file di quel tipo su un indice di
  copertura, 86-141 ms su 200.000 elementi; nuove misure con limite 600 ms in LibraryScaleTests.
- La quota di chi aspetta non è un minimo per tipo: corretti commento e decisioni, prova con un
  arretrato più vecchio di un altro tipo.
- Visualizzatore in «Tutte le foto»: le frecce saltano i file che non sono tessere (foto sotto
  «Video» e simili) e l'intestazione non dà il numero di un altro file; la voce già scelta
  dell'interruttore non ridisegna il mosaico. Prova d'interfaccia nuova (solo CI).
- «Ricetta sospesa» dice di riattivarla dalla Dashboard, non da Attività; commenti aggiornati.
- Nomi accessibili distinti nella scheda account, variabile in inglese in download-order.js,
  icona activity tolta perché nessuna pagina la usa.
- Schermate 06, 11 e 14 rifatte con /dashboard e nuova 01-libreria-tutte-le-foto, confrontate
  con i mockup in docs/schermate/differenze.md (con quattro difetti visivi ancora da sistemare).
- LEGGIMI del web (mode, cursore, files, moduli riusabili) e guida della Libreria (la scelta del
  mosaico resta nel browser, a differenza del tema).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 17:27:33 +01:00

298 lines
12 KiB
C#

using Febe.Core.Engine;
namespace Febe.Web.Api;
// JSON shapes of the API. English names (camelCase on the wire); every text meant for Alberto is Italian.
// Times: milliseconds since the Unix epoch (UTC), plus local strings computed in Alberto's zone where the page shows a
// clock or a day, so the page never needs to know the zone of the server.
/// <summary>An error the page shows as it is.</summary>
public sealed record ProblemDto(string Message);
/// <summary>A short answer of a command.</summary>
public sealed record MessageDto(string Message);
/// <summary>An instant with its local day and clock time. <see cref="DayDelta"/>: 0 today, 1 tomorrow, -1 yesterday.</summary>
public sealed record LocalTimeDto(long Ms, string Day, string Clock, int DayDelta);
/// <summary>What this shell can do (the page adapts its buttons).</summary>
public sealed record CapabilitiesDto(
string Edition,
bool Demo,
string Access,
bool ShowInFolder,
bool PickFolder,
bool OpenUrlNative,
bool FoldersReadOnly,
bool Autostart,
bool BrowserWindow,
bool Notifications,
string Version,
string? Scene,
IReadOnlyList<string> Scenes,
long Now,
string Today,
IReadOnlyList<Febe.Web.Connection.ConfigurationProblem> Problems);
public sealed record PreferencesDto(string Theme);
// ---------------------------------------------------------------- library
/// <summary>The cover of a tile. <see cref="Thumb"/> is the thumbnail key (null: neutral tile).</summary>
public sealed record CoverDto(long MediaId, string Kind, int? Width, int? Height, double? Duration, string? Thumb);
/// <summary>
/// A tile of the mosaic: one entry, or with «Tutte le foto» one file of it (the cover is that file and
/// <see cref="Position"/> its place in the series; null for an entry tile).
/// </summary>
public sealed record TileDto(
long Id,
long AccountId,
string Username,
string Kind,
long PublishedAt,
string Day,
string Time,
string Provenance,
string State,
int Files,
CoverDto? Cover,
int? Position = null);
/// <summary>A window of tiles; cursors continue it (null: nothing more that way).</summary>
public sealed record LibraryPageDto(IReadOnlyList<TileDto> Tiles, string? Older, string? Newer);
/// <summary>What a line of the history of the Dashboard saved (spec §7.9): the first tiles and how many in all.</summary>
public sealed record ArrivedDto(IReadOnlyList<TileDto> Tiles, int Total);
/// <summary>A day of the mosaic: its count and the cursor that starts at its end.</summary>
public sealed record DayDto(string Day, int Count, string Cursor);
/// <summary>Days of the mosaic with the totals; <see cref="Files"/> only with «Tutte le foto» (the files of the entries).</summary>
public sealed record LibraryDaysDto(long Now, string Today, int Entries, int Accounts, IReadOnlyList<DayDto> Days, int? Files = null);
public sealed record AccountBriefDto(long Id, string Username, string? DisplayName, bool IsPrivate, bool IsFollowed, bool IsMine, string State, string? Avatar);
public sealed record MediaDto(
long Id,
int Position,
string Kind,
int? Width,
int? Height,
double? Duration,
long? Bytes,
string? FileName,
string? Folder,
string? Thumb,
bool Available,
string State,
bool Damaged = false);
/// <summary>Everything the viewer shows of an entry.</summary>
public sealed record EntryDto(
long Id,
string Kind,
AccountBriefDto Account,
long PublishedAt,
string PublishedDay,
string PublishedTime,
string? Code,
string? InstagramId,
string? Caption,
string? Author,
string Provenance,
string State,
LocalTimeDto Discovered,
LocalTimeDto? Downloaded,
IReadOnlyList<string> Highlights,
string? InstagramUrl,
IReadOnlyList<MediaDto> Media);
public sealed record EntryIdsRequest(IReadOnlyList<long> Ids, string? Mode);
public sealed record DeleteResultDto(int Deleted, int FilesRemoved, IReadOnlyList<string> Problems, string Message);
/// <summary>Export by keys, or by the current filter when no keys are given.</summary>
public sealed record ExportRequest(IReadOnlyList<long>? Ids, string? Query);
public sealed record MediaActionRequest(long MediaId);
// ---------------------------------------------------------------- accounts
public sealed record ContentTypesDto(bool Photos, bool Videos, bool Stories, bool Highlights, bool Tagged, bool ProfilePicture);
/// <summary>A row of the accounts table (mockup 03).</summary>
public sealed record AccountRowDto(
long Id,
string Username,
string? DisplayName,
bool IsPrivate,
bool IsFollowed,
bool IsMine,
string State,
string? UnreachableReason,
bool NeedsAttention,
IReadOnlyList<string> Notices,
bool KeepUpdated,
bool KeptUpdated,
string Frequency,
ContentTypesDto Types,
int InLibrary,
int Posts,
int? PostCount,
int NewPostsToday,
int NewStoriesToday,
bool BackfillResumesTomorrow,
long? LastCheck,
LocalTimeDto? NextCheck,
LocalTimeDto? StateChanged,
long AddedAt,
string? Avatar,
string? PreviousUsername);
public sealed record AccountCountsDto(int All, int UpToDate, int Backfilling, int Paused, int ArchiveOnly, int NeedsAttention, int KeptUpdated);
public sealed record AccountListDto(long Now, AccountCountsDto Counts, IReadOnlyList<AccountRowDto> Accounts);
public sealed record AccountStatsDto(int Entries, int Posts, int Stories, int HighlightItems, int Tagged, int ProfilePictures, int Collections, long Bytes, int PendingFiles);
/// <summary>
/// The editable settings of an account (mockup 05). <see cref="DownloadOrder"/> is «Cosa scaricare prima» (spec §4.4):
/// the names of the five kinds first to last for «Un ordine suo», null or empty for «Come le impostazioni generali».
/// </summary>
public sealed record AccountSettingsDto(
bool KeepUpdated,
string Frequency,
double? CustomPostHours,
double? CustomStoryHours,
ContentTypesDto Types,
string Depth,
int? LastPosts,
string? FromDate,
int BackfillPerDay,
double? MaxVideoMb,
bool StoryVideos,
string? Folder,
IReadOnlyList<string>? DownloadOrder = null);
public sealed record PlanLineDto(string Key, string Title, string Text);
/// <summary>«Con queste impostazioni» (spec §4.4).</summary>
public sealed record PlanDto(
IReadOnlyList<PlanLineDto> Lines,
IReadOnlyList<string> Warnings,
double Share,
double OpensPerDay,
int DailyBudget,
bool OverBudget,
string FrequencyHint,
string? Note);
public sealed record HighlightDto(long Id, string Title, int Count, bool Removed, IReadOnlyList<long> EntryIds);
public sealed record AccountDetailDto(
AccountRowDto Account,
AccountStatsDto Stats,
AccountSettingsDto Settings,
PlanDto Plan,
string Folder,
bool FolderIsDefault,
string? InstagramUrl,
IReadOnlyList<HighlightDto> Highlights,
int MaxBackfillPerDay,
IReadOnlyList<string>? GeneralDownloadOrder = null);
public sealed record HistoryItemDto(long Id, LocalTimeDto At, string Severity, string Code, string Message);
public sealed record HistoryDto(IReadOnlyList<HistoryItemDto> Items, long? Before);
public sealed record SwitchRequest(bool Value);
public sealed record CheckNowRequest(string? Token);
public sealed record CheckNowDto(string Status, string Message, string? Token);
public sealed record RemoveAccountRequest(bool DeleteFiles);
public sealed record RemoveAccountDto(string Outcome, int DeletedEntries, int Problems, string Message);
public sealed record ParseRequest(string Text);
public sealed record ParsedNameDto(int Line, string Username, bool Present, long? AccountId, bool Followed, string? DisplayName, bool? IsPrivate);
public sealed record ParseProblemDto(int Line, string Text, string Reason);
public sealed record ParseResultDto(IReadOnlyList<ParsedNameDto> Names, IReadOnlyList<ParseProblemDto> Problems);
public sealed record AddAccountsRequest(IReadOnlyList<string> Usernames, string Start, string? Depth, int? LastPosts);
public sealed record AddAccountsDto(int Added, IReadOnlyList<string> Skipped, string Message);
/// <summary>A profile for the local suggestions: one Alberto follows, or an account in Febe he does not follow.</summary>
/// <param name="InstagramId">The site's identifier, when known (to merge with the results of the search).</param>
/// <param name="Avatar">Thumbnail key of the newest profile picture in the library (<c>/api/thumbnails/{key}</c>).</param>
/// <param name="Photo">Key of a photo of the search in memory (<c>/api/ricerca/foto/{key}</c>).</param>
/// <param name="Followed">True when Alberto follows the profile (from the list of followed profiles).</param>
public sealed record FollowingProfileDto(string Username, string? DisplayName, bool? IsPrivate, long? AccountId, string? InstagramId = null, string? Avatar = null, string? Photo = null, bool Followed = true);
/// <param name="BackfillPerDay">Default «Storico, massimo al giorno» of the caution profile, for the note of the dialog.</param>
public sealed record FollowingDto(long? ReadAt, string? ReadDay, bool InProgress, int ReadSoFar, int Total, IReadOnlyList<FollowingProfileDto> Profiles, int BackfillPerDay);
// ---------------------------------------------------------------- profile search (issue #37)
/// <summary>The text of the search box of the dialog. <paramref name="Client"/> is a random id of the window (16 hex).</summary>
public sealed record ProfileSearchRequest(string Client, string? Text)
{
private bool PrintMembers(System.Text.StringBuilder builder)
{
builder.Append($"TextLength = {Text?.Length ?? 0}");
return true;
}
}
/// <summary>The dialog closed.</summary>
public sealed record ProfileSearchEndRequest(string Client);
/// <summary>
/// What the search shows. <paramref name="State"/> is one of
/// <c>idle|solo-locale|attesa|cerca|pronta|vuota|nessuna-risposta|non-possibile|fuori-fascia|ferma|non-pronto|da-configurare|rifiutata|errore</c>;
/// <paramref name="Mine"/> is true when the window that asks wrote the text.
/// </summary>
public sealed record ProfileSearchDto(long Version, bool Mine, string Text, string State, string? Message, long? RetryAfter, IReadOnlyList<ProfileSearchHitDto> Hits)
{
private bool PrintMembers(System.Text.StringBuilder builder)
{
builder.Append($"Version = {Version}, State = {State}, Hits = {Hits.Count}");
return true;
}
}
/// <summary>A profile found on the site, with what Febe knows of it (account, followed, private).</summary>
/// <param name="Photo">Key of its photo in memory, once <paramref name="PhotoReady"/>.</param>
/// <param name="Avatar">Thumbnail key of the account's newest profile picture in the library, when it is in Febe.</param>
public sealed record ProfileSearchHitDto(string InstagramId, string Username, string? DisplayName, bool? IsVerified, string? Photo, bool PhotoReady, long? AccountId, bool Followed, bool? IsPrivate, string? Avatar)
{
private bool PrintMembers(System.Text.StringBuilder builder)
{
builder.Append($"PhotoReady = {PhotoReady}, InFebe = {AccountId is not null}, Followed = {Followed}");
return true;
}
}
// ---------------------------------------------------------------- engine
/// <summary>The connected account at the bottom of the sidebar.</summary>
/// <param name="State">"connected", "notConnected", "verification", "disconnected".</param>
public sealed record ConnectionDto(string State, string? Username, string? DisplayName, string? Avatar);
/// <summary>The engine for the sidebar, the stop strip and the Dashboard.</summary>
public sealed record EngineDto(long Now, EngineSnapshot Snapshot, ConnectionDto Connection, bool CanResume);
public sealed record ResumeDto(bool Resumed, string Message);
// ---------------------------------------------------------------- access
public sealed record LoginRequest(string? Password);
public sealed record LoginDto(bool Ok, string Message, long? LockedUntil);