Push notifications

This commit is contained in:
2023-12-18 12:19:09 +00:00
parent d087850f69
commit 053d34cde7
19 changed files with 1175 additions and 4 deletions

View File

@ -0,0 +1,32 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class PushSubscriptionConfiguration : IEntityTypeConfiguration<PushSubscription>
{
public void Configure(EntityTypeBuilder<PushSubscription> builder)
{
builder.HasKey(a => a.Id);
builder.Property(a => a.Created)
.IsRequired();
builder.Property(a => a.LastUsed)
.IsRequired();
builder.Property(a => a.Pubkey)
.IsRequired();
builder.Property(a => a.Endpoint)
.IsRequired();
builder.Property(a => a.Auth)
.IsRequired();
builder.Property(a => a.Key)
.IsRequired();
builder.Property(a => a.Scope)
.IsRequired();
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace NostrStreamer.Database.Configuration;
public class PushSubscriptionTargetConfiguration : IEntityTypeConfiguration<PushSubscriptionTarget>
{
public void Configure(EntityTypeBuilder<PushSubscriptionTarget> builder)
{
builder.HasKey(a => a.Id);
builder.Property(a => a.TargetPubkey)
.IsRequired();
builder.Property(a => a.SubscriberPubkey)
.IsRequired();
builder.HasIndex(a => a.TargetPubkey);
builder.HasIndex(a => new {a.SubscriberPubkey, a.TargetPubkey})
.IsUnique();
}
}

View File

@ -0,0 +1,23 @@
using System.ComponentModel.DataAnnotations;
namespace NostrStreamer.Database;
public class PushSubscription
{
public Guid Id { get; init; } = Guid.NewGuid();
public DateTime Created { get; init; } = DateTime.UtcNow;
public DateTime LastUsed { get; init; } = DateTime.UtcNow;
[MaxLength(64)]
public string Pubkey { get; init; } = null!;
public string Endpoint { get; init; } = null!;
public string Key { get; init; } = null!;
public string Auth { get; init; } = null!;
public string Scope { get; init; } = null!;
}

View File

@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace NostrStreamer.Database;
public class PushSubscriptionTarget
{
public Guid Id { get; init; } = Guid.NewGuid();
[MaxLength(64)]
public string SubscriberPubkey { get; init; } = null!;
[MaxLength(64)]
public string TargetPubkey { get; init; } = null!;
}

View File

@ -33,4 +33,8 @@ public class StreamerContext : DbContext
public DbSet<UserStreamForwards> Forwards => Set<UserStreamForwards>();
public DbSet<UserStreamClip> Clips => Set<UserStreamClip>();
public DbSet<PushSubscription> PushSubscriptions => Set<PushSubscription>();
public DbSet<PushSubscriptionTarget> PushSubscriptionTargets => Set<PushSubscriptionTarget>();
}