feat(server): implement sealed share lifecycle
Signed-off-by: JustMe <mr.toing@outlook.com>
This commit is contained in:
1 parent
e02e024605
commit
42b93ae2d8
45 files changed
+6327
No files matched your search
@@ -0,0 +1,100 @@
|
||||
namespace WebDrop.Core;
|
||||
|
||||
public sealed record Channel(
|
||||
Id16 Id,
|
||||
ChannelMode Mode,
|
||||
ChannelSettings Settings,
|
||||
byte[]? ReadHash,
|
||||
byte[]? WriteHash,
|
||||
byte[] OwnerHash,
|
||||
long CreatedAt,
|
||||
long ExpiresAt,
|
||||
long LastSeq,
|
||||
long CompactedThrough,
|
||||
long Bytes);
|
||||
|
||||
public sealed record Share(
|
||||
Id16 Id,
|
||||
ShareSettings Settings,
|
||||
byte[] ReadHash,
|
||||
byte[]? OwnerHash,
|
||||
byte[]? CreatorEndpointHash,
|
||||
long CreatedAt,
|
||||
long ExpiresAt,
|
||||
long? SealedAt,
|
||||
Id16? ManifestItemId,
|
||||
long Bytes)
|
||||
{
|
||||
public bool IsSealed => SealedAt is not null;
|
||||
}
|
||||
|
||||
public sealed record ShareItem(
|
||||
Id16 ShareId,
|
||||
Id16 ItemId,
|
||||
FrameFlags Flags,
|
||||
long MaxDownloads,
|
||||
long Downloads,
|
||||
int FrameCount,
|
||||
long MaxIndex,
|
||||
long? FinalIndex,
|
||||
long Bytes,
|
||||
long CreatedAt,
|
||||
long ExpiresAt,
|
||||
long? CloseDeadline)
|
||||
{
|
||||
public bool IsGated => (Flags & FrameFlags.Gated) != 0;
|
||||
public bool IsSnapshot => (Flags & FrameFlags.Snapshot) != 0;
|
||||
public bool IsComplete => FinalIndex is { } f && FrameCount == f + 1;
|
||||
}
|
||||
|
||||
public sealed record ShareFrame(
|
||||
Id16 ShareId,
|
||||
Id16 ItemId,
|
||||
uint Index,
|
||||
long AckSeq,
|
||||
int Length,
|
||||
byte[] Digest,
|
||||
byte[]? Inline,
|
||||
string? BlobKey);
|
||||
|
||||
public sealed record Item(
|
||||
Id16 ChannelId,
|
||||
Id16 ItemId,
|
||||
byte[] AuthorHash,
|
||||
FrameFlags Flags,
|
||||
long MaxDownloads,
|
||||
long Downloads,
|
||||
int FrameCount,
|
||||
long MaxIndex,
|
||||
long? FinalIndex,
|
||||
long Bytes,
|
||||
long CreatedAt,
|
||||
long ExpiresAt,
|
||||
long? CloseDeadline,
|
||||
string? Label)
|
||||
{
|
||||
public bool IsGated => (Flags & FrameFlags.Gated) != 0;
|
||||
public bool IsSnapshot => (Flags & FrameFlags.Snapshot) != 0;
|
||||
public bool IsComplete => FinalIndex is { } f && FrameCount == f + 1;
|
||||
}
|
||||
|
||||
public sealed record Seat(byte[] EndpointHash, long JoinedAt, byte[]? Label);
|
||||
|
||||
/// <summary>已存储的一帧(完整封装)。Inline 与 BlobKey 二选一。</summary>
|
||||
public sealed record StoredFrame(
|
||||
Id16 ChannelId,
|
||||
Id16 ItemId,
|
||||
uint Index,
|
||||
long Seq,
|
||||
int Length,
|
||||
byte[] Digest,
|
||||
byte[]? Inline,
|
||||
string? BlobKey);
|
||||
|
||||
public sealed record LogEntry(long Seq, LogKind Kind, Id16 ItemId, uint FrameIndex, byte Aux, long CreatedAt);
|
||||
|
||||
/// <summary>一次请求验证通过后的身份。</summary>
|
||||
public sealed record Principal(Role Role, byte[] EndpointHash);
|
||||
|
||||
/// <summary>请求携带的凭据,尚未验证。</summary>
|
||||
public sealed record Credentials(Role ClaimedRole, byte[]? Token, byte[] EndpointHash);
|
||||
Reference in new issue
Block a user