feat: stream tickets

This commit is contained in:
2024-08-19 10:10:59 +01:00
parent 3148b2cf6f
commit 015b75f894
9 changed files with 654 additions and 13 deletions

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class StreamTicketsConfiguration : IEntityTypeConfiguration<StreamTickets>
{
public void Configure(EntityTypeBuilder<StreamTickets> builder)
{
builder.HasKey(a => a.Id);
builder.Property(a => a.Created)
.IsRequired();
builder.Property(a => a.Token)
.IsRequired();
builder.HasOne(a => a.UserStream)
.WithMany()
.HasForeignKey(a => a.UserStreamId);
}
}

View File

@ -32,7 +32,9 @@ public class UserStreamConfiguration : IEntityTypeConfiguration<UserStream>
builder.Property(a => a.LastSegment)
.IsRequired();
builder.Property(a => a.AdmissionCost);
builder.HasOne(a => a.Endpoint)
.WithMany()
.HasForeignKey(a => a.EndpointId);
@ -41,4 +43,4 @@ public class UserStreamConfiguration : IEntityTypeConfiguration<UserStream>
.WithMany(a => a.Streams)
.HasForeignKey(a => a.PubKey);
}
}
}

View File

@ -30,8 +30,9 @@ public class Payment
public enum PaymentType
{
Topup = 0,
TopUp = 0,
Zap = 1,
Credit = 2,
Withdrawal = 3,
AdmissionFee = 4,
}

View File

@ -0,0 +1,13 @@
namespace NostrStreamer.Database;
public class StreamTickets
{
public Guid Id { get; init; } = Guid.NewGuid();
public Guid UserStreamId { get; init; }
public UserStream UserStream { get; init; } = null!;
public DateTime Created { get; init; } = DateTime.UtcNow;
public Guid Token { get; init; } = Guid.NewGuid();
}

View File

@ -8,18 +8,18 @@ public class UserStream
public User User { get; init; } = null!;
public string StreamId { get; init; } = null!;
public DateTime Starts { get; init; } = DateTime.UtcNow;
public DateTime? Ends { get; set; }
public UserStreamState State { get; set; }
/// <summary>
/// Nostr Event for this stream
/// </summary>
public string Event { get; set; } = null!;
/// <summary>
/// URL of auto-generated thumbnail
/// </summary>
@ -32,24 +32,29 @@ public class UserStream
/// Publisher edge IP
/// </summary>
public string EdgeIp { get; set; } = null!;
/// <summary>
/// Publisher edge client id
/// </summary>
public string ForwardClientId { get; set; } = null!;
public DateTime LastSegment { get; set; } = DateTime.UtcNow;
/// <summary>
/// Total sats charged during this stream
/// </summary>
public decimal MilliSatsCollected { get; set; }
/// <summary>
/// Total seconds produced in HLS segments
/// </summary>
public decimal Length { get; set; }
/// <summary>
/// Cost to view stream, tickets in <see cref="StreamTickets"/>
/// </summary>
public decimal? AdmissionCost { get; set; }
public List<UserStreamGuest> Guests { get; init; } = new();
public List<UserStreamRecording> Recordings { get; init; } = new();