mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
feat: paste views; configuration validation; hmacsha256 method; enhance paste clean up serivce; paste view clean up service;
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user