♻️ Remove chat message in app database

This commit is contained in:
2026-01-02 02:00:04 +08:00
parent 913a6e7382
commit 24b1f24dea
6 changed files with 2170 additions and 707 deletions

View File

@@ -31,12 +31,6 @@ public class AppDatabase(
public DbSet<SnPollQuestion> PollQuestions { get; set; } = null!;
public DbSet<SnPollAnswer> PollAnswers { get; set; } = null!;
public DbSet<SnChatRoom> ChatRooms { get; set; } = null!;
public DbSet<SnChatMember> ChatMembers { get; set; } = null!;
public DbSet<SnChatMessage> ChatMessages { get; set; } = null!;
public DbSet<SnRealtimeCall> ChatRealtimeCall { get; set; } = null!;
public DbSet<SnChatReaction> ChatReactions { get; set; } = null!;
public DbSet<SnSticker> Stickers { get; set; } = null!;
public DbSet<StickerPack> StickerPacks { get; set; } = null!;
public DbSet<StickerPackOwnership> StickerPackOwnerships { get; set; } = null!;
@@ -99,36 +93,6 @@ public class AppDatabase(
.WithMany(c => c.Posts)
.UsingEntity(j => j.ToTable("post_collection_links"));
modelBuilder.Entity<SnChatMember>()
.HasKey(pm => new { pm.Id });
modelBuilder.Entity<SnChatMember>()
.HasAlternateKey(pm => new { pm.ChatRoomId, pm.AccountId });
modelBuilder.Entity<SnChatMember>()
.HasOne(pm => pm.ChatRoom)
.WithMany(p => p.Members)
.HasForeignKey(pm => pm.ChatRoomId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<SnChatMessage>()
.HasOne(m => m.ForwardedMessage)
.WithMany()
.HasForeignKey(m => m.ForwardedMessageId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<SnChatMessage>()
.HasOne(m => m.RepliedMessage)
.WithMany()
.HasForeignKey(m => m.RepliedMessageId)
.OnDelete(DeleteBehavior.Restrict);
modelBuilder.Entity<SnRealtimeCall>()
.HasOne(m => m.Room)
.WithMany()
.HasForeignKey(m => m.RoomId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<SnRealtimeCall>()
.HasOne(m => m.Sender)
.WithMany()
.HasForeignKey(m => m.SenderId)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity<SnFediverseActor>()
.HasOne(a => a.Instance)
.WithMany(i => i.Actors)

View File

@@ -48,18 +48,8 @@ public class AutocompletionService(AppDatabase db, RemoteAccountService remoteAc
{
case "u":
var allAccounts = await remoteAccountsHelper.SearchAccounts(query);
var filteredAccounts = allAccounts;
if (chatId.HasValue)
{
var chatMemberIds = await db.ChatMembers
.Where(m => m.ChatRoomId == chatId.Value && m.JoinedAt != null && m.LeaveAt == null)
.Select(m => m.AccountId)
.ToListAsync();
var chatMemberIdStrings = chatMemberIds.Select(id => id.ToString()).ToHashSet();
filteredAccounts = allAccounts.Where(a => chatMemberIdStrings.Contains(a.Id)).ToList();
}
else if (realmId.HasValue)
if (realmId.HasValue)
{
// TODO: Filter to realm members only - needs efficient implementation
// var realmMemberIds = await db.RealmMembers
@@ -70,7 +60,7 @@ public class AutocompletionService(AppDatabase db, RemoteAccountService remoteAc
// filteredAccounts = allAccounts.Where(a => realmMemberIdStrings.Contains(a.Id)).ToList();
}
var users = filteredAccounts
var users = allAccounts
.Take(limit)
.Select(a => new DysonNetwork.Shared.Models.Autocompletion
{
@@ -105,20 +95,6 @@ public class AutocompletionService(AppDatabase db, RemoteAccountService remoteAc
});
results.AddRange(autocompletions);
break;
case "c":
var chats = await db.ChatRooms
.Where(c => c.Name != null && EF.Functions.Like(c.Name, $"{query}%"))
.Take(limit)
.Select(c => new DysonNetwork.Shared.Models.Autocompletion
{
Type = "chat",
Keyword = "@c/" + c.Name,
Data = c
})
.ToListAsync();
results.AddRange(chats);
break;
}
return results;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,363 @@
using System;
using System.Collections.Generic;
using DysonNetwork.Shared.Models;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
/// <inheritdoc />
public partial class RemoveChat : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "chat_reactions");
migrationBuilder.DropTable(
name: "chat_realtime_call");
migrationBuilder.DropTable(
name: "web_articles");
migrationBuilder.DropTable(
name: "web_feed_subscriptions");
migrationBuilder.DropTable(
name: "chat_messages");
migrationBuilder.DropTable(
name: "web_feeds");
migrationBuilder.DropTable(
name: "chat_members");
migrationBuilder.DropTable(
name: "chat_rooms");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "chat_rooms",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
account_id = table.Column<Guid>(type: "uuid", nullable: true),
background = table.Column<SnCloudFileReferenceObject>(type: "jsonb", nullable: true),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
description = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
is_community = table.Column<bool>(type: "boolean", nullable: false),
is_public = table.Column<bool>(type: "boolean", nullable: false),
name = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true),
picture = table.Column<SnCloudFileReferenceObject>(type: "jsonb", nullable: true),
realm_id = table.Column<Guid>(type: "uuid", nullable: true),
type = table.Column<int>(type: "integer", nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_chat_rooms", x => x.id);
});
migrationBuilder.CreateTable(
name: "web_feeds",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
publisher_id = table.Column<Guid>(type: "uuid", nullable: false),
config = table.Column<WebFeedConfig>(type: "jsonb", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
description = table.Column<string>(type: "character varying(8192)", maxLength: 8192, nullable: true),
title = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
url = table.Column<string>(type: "character varying(8192)", maxLength: 8192, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_web_feeds", x => x.id);
table.ForeignKey(
name: "fk_web_feeds_publishers_publisher_id",
column: x => x.publisher_id,
principalTable: "publishers",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "chat_members",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
chat_room_id = table.Column<Guid>(type: "uuid", nullable: false),
invited_by_id = table.Column<Guid>(type: "uuid", nullable: true),
account_id = table.Column<Guid>(type: "uuid", nullable: false),
break_until = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
joined_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
last_read_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
leave_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
nick = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true),
notify = table.Column<int>(type: "integer", nullable: false),
timeout_cause = table.Column<ChatTimeoutCause>(type: "jsonb", nullable: true),
timeout_until = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_chat_members", x => x.id);
table.UniqueConstraint("ak_chat_members_chat_room_id_account_id", x => new { x.chat_room_id, x.account_id });
table.ForeignKey(
name: "fk_chat_members_chat_members_invited_by_id",
column: x => x.invited_by_id,
principalTable: "chat_members",
principalColumn: "id");
table.ForeignKey(
name: "fk_chat_members_chat_rooms_chat_room_id",
column: x => x.chat_room_id,
principalTable: "chat_rooms",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "web_articles",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
feed_id = table.Column<Guid>(type: "uuid", nullable: false),
author = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
content = table.Column<string>(type: "text", nullable: true),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
meta = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
published_at = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
title = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
url = table.Column<string>(type: "character varying(8192)", maxLength: 8192, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_web_articles", x => x.id);
table.ForeignKey(
name: "fk_web_articles_web_feeds_feed_id",
column: x => x.feed_id,
principalTable: "web_feeds",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "web_feed_subscriptions",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
feed_id = table.Column<Guid>(type: "uuid", nullable: false),
account_id = table.Column<Guid>(type: "uuid", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_web_feed_subscriptions", x => x.id);
table.ForeignKey(
name: "fk_web_feed_subscriptions_web_feeds_feed_id",
column: x => x.feed_id,
principalTable: "web_feeds",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "chat_messages",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
chat_room_id = table.Column<Guid>(type: "uuid", nullable: false),
forwarded_message_id = table.Column<Guid>(type: "uuid", nullable: true),
replied_message_id = table.Column<Guid>(type: "uuid", nullable: true),
sender_id = table.Column<Guid>(type: "uuid", nullable: false),
attachments = table.Column<List<SnCloudFileReferenceObject>>(type: "jsonb", nullable: false),
content = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
edited_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
members_mentioned = table.Column<string>(type: "jsonb", nullable: true),
meta = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: true),
nonce = table.Column<string>(type: "character varying(36)", maxLength: 36, nullable: false),
type = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_chat_messages", x => x.id);
table.ForeignKey(
name: "fk_chat_messages_chat_members_sender_id",
column: x => x.sender_id,
principalTable: "chat_members",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_chat_messages_chat_messages_forwarded_message_id",
column: x => x.forwarded_message_id,
principalTable: "chat_messages",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_chat_messages_chat_messages_replied_message_id",
column: x => x.replied_message_id,
principalTable: "chat_messages",
principalColumn: "id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "fk_chat_messages_chat_rooms_chat_room_id",
column: x => x.chat_room_id,
principalTable: "chat_rooms",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "chat_realtime_call",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
room_id = table.Column<Guid>(type: "uuid", nullable: false),
sender_id = table.Column<Guid>(type: "uuid", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
ended_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
provider_name = table.Column<string>(type: "text", nullable: true),
session_id = table.Column<string>(type: "text", nullable: true),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
upstream = table.Column<string>(type: "jsonb", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("pk_chat_realtime_call", x => x.id);
table.ForeignKey(
name: "fk_chat_realtime_call_chat_members_sender_id",
column: x => x.sender_id,
principalTable: "chat_members",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_chat_realtime_call_chat_rooms_room_id",
column: x => x.room_id,
principalTable: "chat_rooms",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "chat_reactions",
columns: table => new
{
id = table.Column<Guid>(type: "uuid", nullable: false),
message_id = table.Column<Guid>(type: "uuid", nullable: false),
sender_id = table.Column<Guid>(type: "uuid", nullable: false),
attitude = table.Column<int>(type: "integer", nullable: false),
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
symbol = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_chat_reactions", x => x.id);
table.ForeignKey(
name: "fk_chat_reactions_chat_members_sender_id",
column: x => x.sender_id,
principalTable: "chat_members",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_chat_reactions_chat_messages_message_id",
column: x => x.message_id,
principalTable: "chat_messages",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_chat_members_invited_by_id",
table: "chat_members",
column: "invited_by_id");
migrationBuilder.CreateIndex(
name: "ix_chat_messages_chat_room_id",
table: "chat_messages",
column: "chat_room_id");
migrationBuilder.CreateIndex(
name: "ix_chat_messages_forwarded_message_id",
table: "chat_messages",
column: "forwarded_message_id");
migrationBuilder.CreateIndex(
name: "ix_chat_messages_replied_message_id",
table: "chat_messages",
column: "replied_message_id");
migrationBuilder.CreateIndex(
name: "ix_chat_messages_sender_id",
table: "chat_messages",
column: "sender_id");
migrationBuilder.CreateIndex(
name: "ix_chat_reactions_message_id",
table: "chat_reactions",
column: "message_id");
migrationBuilder.CreateIndex(
name: "ix_chat_reactions_sender_id",
table: "chat_reactions",
column: "sender_id");
migrationBuilder.CreateIndex(
name: "ix_chat_realtime_call_room_id",
table: "chat_realtime_call",
column: "room_id");
migrationBuilder.CreateIndex(
name: "ix_chat_realtime_call_sender_id",
table: "chat_realtime_call",
column: "sender_id");
migrationBuilder.CreateIndex(
name: "ix_web_articles_feed_id",
table: "web_articles",
column: "feed_id");
migrationBuilder.CreateIndex(
name: "ix_web_articles_url",
table: "web_articles",
column: "url",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_web_feed_subscriptions_feed_id",
table: "web_feed_subscriptions",
column: "feed_id");
migrationBuilder.CreateIndex(
name: "ix_web_feeds_publisher_id",
table: "web_feeds",
column: "publisher_id");
migrationBuilder.CreateIndex(
name: "ix_web_feeds_url",
table: "web_feeds",
column: "url",
unique: true);
}
}
}

View File

@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Text.Json;
using DysonNetwork.Shared.Models;
using DysonNetwork.Sphere;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
@@ -106,281 +105,6 @@ namespace DysonNetwork.Sphere.Migrations
b.ToTable("activity_pub_deliveries", (string)null);
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatMember", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<Guid>("AccountId")
.HasColumnType("uuid")
.HasColumnName("account_id");
b.Property<Instant?>("BreakUntil")
.HasColumnType("timestamp with time zone")
.HasColumnName("break_until");
b.Property<Guid>("ChatRoomId")
.HasColumnType("uuid")
.HasColumnName("chat_room_id");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<Guid?>("InvitedById")
.HasColumnType("uuid")
.HasColumnName("invited_by_id");
b.Property<Instant?>("JoinedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("joined_at");
b.Property<Instant?>("LastReadAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("last_read_at");
b.Property<Instant?>("LeaveAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("leave_at");
b.Property<string>("Nick")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("nick");
b.Property<int>("Notify")
.HasColumnType("integer")
.HasColumnName("notify");
b.Property<ChatTimeoutCause>("TimeoutCause")
.HasColumnType("jsonb")
.HasColumnName("timeout_cause");
b.Property<Instant?>("TimeoutUntil")
.HasColumnType("timestamp with time zone")
.HasColumnName("timeout_until");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_chat_members");
b.HasAlternateKey("ChatRoomId", "AccountId")
.HasName("ak_chat_members_chat_room_id_account_id");
b.HasIndex("InvitedById")
.HasDatabaseName("ix_chat_members_invited_by_id");
b.ToTable("chat_members", (string)null);
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatMessage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<List<SnCloudFileReferenceObject>>("Attachments")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("attachments");
b.Property<Guid>("ChatRoomId")
.HasColumnType("uuid")
.HasColumnName("chat_room_id");
b.Property<string>("Content")
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("content");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<Instant?>("EditedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("edited_at");
b.Property<Guid?>("ForwardedMessageId")
.HasColumnType("uuid")
.HasColumnName("forwarded_message_id");
b.PrimitiveCollection<string>("MembersMentioned")
.HasColumnType("jsonb")
.HasColumnName("members_mentioned");
b.Property<Dictionary<string, object>>("Meta")
.HasColumnType("jsonb")
.HasColumnName("meta");
b.Property<string>("Nonce")
.IsRequired()
.HasMaxLength(36)
.HasColumnType("character varying(36)")
.HasColumnName("nonce");
b.Property<Guid?>("RepliedMessageId")
.HasColumnType("uuid")
.HasColumnName("replied_message_id");
b.Property<Guid>("SenderId")
.HasColumnType("uuid")
.HasColumnName("sender_id");
b.Property<string>("Type")
.IsRequired()
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("type");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_chat_messages");
b.HasIndex("ChatRoomId")
.HasDatabaseName("ix_chat_messages_chat_room_id");
b.HasIndex("ForwardedMessageId")
.HasDatabaseName("ix_chat_messages_forwarded_message_id");
b.HasIndex("RepliedMessageId")
.HasDatabaseName("ix_chat_messages_replied_message_id");
b.HasIndex("SenderId")
.HasDatabaseName("ix_chat_messages_sender_id");
b.ToTable("chat_messages", (string)null);
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatMessageReaction", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<int>("Attitude")
.HasColumnType("integer")
.HasColumnName("attitude");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<Guid>("MessageId")
.HasColumnType("uuid")
.HasColumnName("message_id");
b.Property<Guid>("SenderId")
.HasColumnType("uuid")
.HasColumnName("sender_id");
b.Property<string>("Symbol")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)")
.HasColumnName("symbol");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_chat_reactions");
b.HasIndex("MessageId")
.HasDatabaseName("ix_chat_reactions_message_id");
b.HasIndex("SenderId")
.HasDatabaseName("ix_chat_reactions_sender_id");
b.ToTable("chat_reactions", (string)null);
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatRoom", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<Guid?>("AccountId")
.HasColumnType("uuid")
.HasColumnName("account_id");
b.Property<SnCloudFileReferenceObject>("Background")
.HasColumnType("jsonb")
.HasColumnName("background");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<string>("Description")
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("description");
b.Property<bool>("IsCommunity")
.HasColumnType("boolean")
.HasColumnName("is_community");
b.Property<bool>("IsPublic")
.HasColumnType("boolean")
.HasColumnName("is_public");
b.Property<string>("Name")
.HasMaxLength(1024)
.HasColumnType("character varying(1024)")
.HasColumnName("name");
b.Property<SnCloudFileReferenceObject>("Picture")
.HasColumnType("jsonb")
.HasColumnName("picture");
b.Property<Guid?>("RealmId")
.HasColumnType("uuid")
.HasColumnName("realm_id");
b.Property<int>("Type")
.HasColumnType("integer")
.HasColumnName("type");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_chat_rooms");
b.ToTable("chat_rooms", (string)null);
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnFediverseActor", b =>
{
b.Property<Guid>("Id")
@@ -1531,61 +1255,6 @@ namespace DysonNetwork.Sphere.Migrations
b.ToTable("publisher_subscriptions", (string)null);
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnRealtimeCall", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<Instant?>("EndedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("ended_at");
b.Property<string>("ProviderName")
.HasColumnType("text")
.HasColumnName("provider_name");
b.Property<Guid>("RoomId")
.HasColumnType("uuid")
.HasColumnName("room_id");
b.Property<Guid>("SenderId")
.HasColumnType("uuid")
.HasColumnName("sender_id");
b.Property<string>("SessionId")
.HasColumnType("text")
.HasColumnName("session_id");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.Property<string>("UpstreamConfigJson")
.HasColumnType("jsonb")
.HasColumnName("upstream");
b.HasKey("Id")
.HasName("pk_chat_realtime_call");
b.HasIndex("RoomId")
.HasDatabaseName("ix_chat_realtime_call_room_id");
b.HasIndex("SenderId")
.HasDatabaseName("ix_chat_realtime_call_sender_id");
b.ToTable("chat_realtime_call", (string)null);
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnSticker", b =>
{
b.Property<Guid>("Id")
@@ -1726,167 +1395,6 @@ namespace DysonNetwork.Sphere.Migrations
b.ToTable("sticker_pack_ownerships", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.WebReader.WebArticle", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<string>("Author")
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("author");
b.Property<string>("Content")
.HasColumnType("text")
.HasColumnName("content");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<Guid>("FeedId")
.HasColumnType("uuid")
.HasColumnName("feed_id");
b.Property<Dictionary<string, object>>("Meta")
.HasColumnType("jsonb")
.HasColumnName("meta");
b.Property<DateTime?>("PublishedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("published_at");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("title");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.Property<string>("Url")
.IsRequired()
.HasMaxLength(8192)
.HasColumnType("character varying(8192)")
.HasColumnName("url");
b.HasKey("Id")
.HasName("pk_web_articles");
b.HasIndex("FeedId")
.HasDatabaseName("ix_web_articles_feed_id");
b.HasIndex("Url")
.IsUnique()
.HasDatabaseName("ix_web_articles_url");
b.ToTable("web_articles", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.WebReader.WebFeed", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<WebFeedConfig>("Config")
.IsRequired()
.HasColumnType("jsonb")
.HasColumnName("config");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<string>("Description")
.HasMaxLength(8192)
.HasColumnType("character varying(8192)")
.HasColumnName("description");
b.Property<Guid>("PublisherId")
.HasColumnType("uuid")
.HasColumnName("publisher_id");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(4096)
.HasColumnType("character varying(4096)")
.HasColumnName("title");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.Property<string>("Url")
.IsRequired()
.HasMaxLength(8192)
.HasColumnType("character varying(8192)")
.HasColumnName("url");
b.HasKey("Id")
.HasName("pk_web_feeds");
b.HasIndex("PublisherId")
.HasDatabaseName("ix_web_feeds_publisher_id");
b.HasIndex("Url")
.IsUnique()
.HasDatabaseName("ix_web_feeds_url");
b.ToTable("web_feeds", (string)null);
});
modelBuilder.Entity("DysonNetwork.Sphere.WebReader.WebFeedSubscription", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid")
.HasColumnName("id");
b.Property<Guid>("AccountId")
.HasColumnType("uuid")
.HasColumnName("account_id");
b.Property<Instant>("CreatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("created_at");
b.Property<Instant?>("DeletedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("deleted_at");
b.Property<Guid>("FeedId")
.HasColumnType("uuid")
.HasColumnName("feed_id");
b.Property<Instant>("UpdatedAt")
.HasColumnType("timestamp with time zone")
.HasColumnName("updated_at");
b.HasKey("Id")
.HasName("pk_web_feed_subscriptions");
b.HasIndex("FeedId")
.HasDatabaseName("ix_web_feed_subscriptions_feed_id");
b.ToTable("web_feed_subscriptions", (string)null);
});
modelBuilder.Entity("SnPostSnPostCategory", b =>
{
b.Property<Guid>("CategoriesId")
@@ -1944,83 +1452,6 @@ namespace DysonNetwork.Sphere.Migrations
b.ToTable("post_tag_links", (string)null);
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatMember", b =>
{
b.HasOne("DysonNetwork.Shared.Models.SnChatRoom", "ChatRoom")
.WithMany("Members")
.HasForeignKey("ChatRoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_chat_members_chat_rooms_chat_room_id");
b.HasOne("DysonNetwork.Shared.Models.SnChatMember", "InvitedBy")
.WithMany()
.HasForeignKey("InvitedById")
.HasConstraintName("fk_chat_members_chat_members_invited_by_id");
b.Navigation("ChatRoom");
b.Navigation("InvitedBy");
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatMessage", b =>
{
b.HasOne("DysonNetwork.Shared.Models.SnChatRoom", "ChatRoom")
.WithMany()
.HasForeignKey("ChatRoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_chat_messages_chat_rooms_chat_room_id");
b.HasOne("DysonNetwork.Shared.Models.SnChatMessage", "ForwardedMessage")
.WithMany()
.HasForeignKey("ForwardedMessageId")
.OnDelete(DeleteBehavior.Restrict)
.HasConstraintName("fk_chat_messages_chat_messages_forwarded_message_id");
b.HasOne("DysonNetwork.Shared.Models.SnChatMessage", "RepliedMessage")
.WithMany()
.HasForeignKey("RepliedMessageId")
.OnDelete(DeleteBehavior.Restrict)
.HasConstraintName("fk_chat_messages_chat_messages_replied_message_id");
b.HasOne("DysonNetwork.Shared.Models.SnChatMember", "Sender")
.WithMany()
.HasForeignKey("SenderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_chat_messages_chat_members_sender_id");
b.Navigation("ChatRoom");
b.Navigation("ForwardedMessage");
b.Navigation("RepliedMessage");
b.Navigation("Sender");
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatMessageReaction", b =>
{
b.HasOne("DysonNetwork.Shared.Models.SnChatMessage", "Message")
.WithMany("Reactions")
.HasForeignKey("MessageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_chat_reactions_chat_messages_message_id");
b.HasOne("DysonNetwork.Shared.Models.SnChatMember", "Sender")
.WithMany()
.HasForeignKey("SenderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_chat_reactions_chat_members_sender_id");
b.Navigation("Message");
b.Navigation("Sender");
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnFediverseActor", b =>
{
b.HasOne("DysonNetwork.Shared.Models.SnFediverseInstance", "Instance")
@@ -2231,27 +1662,6 @@ namespace DysonNetwork.Sphere.Migrations
b.Navigation("Publisher");
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnRealtimeCall", b =>
{
b.HasOne("DysonNetwork.Shared.Models.SnChatRoom", "Room")
.WithMany()
.HasForeignKey("RoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_chat_realtime_call_chat_rooms_room_id");
b.HasOne("DysonNetwork.Shared.Models.SnChatMember", "Sender")
.WithMany()
.HasForeignKey("SenderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_chat_realtime_call_chat_members_sender_id");
b.Navigation("Room");
b.Navigation("Sender");
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnSticker", b =>
{
b.HasOne("DysonNetwork.Shared.Models.StickerPack", "Pack")
@@ -2288,42 +1698,6 @@ namespace DysonNetwork.Sphere.Migrations
b.Navigation("Pack");
});
modelBuilder.Entity("DysonNetwork.Sphere.WebReader.WebArticle", b =>
{
b.HasOne("DysonNetwork.Sphere.WebReader.WebFeed", "Feed")
.WithMany("Articles")
.HasForeignKey("FeedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_web_articles_web_feeds_feed_id");
b.Navigation("Feed");
});
modelBuilder.Entity("DysonNetwork.Sphere.WebReader.WebFeed", b =>
{
b.HasOne("DysonNetwork.Shared.Models.SnPublisher", "Publisher")
.WithMany()
.HasForeignKey("PublisherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_web_feeds_publishers_publisher_id");
b.Navigation("Publisher");
});
modelBuilder.Entity("DysonNetwork.Sphere.WebReader.WebFeedSubscription", b =>
{
b.HasOne("DysonNetwork.Sphere.WebReader.WebFeed", "Feed")
.WithMany()
.HasForeignKey("FeedId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_web_feed_subscriptions_web_feeds_feed_id");
b.Navigation("Feed");
});
modelBuilder.Entity("SnPostSnPostCategory", b =>
{
b.HasOne("DysonNetwork.Shared.Models.SnPostCategory", null)
@@ -2375,16 +1749,6 @@ namespace DysonNetwork.Sphere.Migrations
.HasConstraintName("fk_post_tag_links_post_tags_tags_id");
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatMessage", b =>
{
b.Navigation("Reactions");
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnChatRoom", b =>
{
b.Navigation("Members");
});
modelBuilder.Entity("DysonNetwork.Shared.Models.SnFediverseActor", b =>
{
b.Navigation("FollowerRelationships");
@@ -2432,11 +1796,6 @@ namespace DysonNetwork.Sphere.Migrations
b.Navigation("Stickers");
});
modelBuilder.Entity("DysonNetwork.Sphere.WebReader.WebFeed", b =>
{
b.Navigation("Articles");
});
#pragma warning restore 612, 618
}
}

View File

@@ -125,10 +125,6 @@ public class BroadcastEventHandler(
using var scope = serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDatabase>();
await db.ChatMembers
.Where(m => m.AccountId == evt.AccountId)
.ExecuteDeleteAsync(cancellationToken: stoppingToken);
await using var transaction = await db.Database.BeginTransactionAsync(cancellationToken: stoppingToken);
try
{