67 lines
2.8 KiB
C#
67 lines
2.8 KiB
C#
using System.Text.Json.Serialization;
|
|
using WebDrop.Core;
|
|
|
|
namespace WebDrop.Api;
|
|
|
|
public sealed class ErrorBody
|
|
{
|
|
[JsonPropertyName("error")] public required string Error { get; init; }
|
|
}
|
|
|
|
public sealed class GoneLogBody
|
|
{
|
|
[JsonPropertyName("error")] public string Error { get; init; } = "gone";
|
|
[JsonPropertyName("oldest_seq")] public required long OldestSeq { get; init; }
|
|
}
|
|
|
|
public sealed class ServerInfoBody
|
|
{
|
|
[JsonPropertyName("protocol")] public int Protocol { get; init; } = 1;
|
|
[JsonPropertyName("contract_version")] public string ContractVersion { get; init; } = ApiContract.Version;
|
|
[JsonPropertyName("captcha")] public required CaptchaBody Captcha { get; init; }
|
|
[JsonPropertyName("transports")] public required TransportsBody Transports { get; init; }
|
|
[JsonPropertyName("limits")] public required LimitsBody Limits { get; init; }
|
|
}
|
|
|
|
/// <summary>告诉前端要不要出示验证码、widget 该连哪里(Cap 的 data-cap-api-endpoint)。</summary>
|
|
public sealed class CaptchaBody
|
|
{
|
|
[JsonPropertyName("provider")] public required string Provider { get; init; }
|
|
[JsonPropertyName("enabled")] public required bool Enabled { get; init; }
|
|
[JsonPropertyName("api_endpoint")] public string? ApiEndpoint { get; init; }
|
|
}
|
|
|
|
public sealed class TransportsBody
|
|
{
|
|
[JsonPropertyName("websocket")] public bool WebSocket { get; init; } = true;
|
|
[JsonPropertyName("sse")] public bool Sse { get; init; } = true;
|
|
[JsonPropertyName("http3")] public required bool Http3 { get; init; }
|
|
}
|
|
|
|
public sealed class LimitsBody
|
|
{
|
|
[JsonPropertyName("max_payload_bytes")] public required int MaxPayloadBytes { get; init; }
|
|
[JsonPropertyName("max_frames_per_item")] public required int MaxFramesPerItem { get; init; }
|
|
[JsonPropertyName("max_channel_bytes")] public required long MaxChannelBytes { get; init; }
|
|
[JsonPropertyName("max_seats")] public required int MaxSeats { get; init; }
|
|
[JsonPropertyName("max_ttl_seconds")] public required int MaxTtlSeconds { get; init; }
|
|
}
|
|
|
|
[JsonSerializable(typeof(ErrorBody))]
|
|
[JsonSerializable(typeof(GoneLogBody))]
|
|
[JsonSerializable(typeof(ServerInfoBody))]
|
|
[JsonSerializable(typeof(ChannelInfo))]
|
|
[JsonSerializable(typeof(ShareInfo))]
|
|
[JsonSerializable(typeof(CreateShareRequest))]
|
|
[JsonSerializable(typeof(ShareSettingsPatch))]
|
|
[JsonSerializable(typeof(FinishShareRequest))]
|
|
[JsonSerializable(typeof(CreateChannelRequest))]
|
|
[JsonSerializable(typeof(ChannelSettingsPatch))]
|
|
[JsonSerializable(typeof(SeatJoined))]
|
|
[JsonSerializable(typeof(List<SeatInfo>))]
|
|
[JsonSerializable(typeof(AppendResult))]
|
|
[JsonSerializable(typeof(SiteverifyRequest))]
|
|
[JsonSerializable(typeof(SiteverifyResponse))]
|
|
[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public sealed partial class ApiJson : JsonSerializerContext;
|