mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
i think this fixes it
This commit is contained in:
@@ -326,3 +326,4 @@ FodyWeavers.xsd
|
|||||||
**/*.sqlite
|
**/*.sqlite
|
||||||
|
|
||||||
Data
|
Data
|
||||||
|
!SharpbinV3.Server/Data
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SharpbinV3.Server.Data.Entities;
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Data
|
||||||
|
{
|
||||||
|
public sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
|
||||||
|
{
|
||||||
|
public DbSet<User> Users => Set<User>();
|
||||||
|
public DbSet<Paste> Pastes => Set<Paste>();
|
||||||
|
public DbSet<RefreshToken> RefreshTokens => Set<RefreshToken>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Data.Entities
|
||||||
|
{
|
||||||
|
[Index(nameof(PID), IsUnique = true)]
|
||||||
|
[Index(nameof(UUID), IsUnique = true)]
|
||||||
|
[Index(nameof(ID), IsUnique = true)]
|
||||||
|
[Index(nameof(AuthorUUID))]
|
||||||
|
[Index(nameof(ExpiresAt))]
|
||||||
|
[Index(nameof(Views))]
|
||||||
|
[Index(nameof(Visibility))]
|
||||||
|
public sealed class Paste
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int PID { get; set; }
|
||||||
|
public required Guid UUID { get; set; } // uuid v7 includes timestamp, this counts as created at
|
||||||
|
public required string ID { get; set; }
|
||||||
|
public string? Title { get; set; }
|
||||||
|
|
||||||
|
public required Guid AuthorUUID { get; set; } = Guid.Empty; // uuid of the user who created the paste, or Guid.Empty for anonymous pastes
|
||||||
|
public User? User { get; set; }
|
||||||
|
|
||||||
|
public long? EditedAt { get; set; }
|
||||||
|
|
||||||
|
public required byte[] Content { get; set; }
|
||||||
|
public long Size { get; set; } // stored size (may be compressed)
|
||||||
|
public long TrueSize { get; set; } // uncompressed size
|
||||||
|
public bool IsCompressed { get; set; } = false;
|
||||||
|
|
||||||
|
public int Views { get; set; }
|
||||||
|
public string? Syntax { get; set; }
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Data.Entities
|
||||||
|
{
|
||||||
|
public sealed class RefreshToken
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public Guid UserUUID { get; set; }
|
||||||
|
public required string Token { get; set; }
|
||||||
|
public required string JwtId { get; set; }
|
||||||
|
public required long CreatedAt { get; set; }
|
||||||
|
public required long ExpiresAt { get; set; }
|
||||||
|
public bool Used { get; set; } = false;
|
||||||
|
public User? User { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace SharpbinV3.Server.Data.Entities
|
||||||
|
{
|
||||||
|
[Index(nameof(UUID), IsUnique = true)]
|
||||||
|
public sealed class User
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int UID { get; set; }
|
||||||
|
public required Guid UUID { get; set; } = Guid.CreateVersion7(); // uuid v7 includes timestamp
|
||||||
|
public required string Username { get; set; }
|
||||||
|
public required string PasswordHash { get; set; }
|
||||||
|
public string? Email { get; set; }
|
||||||
|
public string? DisplayName { get; set; }
|
||||||
|
public long? LastLogin { get; set; }
|
||||||
|
public int[] Roles { get; set; } = [0]; // 0 = regular user, 1 = moderator, 255 = admin
|
||||||
|
public int Visibility { get; set; } = 0; // 0 = public, 1 = unlisted, 2 = private
|
||||||
|
public List<Paste> Pastes { get; set; } = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user