Reply and forward gone indicator

This commit is contained in:
2025-08-20 02:14:18 +08:00
parent 2e52a13c30
commit ec44b51ab6
5 changed files with 2027 additions and 2 deletions

View File

@@ -48,6 +48,9 @@ public class Post : ModelBase, IIdentifiedResource, IActivity
[NotMapped] public int RepliesCount { get; set; }
[NotMapped] public Dictionary<string, bool>? ReactionsMade { get; set; }
public bool RepliedGone { get; set; }
public bool ForwardedGone { get; set; }
public Guid? RepliedPostId { get; set; }
public Post? RepliedPost { get; set; }
public Guid? ForwardedPostId { get; set; }

View File

@@ -392,8 +392,30 @@ public partial class PostService(
new DeleteResourceReferencesRequest { ResourceId = post.ResourceIdentifier }
);
db.Posts.Remove(post);
await db.SaveChangesAsync();
var now = SystemClock.Instance.GetCurrentInstant();
await using var transaction = await db.Database.BeginTransactionAsync();
try
{
await db.PostReactions
.Where(r => r.PostId == post.Id)
.ExecuteUpdateAsync(p => p.SetProperty(x => x.DeletedAt, now));
await db.Posts
.Where(p => p.RepliedPostId == post.Id)
.ExecuteUpdateAsync(p => p.SetProperty(x => x.RepliedGone, true));
await db.Posts
.Where(p => p.ForwardedPostId == post.Id)
.ExecuteUpdateAsync(p => p.SetProperty(x => x.ForwardedGone, true));
db.Posts.Remove(post);
await db.SaveChangesAsync();
await transaction.CommitAsync();
}
catch (Exception)
{
await transaction.RollbackAsync();
throw;
}
}
/// <summary>