merge: full Titano Server (auth, users, uploads, sync, jobs, render nodes, events, admin panel, Windows service)

# Conflicts:
#	i18n/en/Server.resx
#	i18n/it/Server.it.resx
#	src/Titano.Data/Repositories/FrameRepository.cs
This commit is contained in:
Claude committed 2026-10-02 12:54:14 +00:00
commit 8f54bd8804
104 files changed
+8879 -250

No files matched your search

@@ -60,6 +60,28 @@ public sealed record ArchiveStats(
IReadOnlyList<FormatBucket> ByFormat,
ArchiveHealth Health);
/// <summary>Fields a client may change on a sequence; null leaves a field unchanged, an empty title or notes clears it.</summary>
public sealed record SequenceEdit
{
public string? Title { get; init; }
public IReadOnlyList<string>? Tags { get; init; }
public int? Rating { get; init; }
public string? Notes { get; init; }
public string? SettingsJson { get; init; }
}
public enum SequenceEditOutcome
{
Updated,
NotFound,
/// <summary>The settings version moved since the client read it.</summary>
Conflict,
}
/// <summary>Result of <see cref="SequenceRepository.EditAsync"/>: the updated sequence, or the stored one on conflict.</summary>
public sealed record SequenceEditResult(SequenceEditOutcome Outcome, Sequence? Sequence);
public sealed record YearBucket(int Year, int Sequences, long Photos, long Bytes);
/// <summary>One heatmap cell: sequences and photos whose first capture falls in the month.</summary>
@@ -175,6 +197,38 @@ public sealed class SequenceRepository
return updated;
}, cancellationToken);
/// <summary>
/// Applies a client edit atomically and bumps <c>settings_version</c>. With <paramref name="expectedSettingsVersion"/>
/// the edit is refused (<see cref="SequenceEditOutcome.Conflict"/>, carrying the stored sequence) when someone else
/// changed the sequence first (BRIEF §14.5).
/// </summary>
public Task<SequenceEditResult> EditAsync(Guid id, SequenceEdit edit, int? expectedSettingsVersion, CancellationToken cancellationToken = default) =>
_db.InTransactionAsync(async session =>
{
var current = await session.QuerySingleOrDefaultAsync($"{_select} WHERE s.id = $1{_db.Sql.ForUpdate}", [id], Map, cancellationToken)
.ConfigureAwait(false);
if (current is null) return new SequenceEditResult(SequenceEditOutcome.NotFound, null);
if (expectedSettingsVersion is { } expected && expected != current.SettingsVersion)
return new SequenceEditResult(SequenceEditOutcome.Conflict, current);
var updated = current with
{
Title = edit.Title is null ? current.Title : NullIfEmpty(edit.Title),
Notes = edit.Notes is null ? current.Notes : NullIfEmpty(edit.Notes),
Rating = edit.Rating ?? current.Rating,
SettingsJson = edit.SettingsJson ?? current.SettingsJson,
SettingsVersion = current.SettingsVersion + 1,
UpdatedAt = DateTimeOffset.UtcNow,
};
await UpsertRowAsync(session, updated, cancellationToken).ConfigureAwait(false);
if (edit.Tags is not null) await ReplaceTagsAsync(session, id, edit.Tags, cancellationToken).ConfigureAwait(false);
var stored = await session.QuerySingleAsync($"{_select} WHERE s.id = $1", [id], cancellationToken).ConfigureAwait(false);
return new SequenceEditResult(SequenceEditOutcome.Updated, Map(stored));
}, cancellationToken);
/// <summary>Gives every sequence owned by <paramref name="fromUserId"/> to <paramref name="toUserId"/>; returns how many.</summary>
public Task<int> ReassignOwnerAsync(Guid fromUserId, Guid toUserId, CancellationToken cancellationToken = default) =>
_db.ExecuteAsync("UPDATE sequences SET owner_user_id = $2 WHERE owner_user_id = $1", [fromUserId, toUserId], cancellationToken);
/// <summary>One page of sequences matching <paramref name="query"/>.</summary>
public Task<Page<Sequence>> ListAsync(SequenceQuery query, CancellationToken cancellationToken = default)
{
@@ -393,6 +447,8 @@ public sealed class SequenceRepository
}
}
private static string? NullIfEmpty(string value) => string.IsNullOrWhiteSpace(value) ? null : value.Trim();
/// <summary>Camera wall-clock times are stored without zone, whatever kind the caller's value has.</summary>
internal static DateTime? Wall(DateTime? value) =>
value is { } v ? DateTime.SpecifyKind(v, DateTimeKind.Unspecified) : null;