Ossatura del progetto: soluzione, contratti, specifica, mockup, carattere e icone
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
123 files changed
+3763
-1
No files matched your search
@@ -0,0 +1,143 @@
|
||||
using Febe.Core.Abstractions;
|
||||
|
||||
namespace Febe.Core.Domain;
|
||||
|
||||
/// <summary>An hourly and daily budget for one action category.</summary>
|
||||
public sealed record Budget(int PerHour, int PerDay);
|
||||
|
||||
/// <summary>
|
||||
/// Values of a caution profile (spec §7.5). These are cautious starting estimates, not official limits
|
||||
/// and not measurements: the interface must say so.
|
||||
/// </summary>
|
||||
public sealed record CautionProfile
|
||||
{
|
||||
public required CautionProfileKind Kind { get; init; }
|
||||
|
||||
/// <summary>Start of the daily active window (local time).</summary>
|
||||
public required TimeOnly WindowStart { get; init; }
|
||||
|
||||
/// <summary>End of the daily active window (local time); may be after midnight (e.g. 00:30).</summary>
|
||||
public required TimeOnly WindowEnd { get; init; }
|
||||
|
||||
/// <summary>Random daily shift applied to start and end, ± this amount.</summary>
|
||||
public required TimeSpan WindowJitter { get; init; }
|
||||
|
||||
public required TimeSpan SessionMin { get; init; }
|
||||
public required TimeSpan SessionMax { get; init; }
|
||||
public required TimeSpan PauseMin { get; init; }
|
||||
public required TimeSpan PauseMax { get; init; }
|
||||
|
||||
/// <summary>Budgets per category, excluding <see cref="ActionKind.DataDownload"/>.</summary>
|
||||
public required IReadOnlyDictionary<ActionKind, Budget> Budgets { get; init; }
|
||||
|
||||
/// <summary>Daily download budget in bytes.</summary>
|
||||
public required long DataPerDayBytes { get; init; }
|
||||
|
||||
/// <summary>Default per-account backfill limit (posts per day).</summary>
|
||||
public required int BackfillPostsPerAccountPerDay { get; init; }
|
||||
|
||||
/// <summary>Gradual start: days to go from half to full budgets.</summary>
|
||||
public required int RampUpDays { get; init; }
|
||||
|
||||
/// <summary>Active weekdays (all by default).</summary>
|
||||
public IReadOnlySet<DayOfWeek> ActiveDays { get; init; } = new HashSet<DayOfWeek>(Enum.GetValues<DayOfWeek>());
|
||||
|
||||
public bool GradualStart { get; init; } = true;
|
||||
|
||||
public GesturePace Pace { get; init; } = GesturePace.Natural;
|
||||
|
||||
private const long GB = 1024L * 1024 * 1024;
|
||||
|
||||
public static CautionProfile Prudent { get; } = new()
|
||||
{
|
||||
Kind = CautionProfileKind.Prudent,
|
||||
WindowStart = new TimeOnly(7, 30),
|
||||
WindowEnd = new TimeOnly(23, 30),
|
||||
WindowJitter = TimeSpan.FromMinutes(40),
|
||||
SessionMin = TimeSpan.FromMinutes(2),
|
||||
SessionMax = TimeSpan.FromMinutes(10),
|
||||
PauseMin = TimeSpan.FromMinutes(20),
|
||||
PauseMax = TimeSpan.FromMinutes(90),
|
||||
Budgets = new Dictionary<ActionKind, Budget>
|
||||
{
|
||||
[ActionKind.Home] = new(4, 30),
|
||||
[ActionKind.ProfileOpen] = new(12, 100),
|
||||
[ActionKind.StoryView] = new(50, 300),
|
||||
[ActionKind.BackfillPage] = new(20, 100),
|
||||
[ActionKind.SinglePost] = new(10, 60),
|
||||
[ActionKind.FollowingListPage] = new(15, 60),
|
||||
},
|
||||
DataPerDayBytes = 4 * GB,
|
||||
BackfillPostsPerAccountPerDay = 300,
|
||||
RampUpDays = 7,
|
||||
};
|
||||
|
||||
public static CautionProfile Balanced { get; } = new()
|
||||
{
|
||||
Kind = CautionProfileKind.Balanced,
|
||||
WindowStart = new TimeOnly(7, 0),
|
||||
WindowEnd = new TimeOnly(0, 0),
|
||||
WindowJitter = TimeSpan.FromMinutes(30),
|
||||
SessionMin = TimeSpan.FromMinutes(3),
|
||||
SessionMax = TimeSpan.FromMinutes(14),
|
||||
PauseMin = TimeSpan.FromMinutes(12),
|
||||
PauseMax = TimeSpan.FromMinutes(60),
|
||||
Budgets = new Dictionary<ActionKind, Budget>
|
||||
{
|
||||
[ActionKind.Home] = new(5, 45),
|
||||
[ActionKind.ProfileOpen] = new(20, 180),
|
||||
[ActionKind.StoryView] = new(80, 500),
|
||||
[ActionKind.BackfillPage] = new(30, 180),
|
||||
[ActionKind.SinglePost] = new(15, 100),
|
||||
[ActionKind.FollowingListPage] = new(20, 90),
|
||||
},
|
||||
DataPerDayBytes = 8 * GB,
|
||||
BackfillPostsPerAccountPerDay = 500,
|
||||
RampUpDays = 5,
|
||||
};
|
||||
|
||||
public static CautionProfile Fast { get; } = new()
|
||||
{
|
||||
Kind = CautionProfileKind.Fast,
|
||||
WindowStart = new TimeOnly(6, 30),
|
||||
WindowEnd = new TimeOnly(0, 30),
|
||||
WindowJitter = TimeSpan.FromMinutes(30),
|
||||
SessionMin = TimeSpan.FromMinutes(4),
|
||||
SessionMax = TimeSpan.FromMinutes(18),
|
||||
PauseMin = TimeSpan.FromMinutes(8),
|
||||
PauseMax = TimeSpan.FromMinutes(40),
|
||||
Budgets = new Dictionary<ActionKind, Budget>
|
||||
{
|
||||
[ActionKind.Home] = new(6, 60),
|
||||
[ActionKind.ProfileOpen] = new(30, 300),
|
||||
[ActionKind.StoryView] = new(120, 800),
|
||||
[ActionKind.BackfillPage] = new(45, 300),
|
||||
[ActionKind.SinglePost] = new(20, 160),
|
||||
[ActionKind.FollowingListPage] = new(30, 150),
|
||||
},
|
||||
DataPerDayBytes = 16 * GB,
|
||||
BackfillPostsPerAccountPerDay = 800,
|
||||
RampUpDays = 3,
|
||||
};
|
||||
|
||||
public static CautionProfile For(CautionProfileKind kind) => kind switch
|
||||
{
|
||||
CautionProfileKind.Prudent => Prudent,
|
||||
CautionProfileKind.Balanced => Balanced,
|
||||
CautionProfileKind.Fast => Fast,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(kind), kind, "Custom profiles are stored values, not presets."),
|
||||
};
|
||||
|
||||
/// <summary>Limits enforced by the interface (spec §7.5): minimum pause 5 min, session ≤ 30 min, window ≤ 20 h, no budget above twice «Rapido».</summary>
|
||||
public static class Limits
|
||||
{
|
||||
public static readonly TimeSpan MinPause = TimeSpan.FromMinutes(5);
|
||||
public static readonly TimeSpan MaxSession = TimeSpan.FromMinutes(30);
|
||||
public static readonly TimeSpan MaxWindow = TimeSpan.FromHours(20);
|
||||
|
||||
public static Budget MaxBudget(ActionKind kind) =>
|
||||
new(Fast.Budgets[kind].PerHour * 2, Fast.Budgets[kind].PerDay * 2);
|
||||
|
||||
public static long MaxDataPerDayBytes => Fast.DataPerDayBytes * 2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
namespace Febe.Core.Domain;
|
||||
|
||||
/// <summary>
|
||||
/// Kind of an entry (spec §4.3). The folder name and the {tipo} placeholder are the Italian names
|
||||
/// returned by <see cref="EntryKindNames.Folder"/>.
|
||||
/// </summary>
|
||||
public enum EntryKind
|
||||
{
|
||||
/// <summary>Grid post, reels included («post»).</summary>
|
||||
Post,
|
||||
|
||||
/// <summary>Active story («storie»).</summary>
|
||||
Story,
|
||||
|
||||
/// <summary>Item of a highlight collection («evidenza»).</summary>
|
||||
Highlight,
|
||||
|
||||
/// <summary>Someone else's post where the account appears («taggati»).</summary>
|
||||
Tagged,
|
||||
|
||||
/// <summary>Profile picture, one copy per change («profilo»).</summary>
|
||||
ProfilePicture,
|
||||
}
|
||||
|
||||
public static class EntryKindNames
|
||||
{
|
||||
/// <summary>Folder name and value of the {tipo} placeholder.</summary>
|
||||
public static string Folder(EntryKind kind) => kind switch
|
||||
{
|
||||
EntryKind.Post => "post",
|
||||
EntryKind.Story => "storie",
|
||||
EntryKind.Highlight => "evidenza",
|
||||
EntryKind.Tagged => "taggati",
|
||||
EntryKind.ProfilePicture => "profilo",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(kind), kind, null),
|
||||
};
|
||||
|
||||
public static EntryKind? FromFolder(string folder) => folder.ToLowerInvariant() switch
|
||||
{
|
||||
"post" => EntryKind.Post,
|
||||
"storie" => EntryKind.Story,
|
||||
"evidenza" => EntryKind.Highlight,
|
||||
"taggati" => EntryKind.Tagged,
|
||||
"profilo" => EntryKind.ProfilePicture,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>State of an entry (spec §8.3).</summary>
|
||||
public enum EntryState
|
||||
{
|
||||
/// <summary>da scaricare</summary>
|
||||
ToDownload,
|
||||
|
||||
/// <summary>scaricato</summary>
|
||||
Downloaded,
|
||||
|
||||
/// <summary>parziale: some files missing</summary>
|
||||
Partial,
|
||||
|
||||
/// <summary>fallito</summary>
|
||||
Failed,
|
||||
|
||||
/// <summary>saltato: excluded by a limit (e.g. video too large)</summary>
|
||||
Skipped,
|
||||
|
||||
/// <summary>importato</summary>
|
||||
Imported,
|
||||
|
||||
/// <summary>eliminato: kept in the database without files so it is not downloaded again</summary>
|
||||
Deleted,
|
||||
}
|
||||
|
||||
/// <summary>State of a single file.</summary>
|
||||
public enum MediaState
|
||||
{
|
||||
ToDownload,
|
||||
Downloaded,
|
||||
Failed,
|
||||
Skipped,
|
||||
Imported,
|
||||
Deleted,
|
||||
|
||||
/// <summary>The signed address expired: needs the Post singolo recipe (not possible for stories).</summary>
|
||||
Expired,
|
||||
}
|
||||
|
||||
public enum MediaKind
|
||||
{
|
||||
Photo,
|
||||
Video,
|
||||
}
|
||||
|
||||
/// <summary>Where an entry came from.</summary>
|
||||
public enum Provenance
|
||||
{
|
||||
Downloaded,
|
||||
Imported,
|
||||
}
|
||||
|
||||
/// <summary>State of a followed account (spec §4.2).</summary>
|
||||
public enum AccountState
|
||||
{
|
||||
/// <summary>Aggiornato</summary>
|
||||
UpToDate,
|
||||
|
||||
/// <summary>Storico in corso</summary>
|
||||
Backfilling,
|
||||
|
||||
/// <summary>In pausa</summary>
|
||||
Paused,
|
||||
|
||||
/// <summary>Solo archivio: never contacted</summary>
|
||||
ArchiveOnly,
|
||||
|
||||
/// <summary>Non raggiungibile: private and not followed, missing, blocked, renamed</summary>
|
||||
Unreachable,
|
||||
}
|
||||
|
||||
/// <summary>Check frequency of an account (spec §7.3).</summary>
|
||||
public enum Frequency
|
||||
{
|
||||
Low,
|
||||
Normal,
|
||||
High,
|
||||
|
||||
/// <summary>Su misura: explicit hours for posts and maximum interval for stories.</summary>
|
||||
Custom,
|
||||
}
|
||||
|
||||
/// <summary>The six per-account switches of «Cosa scaricare» (spec §4.3, §4.4).</summary>
|
||||
[Flags]
|
||||
public enum ContentTypes
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>Foto dei post</summary>
|
||||
PostPhotos = 1,
|
||||
|
||||
/// <summary>Video e reel</summary>
|
||||
PostVideos = 2,
|
||||
|
||||
/// <summary>Storie</summary>
|
||||
Stories = 4,
|
||||
|
||||
/// <summary>Storie in evidenza</summary>
|
||||
Highlights = 8,
|
||||
|
||||
/// <summary>Post in cui è taggato</summary>
|
||||
Tagged = 16,
|
||||
|
||||
/// <summary>Foto del profilo</summary>
|
||||
ProfilePicture = 32,
|
||||
|
||||
All = PostPhotos | PostVideos | Stories | Highlights | Tagged | ProfilePicture,
|
||||
}
|
||||
|
||||
/// <summary>Starting points when adding accounts (spec §4.2).</summary>
|
||||
public enum StartingPoint
|
||||
{
|
||||
/// <summary>Scarica tutto e tieni aggiornato</summary>
|
||||
EverythingAndKeepUpdated,
|
||||
|
||||
/// <summary>Solo le novità da oggi</summary>
|
||||
OnlyNewFromToday,
|
||||
|
||||
/// <summary>Solo le storie</summary>
|
||||
OnlyStories,
|
||||
}
|
||||
|
||||
/// <summary>Caution profiles (spec §7.5). Prudent is the default.</summary>
|
||||
public enum CautionProfileKind
|
||||
{
|
||||
Prudent,
|
||||
Balanced,
|
||||
Fast,
|
||||
Custom,
|
||||
}
|
||||
|
||||
/// <summary>«Ritmo dei gesti» slider (spec §7.7).</summary>
|
||||
public enum GesturePace
|
||||
{
|
||||
Slow,
|
||||
Natural,
|
||||
Brisk,
|
||||
}
|
||||
Reference in new issue
Block a user