Files
DorkNet/DorkNet.Server/Data/Entities/ChatMessageEntity.cs
Alexa 4edf25b2d5 Import december-2020-12-18 from private repo (scrubbed 2026-05-27)
Targets Rec Room 2020.12.18 client.

Re-import after adding:
- DorkNet.ClientMod/dorknet-clientmod.json.template — config schema
  the launcher's manifest-driven patcher renders into UserData/.
- tools/build-patcher-zip.ps1 — produces the dorknet-clientpatch-{key}.zip
  Release asset the launcher fetches.
- .github/workflows/release.yml — auto-publishes both Release assets
  on v1-december-* tag push.

Scrubbed via maintainer-side scrub-for-public.ps1: same drop rules as
the prior import, plus build-patcher-zip.ps1 added to the tools/
allow-list so it survives the scrub.
2026-05-27 01:04:12 +03:00

40 lines
1.4 KiB
C#

using System.ComponentModel.DataAnnotations;
namespace DorkNet.Server.Data.Entities;
/// <summary>
/// In-game text-chat message. Sent to the chat.rec.net/thread
/// endpoint family; backed by a flat per-thread row table where the
/// thread id is just the canonical (lower, higher) pair of player ids
/// for DMs, or the room id for room-wide chats.
///
/// We keep a separate table from <see cref="MessageEntity"/> because
/// the wire shape and history-fetch semantics differ — chat is
/// append-and-read-recent, messages are inbox-style with read
/// receipts.
/// </summary>
public class ChatMessageEntity
{
public long Id { get; set; }
/// <summary>String thread key. Format: <c>dm:<low>:<high></c> for
/// direct messages between two players (lower id first), or
/// <c>room:<roomId></c> for room-wide chats.</summary>
[MaxLength(64)]
public string ThreadKey { get; set; } = string.Empty;
public long SenderPlayerId { get; set; }
[MaxLength(2000)]
public string Body { get; set; } = string.Empty;
public DateTime SentAt { get; set; } = DateTime.UtcNow;
/// <summary>Build the canonical DM thread key for two players.
/// Order-independent so both sides hit the same row.</summary>
public static string DmKey(long a, long b) =>
a < b ? $"dm:{a}:{b}" : $"dm:{b}:{a}";
public static string RoomKey(long roomId) => $"room:{roomId}";
}