feat: paste views; configuration validation; hmacsha256 method; enhance paste clean up serivce; paste view clean up service;

This commit is contained in:
2026-01-09 19:12:05 -05:00
parent 60876eb1ba
commit 3048af3a6d
20 changed files with 592 additions and 46 deletions
+7
View File
@@ -7,6 +7,7 @@ namespace SharpbinV3.Server.Data
{
public DbSet<User> Users => Set<User>();
public DbSet<Paste> Pastes => Set<Paste>();
public DbSet<PasteView> PasteViews => Set<PasteView>();
public DbSet<RefreshToken> RefreshTokens => Set<RefreshToken>();
public DbSet<UserTotp> UserTotps => Set<UserTotp>();
@@ -20,6 +21,12 @@ namespace SharpbinV3.Server.Data
.HasForeignKey(p => p.AuthorUUID)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<PasteView>()
.HasOne(pv => pv.Paste)
.WithMany(p => p.PasteViews)
.HasForeignKey(pv => pv.PastePID)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<RefreshToken>()
.HasOne(r => r.User)
.WithMany(u => u.RefreshTokens)
+2 -1
View File
@@ -8,7 +8,6 @@ namespace SharpbinV3.Server.Data.Entities
[Index(nameof(ID), IsUnique = true)]
[Index(nameof(AuthorUUID))]
[Index(nameof(ExpiresAt))]
[Index(nameof(Views))]
[Index(nameof(Visibility))]
public sealed class Paste
{
@@ -33,5 +32,7 @@ namespace SharpbinV3.Server.Data.Entities
public int Visibility { get; set; } = 0; // 0 = public, 1 = unlisted, 2 = private (encrypted pastes handled on frontend)
public long ExpiresAt { get; set; } // timestamp of when the paste expires, or 0 for never
public List<PasteView> PasteViews { get; set; } = [];
}
}
@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
namespace SharpbinV3.Server.Data.Entities
{
[Index(nameof(PastePID), nameof(ViewerHash), IsUnique = true)]
public class PasteView
{
[Key]
public int Id { get; set; }
public int PastePID { get; set; }
[MaxLength(64)]
public string ViewerHash { get; set; } = null!;
public long ViewedAt { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
public Paste Paste { get; set; } = null!;
}
}