✨ Reply and forward gone indicator
This commit is contained in:
@@ -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; }
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user