✨ File compression duplicate
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using DysonNetwork.Sphere.Storage;
|
||||
using NodaTime;
|
||||
using NpgsqlTypes;
|
||||
|
||||
namespace DysonNetwork.Sphere.Post;
|
||||
|
||||
@ -31,8 +33,7 @@ public class Post : ModelBase
|
||||
public Instant? PublishedAt { get; set; }
|
||||
public PostVisibility Visibility { get; set; } = PostVisibility.Public;
|
||||
|
||||
// ReSharper disable once EntityFramework.ModelValidation.UnlimitedStringLength
|
||||
public string? Content { get; set; }
|
||||
[Column(TypeName = "jsonb")] public JsonDocument? Content { get; set; }
|
||||
|
||||
public PostType Type { get; set; }
|
||||
[Column(TypeName = "jsonb")] public Dictionary<string, object>? Meta { get; set; }
|
||||
@ -49,6 +50,8 @@ public class Post : ModelBase
|
||||
public long? ForwardedPostId { get; set; }
|
||||
public Post? ForwardedPost { get; set; }
|
||||
public ICollection<CloudFile> Attachments { get; set; } = new List<CloudFile>();
|
||||
|
||||
public NpgsqlTsVector SearchVector { get; set; }
|
||||
|
||||
public Publisher Publisher { get; set; } = null!;
|
||||
public ICollection<PostReaction> Reactions { get; set; } = new List<PostReaction>();
|
||||
@ -56,7 +59,7 @@ public class Post : ModelBase
|
||||
public ICollection<PostCategory> Categories { get; set; } = new List<PostCategory>();
|
||||
public ICollection<PostCollection> Collections { get; set; } = new List<PostCollection>();
|
||||
|
||||
public bool Empty => Content?.Trim() is { Length: 0 } && Attachments.Count == 0 && ForwardedPostId == null;
|
||||
public bool Empty => Content == null && Attachments.Count == 0 && ForwardedPostId == null;
|
||||
}
|
||||
|
||||
public class PostTag : ModelBase
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json;
|
||||
using Casbin;
|
||||
using DysonNetwork.Sphere.Account;
|
||||
using DysonNetwork.Sphere.Permission;
|
||||
@ -17,7 +18,7 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
{
|
||||
HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue);
|
||||
var currentUser = currentUserValue as Account.Account;
|
||||
var userFriends = await rels.ListAccountFriends(currentUser!);
|
||||
var userFriends = currentUser is null ? [] : await rels.ListAccountFriends(currentUser);
|
||||
|
||||
var totalCount = await db.Posts
|
||||
.FilterWithVisibility(currentUser, userFriends, isListing: true)
|
||||
@ -48,7 +49,7 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
{
|
||||
HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue);
|
||||
var currentUser = currentUserValue as Account.Account;
|
||||
var userFriends = await rels.ListAccountFriends(currentUser!);
|
||||
var userFriends = currentUser is null ? [] : await rels.ListAccountFriends(currentUser);
|
||||
|
||||
var post = await db.Posts
|
||||
.Where(e => e.Id == id)
|
||||
@ -74,7 +75,7 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
{
|
||||
HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue);
|
||||
var currentUser = currentUserValue as Account.Account;
|
||||
var userFriends = await rels.ListAccountFriends(currentUser!);
|
||||
var userFriends = currentUser is null ? [] : await rels.ListAccountFriends(currentUser);
|
||||
|
||||
var post = await db.Posts
|
||||
.Where(e => e.Id == id)
|
||||
@ -110,7 +111,7 @@ public class PostController(AppDatabase db, PostService ps, RelationshipService
|
||||
{
|
||||
[MaxLength(1024)] public string? Title { get; set; }
|
||||
[MaxLength(4096)] public string? Description { get; set; }
|
||||
public string? Content { get; set; }
|
||||
public JsonDocument? Content { get; set; }
|
||||
public PostVisibility? Visibility { get; set; }
|
||||
public PostType? Type { get; set; }
|
||||
[MaxLength(16)] public List<string>? Tags { get; set; }
|
||||
|
@ -102,9 +102,7 @@ public class PublisherController(AppDatabase db, PublisherService ps, FileServic
|
||||
|
||||
var newMember = new PublisherMember
|
||||
{
|
||||
Account = relatedUser,
|
||||
AccountId = relatedUser.Id,
|
||||
Publisher = publisher,
|
||||
PublisherId = publisher.Id,
|
||||
Role = request.Role,
|
||||
};
|
||||
|
@ -22,13 +22,12 @@ public class PublisherService(AppDatabase db, FileService fs)
|
||||
Bio = bio ?? account.Profile.Bio,
|
||||
Picture = picture ?? account.Profile.Picture,
|
||||
Background = background ?? account.Profile.Background,
|
||||
Account = account,
|
||||
AccountId = account.Id,
|
||||
Members = new List<PublisherMember>
|
||||
{
|
||||
new()
|
||||
{
|
||||
AccountId = account.Id,
|
||||
Account = account,
|
||||
Role = PublisherMemberRole.Owner,
|
||||
JoinedAt = Instant.FromDateTimeUtc(DateTime.UtcNow)
|
||||
}
|
||||
|
Reference in New Issue
Block a user