💥 Switch all id to uuid
This commit is contained in:
@ -25,7 +25,7 @@ public enum PostVisibility
|
||||
|
||||
public class Post : ModelBase
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(1024)] public string? Title { get; set; }
|
||||
[MaxLength(4096)] public string? Description { get; set; }
|
||||
[MaxLength(128)] public string? Language { get; set; }
|
||||
@ -45,11 +45,11 @@ public class Post : ModelBase
|
||||
public int Downvotes { get; set; }
|
||||
[NotMapped] public Dictionary<string, int> ReactionsCount { get; set; } = new();
|
||||
|
||||
public long? ThreadedPostId { get; set; }
|
||||
public Guid? ThreadedPostId { get; set; }
|
||||
public Post? ThreadedPost { get; set; }
|
||||
public long? RepliedPostId { get; set; }
|
||||
public Guid? RepliedPostId { get; set; }
|
||||
public Post? RepliedPost { get; set; }
|
||||
public long? ForwardedPostId { get; set; }
|
||||
public Guid? ForwardedPostId { get; set; }
|
||||
public Post? ForwardedPost { get; set; }
|
||||
public ICollection<CloudFile> Attachments { get; set; } = new List<CloudFile>();
|
||||
|
||||
@ -67,7 +67,7 @@ public class Post : ModelBase
|
||||
|
||||
public class PostTag : ModelBase
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(128)] public string Slug { get; set; } = null!;
|
||||
[MaxLength(256)] public string? Name { get; set; }
|
||||
public ICollection<Post> Posts { get; set; } = new List<Post>();
|
||||
@ -75,7 +75,7 @@ public class PostTag : ModelBase
|
||||
|
||||
public class PostCategory : ModelBase
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(128)] public string Slug { get; set; } = null!;
|
||||
[MaxLength(256)] public string? Name { get; set; }
|
||||
public ICollection<Post> Posts { get; set; } = new List<Post>();
|
||||
@ -83,7 +83,7 @@ public class PostCategory : ModelBase
|
||||
|
||||
public class PostCollection : ModelBase
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(128)] public string Slug { get; set; } = null!;
|
||||
[MaxLength(256)] public string? Name { get; set; }
|
||||
[MaxLength(4096)] public string? Description { get; set; }
|
||||
@ -102,12 +102,12 @@ public enum PostReactionAttitude
|
||||
|
||||
public class PostReaction : ModelBase
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
[MaxLength(256)] public string Symbol { get; set; } = null!;
|
||||
public PostReactionAttitude Attitude { get; set; }
|
||||
|
||||
public long PostId { get; set; }
|
||||
public Guid PostId { get; set; }
|
||||
[JsonIgnore] public Post Post { get; set; } = null!;
|
||||
public long AccountId { get; set; }
|
||||
public Guid AccountId { get; set; }
|
||||
public Account.Account Account { get; set; } = null!;
|
||||
}
|
||||
}
|
@ -58,8 +58,8 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
return Ok(posts);
|
||||
}
|
||||
|
||||
[HttpGet("{id:long}")]
|
||||
public async Task<ActionResult<Post>> GetPost(long id)
|
||||
[HttpGet("{id:guid}")]
|
||||
public async Task<ActionResult<Post>> GetPost(Guid id)
|
||||
{
|
||||
HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue);
|
||||
var currentUser = currentUserValue as Account.Account;
|
||||
@ -83,8 +83,8 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
return Ok(post);
|
||||
}
|
||||
|
||||
[HttpGet("{id:long}/replies")]
|
||||
public async Task<ActionResult<List<Post>>> ListReplies(long id, [FromQuery] int offset = 0,
|
||||
[HttpGet("{id:guid}/replies")]
|
||||
public async Task<ActionResult<List<Post>>> ListReplies(Guid id, [FromQuery] int offset = 0,
|
||||
[FromQuery] int take = 20)
|
||||
{
|
||||
HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue);
|
||||
@ -137,8 +137,8 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
[MaxLength(32)] public List<string>? Attachments { get; set; }
|
||||
public Dictionary<string, object>? Meta { get; set; }
|
||||
public Instant? PublishedAt { get; set; }
|
||||
public long? RepliedPostId { get; set; }
|
||||
public long? ForwardedPostId { get; set; }
|
||||
public Guid? RepliedPostId { get; set; }
|
||||
public Guid? ForwardedPostId { get; set; }
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -230,10 +230,10 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
public PostReactionAttitude Attitude { get; set; }
|
||||
}
|
||||
|
||||
[HttpPost("{id:long}/reactions")]
|
||||
[HttpPost("{id:guid}/reactions")]
|
||||
[Authorize]
|
||||
[RequiredPermission("global", "posts.react")]
|
||||
public async Task<ActionResult<PostReaction>> ReactPost(long id, [FromBody] PostReactionRequest request)
|
||||
public async Task<ActionResult<PostReaction>> ReactPost(Guid id, [FromBody] PostReactionRequest request)
|
||||
{
|
||||
HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue);
|
||||
if (currentUserValue is not Account.Account currentUser) return Unauthorized();
|
||||
@ -265,8 +265,8 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
return Ok(reaction);
|
||||
}
|
||||
|
||||
[HttpPatch("{id:long}")]
|
||||
public async Task<ActionResult<Post>> UpdatePost(long id, [FromBody] PostRequest request)
|
||||
[HttpPatch("{id:guid}")]
|
||||
public async Task<ActionResult<Post>> UpdatePost(Guid id, [FromBody] PostRequest request)
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized();
|
||||
|
||||
@ -312,8 +312,8 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
return Ok(post);
|
||||
}
|
||||
|
||||
[HttpDelete("{id:long}")]
|
||||
public async Task<ActionResult<Post>> DeletePost(long id)
|
||||
[HttpDelete("{id:guid}")]
|
||||
public async Task<ActionResult<Post>> DeletePost(Guid id)
|
||||
{
|
||||
if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized();
|
||||
|
||||
|
@ -215,7 +215,7 @@ public class PostService(AppDatabase db, FileService fs, ActivityService act)
|
||||
return isRemoving;
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, int>> GetPostReactionMap(long postId)
|
||||
public async Task<Dictionary<string, int>> GetPostReactionMap(Guid postId)
|
||||
{
|
||||
return await db.Set<PostReaction>()
|
||||
.Where(r => r.PostId == postId)
|
||||
@ -226,7 +226,7 @@ public class PostService(AppDatabase db, FileService fs, ActivityService act)
|
||||
);
|
||||
}
|
||||
|
||||
public async Task<Dictionary<long, Dictionary<string, int>>> GetPostReactionMapBatch(List<long> postIds)
|
||||
public async Task<Dictionary<Guid, Dictionary<string, int>>> GetPostReactionMapBatch(List<Guid> postIds)
|
||||
{
|
||||
return await db.Set<PostReaction>()
|
||||
.Where(r => postIds.Contains(r.PostId))
|
||||
@ -245,7 +245,7 @@ public class PostService(AppDatabase db, FileService fs, ActivityService act)
|
||||
public static class PostQueryExtensions
|
||||
{
|
||||
public static IQueryable<Post> FilterWithVisibility(this IQueryable<Post> source, Account.Account? currentUser,
|
||||
List<long> userFriends, bool isListing = false)
|
||||
List<Guid> userFriends, bool isListing = false)
|
||||
{
|
||||
var now = Instant.FromDateTimeUtc(DateTime.UtcNow);
|
||||
|
||||
|
@ -16,7 +16,7 @@ public enum PublisherType
|
||||
[Index(nameof(Name), IsUnique = true)]
|
||||
public class Publisher : ModelBase
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public Guid Id { get; set; }
|
||||
public PublisherType PublisherType { get; set; }
|
||||
[MaxLength(256)] public string Name { get; set; } = string.Empty;
|
||||
[MaxLength(256)] public string Nick { get; set; } = string.Empty;
|
||||
@ -34,9 +34,9 @@ public class Publisher : ModelBase
|
||||
[JsonIgnore]
|
||||
public ICollection<PublisherSubscription> Subscriptions { get; set; } = new List<PublisherSubscription>();
|
||||
|
||||
public long? AccountId { get; set; }
|
||||
public Guid? AccountId { get; set; }
|
||||
[JsonIgnore] public Account.Account? Account { get; set; }
|
||||
public long? RealmId { get; set; }
|
||||
public Guid? RealmId { get; set; }
|
||||
[JsonIgnore] public Realm.Realm? Realm { get; set; }
|
||||
}
|
||||
|
||||
@ -50,9 +50,9 @@ public enum PublisherMemberRole
|
||||
|
||||
public class PublisherMember : ModelBase
|
||||
{
|
||||
public long PublisherId { get; set; }
|
||||
public Guid PublisherId { get; set; }
|
||||
[JsonIgnore] public Publisher Publisher { get; set; } = null!;
|
||||
public long AccountId { get; set; }
|
||||
public Guid AccountId { get; set; }
|
||||
[JsonIgnore] public Account.Account Account { get; set; } = null!;
|
||||
|
||||
public PublisherMemberRole Role { get; set; } = PublisherMemberRole.Viewer;
|
||||
@ -70,9 +70,9 @@ public class PublisherSubscription : ModelBase
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public long PublisherId { get; set; }
|
||||
public Guid PublisherId { get; set; }
|
||||
[JsonIgnore] public Publisher Publisher { get; set; } = null!;
|
||||
public long AccountId { get; set; }
|
||||
public Guid AccountId { get; set; }
|
||||
[JsonIgnore] public Account.Account Account { get; set; } = null!;
|
||||
|
||||
public SubscriptionStatus Status { get; set; } = SubscriptionStatus.Active;
|
||||
|
@ -16,7 +16,7 @@ public class PublisherSubscriptionController(
|
||||
public class SubscriptionStatusResponse
|
||||
{
|
||||
public bool IsSubscribed { get; set; }
|
||||
public long PublisherId { get; set; }
|
||||
public Guid PublisherId { get; set; }
|
||||
public string PublisherName { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class PublisherSubscriptionService(AppDatabase db, NotificationService nt
|
||||
/// <param name="accountId">The account ID</param>
|
||||
/// <param name="publisherId">The publisher ID</param>
|
||||
/// <returns>True if a subscription exists, false otherwise</returns>
|
||||
public async Task<bool> SubscriptionExistsAsync(long accountId, long publisherId)
|
||||
public async Task<bool> SubscriptionExistsAsync(Guid accountId, Guid publisherId)
|
||||
{
|
||||
return await db.PublisherSubscriptions
|
||||
.AnyAsync(ps => ps.AccountId == accountId &&
|
||||
@ -26,7 +26,7 @@ public class PublisherSubscriptionService(AppDatabase db, NotificationService nt
|
||||
/// <param name="accountId">The account ID</param>
|
||||
/// <param name="publisherId">The publisher ID</param>
|
||||
/// <returns>The subscription or null if not found</returns>
|
||||
public async Task<PublisherSubscription?> GetSubscriptionAsync(long accountId, long publisherId)
|
||||
public async Task<PublisherSubscription?> GetSubscriptionAsync(Guid accountId, Guid publisherId)
|
||||
{
|
||||
return await db.PublisherSubscriptions
|
||||
.Include(ps => ps.Publisher)
|
||||
@ -95,7 +95,7 @@ public class PublisherSubscriptionService(AppDatabase db, NotificationService nt
|
||||
/// </summary>
|
||||
/// <param name="accountId">The account ID</param>
|
||||
/// <returns>A list of active subscriptions</returns>
|
||||
public async Task<List<PublisherSubscription>> GetAccountSubscriptionsAsync(long accountId)
|
||||
public async Task<List<PublisherSubscription>> GetAccountSubscriptionsAsync(Guid accountId)
|
||||
{
|
||||
return await db.PublisherSubscriptions
|
||||
.Include(ps => ps.Publisher)
|
||||
@ -108,7 +108,7 @@ public class PublisherSubscriptionService(AppDatabase db, NotificationService nt
|
||||
/// </summary>
|
||||
/// <param name="publisherId">The publisher ID</param>
|
||||
/// <returns>A list of active subscriptions</returns>
|
||||
public async Task<List<PublisherSubscription>> GetPublisherSubscribersAsync(long publisherId)
|
||||
public async Task<List<PublisherSubscription>> GetPublisherSubscribersAsync(Guid publisherId)
|
||||
{
|
||||
return await db.PublisherSubscriptions
|
||||
.Include(ps => ps.Account)
|
||||
@ -124,8 +124,8 @@ public class PublisherSubscriptionService(AppDatabase db, NotificationService nt
|
||||
/// <param name="tier">Optional subscription tier</param>
|
||||
/// <returns>The created subscription</returns>
|
||||
public async Task<PublisherSubscription> CreateSubscriptionAsync(
|
||||
long accountId,
|
||||
long publisherId,
|
||||
Guid accountId,
|
||||
Guid publisherId,
|
||||
int tier = 0
|
||||
)
|
||||
{
|
||||
@ -166,7 +166,7 @@ public class PublisherSubscriptionService(AppDatabase db, NotificationService nt
|
||||
/// <param name="accountId">The account ID</param>
|
||||
/// <param name="publisherId">The publisher ID</param>
|
||||
/// <returns>True if the subscription was cancelled, false if it wasn't found</returns>
|
||||
public async Task<bool> CancelSubscriptionAsync(long accountId, long publisherId)
|
||||
public async Task<bool> CancelSubscriptionAsync(Guid accountId, Guid publisherId)
|
||||
{
|
||||
var subscription = await GetSubscriptionAsync(accountId, publisherId);
|
||||
if (subscription is not { Status: SubscriptionStatus.Active })
|
||||
|
Reference in New Issue
Block a user