diff --git a/Iceshrimp.Backend/Controllers/Mastodon/ConversationsController.cs b/Iceshrimp.Backend/Controllers/Mastodon/ConversationsController.cs index ea71fb09..a44e0b39 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/ConversationsController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/ConversationsController.cs @@ -42,10 +42,10 @@ public class ConversationsController( .IncludeCommonProperties() .FilterHiddenConversations(user, db) .FilterMutedThreads(user, db) - .Paginate(p => p.ThreadId ?? p.Id, pq, ControllerContext) + .Paginate(p => p.ThreadIdOrId, pq, ControllerContext) .Select(p => new Conversation { - Id = p.ThreadId ?? p.Id, + Id = p.ThreadIdOrId, LastNote = p, UserIds = p.VisibleUserIds, Unread = db.Notifications.Any(n => n.Note == p && @@ -96,10 +96,10 @@ public class ConversationsController( var user = HttpContext.GetUserOrFail(); var conversation = await db.Conversations(user) .IncludeCommonProperties() - .Where(p => (p.ThreadId ?? p.Id) == id) + .Where(p => (p.ThreadIdOrId) == id) .Select(p => new Conversation { - Id = p.ThreadId ?? p.Id, + Id = p.ThreadIdOrId, LastNote = p, UserIds = p.VisibleUserIds, Unread = db.Notifications.Any(n => n.Note == p && diff --git a/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs b/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs index 29d9ebb8..90105a51 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs @@ -627,7 +627,7 @@ public class StatusController( var user = HttpContext.GetUserOrFail(); var target = await db.Notes.Where(p => p.Id == id) .EnsureVisibleFor(user) - .Select(p => p.ThreadId ?? p.Id) + .Select(p => p.ThreadIdOrId) .FirstOrDefaultAsync() ?? throw GracefulException.RecordNotFound(); @@ -652,7 +652,7 @@ public class StatusController( var user = HttpContext.GetUserOrFail(); var target = await db.Notes.Where(p => p.Id == id) .EnsureVisibleFor(user) - .Select(p => p.ThreadId ?? p.Id) + .Select(p => p.ThreadIdOrId) .FirstOrDefaultAsync() ?? throw GracefulException.RecordNotFound(); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/DirectChannel.cs b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/DirectChannel.cs index 0f408168..7680396b 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/DirectChannel.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Streaming/Channels/DirectChannel.cs @@ -91,7 +91,7 @@ public class DirectChannel(WebSocketConnection connection) : IChannel return new ConversationEntity { Accounts = accounts.ToList(), - Id = note.ThreadId ?? note.Id, + Id = note.ThreadIdOrId, LastStatus = rendered, Unread = true }; diff --git a/Iceshrimp.Backend/Controllers/Web/MiscController.cs b/Iceshrimp.Backend/Controllers/Web/MiscController.cs index b2f1bd74..390da0d9 100644 --- a/Iceshrimp.Backend/Controllers/Web/MiscController.cs +++ b/Iceshrimp.Backend/Controllers/Web/MiscController.cs @@ -28,7 +28,7 @@ public class MiscController(DatabaseContext db, NoteRenderer noteRenderer) : Con { var user = HttpContext.GetUserOrFail(); var notes = await db.Notes.IncludeCommonProperties() - .Where(p => db.NoteThreadMutings.Any(m => m.ThreadId == (p.ThreadId ?? p.Id))) + .Where(p => db.NoteThreadMutings.Any(m => m.ThreadId == p.ThreadIdOrId)) .EnsureVisibleFor(user) .FilterHidden(user, db, false, false) .Paginate(pq, ControllerContext) diff --git a/Iceshrimp.Backend/Controllers/Web/NoteController.cs b/Iceshrimp.Backend/Controllers/Web/NoteController.cs index 64e1dd75..1c97a115 100644 --- a/Iceshrimp.Backend/Controllers/Web/NoteController.cs +++ b/Iceshrimp.Backend/Controllers/Web/NoteController.cs @@ -347,7 +347,7 @@ public class NoteController( var user = HttpContext.GetUserOrFail(); var target = await db.Notes.Where(p => p.Id == id) .EnsureVisibleFor(user) - .Select(p => p.ThreadId ?? p.Id) + .Select(p => p.ThreadIdOrId) .FirstOrDefaultAsync() ?? throw GracefulException.NotFound("Note not found"); @@ -373,7 +373,7 @@ public class NoteController( var user = HttpContext.GetUserOrFail(); var target = await db.Notes.Where(p => p.Id == id) .EnsureVisibleFor(user) - .Select(p => p.ThreadId ?? p.Id) + .Select(p => p.ThreadIdOrId) .FirstOrDefaultAsync() ?? throw GracefulException.NotFound("Note not found"); diff --git a/Iceshrimp.Backend/Core/Database/Tables/Note.cs b/Iceshrimp.Backend/Core/Database/Tables/Note.cs index b1438c7b..d218b896 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Note.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Note.cs @@ -201,7 +201,7 @@ public class Note : IEntity [StringLength(256)] public string? ThreadId { get; set; } - [NotMapped] public string ThreadIdOrId => ThreadId ?? Id; + [Projectable] [NotMapped] public string ThreadIdOrId => ThreadId ?? Id; /// /// The updated date of the Note. diff --git a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs index f965c3ec..2836b70e 100644 --- a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs @@ -353,7 +353,7 @@ public static class QueryableExtensions public static IQueryable FilterMutedThreads(this IQueryable query, User user, DatabaseContext db) { - return query.Where(p => !db.NoteThreadMutings.Any(m => m.User == user && m.ThreadId == (p.ThreadId ?? p.Id))); + return query.Where(p => !db.NoteThreadMutings.Any(m => m.User == user && m.ThreadId == p.ThreadIdOrId)); } public static IQueryable FilterMutedThreads( @@ -361,7 +361,7 @@ public static class QueryableExtensions ) { return query.Where(p => p.Note == null || - !db.NoteThreadMutings.Any(m => m.User == user && m.ThreadId == (p.Note.ThreadId ?? p.Note.Id))); + !db.NoteThreadMutings.Any(m => m.User == user && m.ThreadId == p.Note.ThreadIdOrId)); } private static (IQueryable hidden, IQueryable? mentionsHidden) FilterHiddenInternal( diff --git a/Iceshrimp.Backend/Core/Services/NoteService.cs b/Iceshrimp.Backend/Core/Services/NoteService.cs index 4aba7428..11a34475 100644 --- a/Iceshrimp.Backend/Core/Services/NoteService.cs +++ b/Iceshrimp.Backend/Core/Services/NoteService.cs @@ -214,7 +214,7 @@ public class NoteService( Mentions = mentionedUserIds, VisibleUserIds = visibleUserIds, MentionedRemoteUsers = remoteMentions, - ThreadId = reply?.ThreadId ?? reply?.Id, + ThreadId = reply?.ThreadIdOrId, Tags = tags, LocalOnly = localOnly, Emojis = emoji ?? [],