Add versioning, content, and chat presence/notifications services
- SOR.Versioning: version.check handler, ClientRelease entity + admin UI - SOR.Content: incremental card sync (DefinitionVersion cursor via Postgres trigger), content.sync / content.sets / content.card handlers - Chat: presence (account_presence) + notifications with unread count and mark-read - CardDefinition: DefinitionVersion bigint (trigger-assigned) + IsRetired soft-delete - 3 migrations applied to pg-forge-01 (Identity, Chat, Catalog) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -89,9 +89,24 @@ public sealed class CardDefinition
|
||||
/// <summary>Only published cards are visible in the client and available for collection.</summary>
|
||||
public bool IsPublished { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Soft-deleted cards remain in the catalog so clients can purge them from local cache.
|
||||
/// Retired cards are excluded from new collection grants, booster draws, and shop listings.
|
||||
/// </summary>
|
||||
public bool IsRetired { get; set; }
|
||||
|
||||
public DateTimeOffset? RetiredAt { get; set; }
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Monotonic version counter assigned by a Postgres trigger on every INSERT or UPDATE.
|
||||
/// Clients use this as a cursor for incremental catalog sync:
|
||||
/// fetch WHERE DefinitionVersion > lastKnownVersion ORDER BY DefinitionVersion ASC LIMIT N.
|
||||
/// </summary>
|
||||
public long DefinitionVersion { get; set; }
|
||||
|
||||
// ── Navigation ───────────────────────────────────────────────────────────
|
||||
public CardSet? Set { get; set; }
|
||||
public ICollection<CardAsset> Assets { get; set; } = new List<CardAsset>();
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace SOR.Database.Entities.Chat;
|
||||
|
||||
using SOR.Database.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// Tracks the real-time presence status of an account.
|
||||
/// One row per account; upserted when the client calls chat.presence.set.
|
||||
/// </summary>
|
||||
public sealed class AccountPresence
|
||||
{
|
||||
/// <summary>PK and FK cross-schema to identity.accounts.</summary>
|
||||
public Guid AccountId { get; set; }
|
||||
|
||||
public PresenceStatus Status { get; set; }
|
||||
|
||||
/// <summary>Populated when Status == InMatch; null otherwise.</summary>
|
||||
public Guid? CurrentMatchId { get; set; }
|
||||
|
||||
/// <summary>When this presence record was last changed.</summary>
|
||||
public DateTimeOffset UpdatedAt { get; set; }
|
||||
|
||||
/// <summary>Last time the account was seen online (even if now Away/Offline).</summary>
|
||||
public DateTimeOffset LastSeenAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
namespace SOR.Database.Entities.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// An in-app notification for a specific account.
|
||||
/// Delivered over the existing WebSocket connection; persisted so the client can
|
||||
/// fetch missed notifications on reconnect.
|
||||
///
|
||||
/// Well-known NotificationType values:
|
||||
/// "outbid" — another player placed a higher bid on your auction
|
||||
/// "friend_request" — incoming friend request
|
||||
/// "friend_accept" — your friend request was accepted
|
||||
/// "match_invite" — challenged to a match
|
||||
/// </summary>
|
||||
public sealed class Notification
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
/// <summary>Cross-schema: identity.accounts.Id of the recipient.</summary>
|
||||
public Guid RecipientAccountId { get; set; }
|
||||
|
||||
/// <summary>Well-known type string used by the client to choose how to render the notification.</summary>
|
||||
public string NotificationType { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>JSONB: type-specific payload (e.g. listingId for outbid, requesterId for friend_request).</summary>
|
||||
public string? PayloadJson { get; set; }
|
||||
|
||||
public DateTimeOffset CreatedAt { get; set; }
|
||||
|
||||
/// <summary>Null = unread. Set when the client calls chat.notifications.read.</summary>
|
||||
public DateTimeOffset? ReadAt { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace SOR.Database.Entities.Identity;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a published client release for a given platform.
|
||||
/// Used by the version check service to inform clients whether an update is available
|
||||
/// or required before they can play.
|
||||
/// </summary>
|
||||
public sealed class ClientRelease
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
/// <summary>Platform identifier: "android", "ios", "pc", "web".</summary>
|
||||
public string Platform { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Semantic version string, e.g. "1.2.3".</summary>
|
||||
public string Version { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>If true, clients on any older version must update before playing.</summary>
|
||||
public bool IsRequired { get; set; }
|
||||
|
||||
/// <summary>Direct download or store URL for this release.</summary>
|
||||
public string? DownloadUrl { get; set; }
|
||||
|
||||
/// <summary>Human-readable release notes shown in the update prompt.</summary>
|
||||
public string? ReleaseNotes { get; set; }
|
||||
|
||||
/// <summary>Inactive releases are ignored by the version check.</summary>
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public DateTimeOffset ReleasedAt { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user