«Aggiungi account» ha una sola casella: mentre Alberto scrive compaiono subito i suggerimenti locali, poi i profili di Instagram con la foto, come chiesto in #37. Il browser di Febe scrive nella casella «Cerca» di Instagram con tasti veri da una mappa chiusa (mai Invio, Tab o Esc), controlla prima il fuoco, legge la risposta della pagina e non clicca mai un risultato. La ricerca ha una categoria propria nel Governatore, con tetti larghi che non consumano quelli della raccolta, e si dà il turno con il motore sull'unica pagina; a fine sessione la pagina torna comunque al riposo. Le foto passano dal CDN con un permesso ciascuna e restano solo in memoria. Le risposte di Alberto del 15 novembre (controllo del fuoco, turni, evento requestWillBeSent, niente foto dei seguiti per ora) sono in §6.1 e in docs/decisioni.md. Su Instagram vero la ricerca parte quando i bersagli search-open e search-box saranno raccolti dal vivo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
284 lines
11 KiB
C#
284 lines
11 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.</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);
|
|
|
|
/// <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>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);
|
|
|
|
public sealed record LibraryDaysDto(long Now, string Today, int Entries, int Accounts, IReadOnlyList<DayDto> Days);
|
|
|
|
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);
|
|
|
|
/// <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).</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);
|
|
|
|
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);
|
|
|
|
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 Attività page.</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);
|