Push notifications
This commit is contained in:
@ -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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
23
NostrStreamer/Database/PushSubscription.cs
Normal file
23
NostrStreamer/Database/PushSubscription.cs
Normal 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!;
|
||||
}
|
14
NostrStreamer/Database/PushSubscriptionTarget.cs
Normal file
14
NostrStreamer/Database/PushSubscriptionTarget.cs
Normal 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!;
|
||||
}
|
@ -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>();
|
||||
}
|
||||
|
Reference in New Issue
Block a user