✨ Reply and forward gone indicator
This commit is contained in:
1952
DysonNetwork.Sphere/Migrations/20250819175925_AddPostParentGone.Designer.cs
generated
Normal file
1952
DysonNetwork.Sphere/Migrations/20250819175925_AddPostParentGone.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DysonNetwork.Sphere.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddPostParentGone : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "forwarded_gone",
|
||||||
|
table: "posts",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "replied_gone",
|
||||||
|
table: "posts",
|
||||||
|
type: "boolean",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "forwarded_gone",
|
||||||
|
table: "posts");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "replied_gone",
|
||||||
|
table: "posts");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -554,6 +554,10 @@ namespace DysonNetwork.Sphere.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasColumnName("edited_at");
|
.HasColumnName("edited_at");
|
||||||
|
|
||||||
|
b.Property<bool>("ForwardedGone")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("forwarded_gone");
|
||||||
|
|
||||||
b.Property<Guid?>("ForwardedPostId")
|
b.Property<Guid?>("ForwardedPostId")
|
||||||
.HasColumnType("uuid")
|
.HasColumnType("uuid")
|
||||||
.HasColumnName("forwarded_post_id");
|
.HasColumnName("forwarded_post_id");
|
||||||
@@ -574,6 +578,10 @@ namespace DysonNetwork.Sphere.Migrations
|
|||||||
.HasColumnType("uuid")
|
.HasColumnType("uuid")
|
||||||
.HasColumnName("realm_id");
|
.HasColumnName("realm_id");
|
||||||
|
|
||||||
|
b.Property<bool>("RepliedGone")
|
||||||
|
.HasColumnType("boolean")
|
||||||
|
.HasColumnName("replied_gone");
|
||||||
|
|
||||||
b.Property<Guid?>("RepliedPostId")
|
b.Property<Guid?>("RepliedPostId")
|
||||||
.HasColumnType("uuid")
|
.HasColumnType("uuid")
|
||||||
.HasColumnName("replied_post_id");
|
.HasColumnName("replied_post_id");
|
||||||
|
@@ -48,6 +48,9 @@ public class Post : ModelBase, IIdentifiedResource, IActivity
|
|||||||
[NotMapped] public int RepliesCount { get; set; }
|
[NotMapped] public int RepliesCount { get; set; }
|
||||||
[NotMapped] public Dictionary<string, bool>? ReactionsMade { 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 Guid? RepliedPostId { get; set; }
|
||||||
public Post? RepliedPost { get; set; }
|
public Post? RepliedPost { get; set; }
|
||||||
public Guid? ForwardedPostId { get; set; }
|
public Guid? ForwardedPostId { get; set; }
|
||||||
|
@@ -392,8 +392,30 @@ public partial class PostService(
|
|||||||
new DeleteResourceReferencesRequest { ResourceId = post.ResourceIdentifier }
|
new DeleteResourceReferencesRequest { ResourceId = post.ResourceIdentifier }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
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);
|
db.Posts.Remove(post);
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
|
await transaction.CommitAsync();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await transaction.RollbackAsync();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Reference in New Issue
Block a user