diff --git a/Iceshrimp.Backend/Controllers/Mastodon/MastodonTimelineController.cs b/Iceshrimp.Backend/Controllers/Mastodon/MastodonTimelineController.cs index fe36f0fc..4d762dcc 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/MastodonTimelineController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/MastodonTimelineController.cs @@ -1,15 +1,12 @@ -using Iceshrimp.Backend.Controllers.Attributes; using Iceshrimp.Backend.Controllers.Mastodon.Renderers; using Iceshrimp.Backend.Controllers.Mastodon.Schemas; using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities; using Iceshrimp.Backend.Core.Database; using Iceshrimp.Backend.Core.Database.Tables; using Iceshrimp.Backend.Core.Extensions; -using Iceshrimp.Backend.Core.Helpers; using Iceshrimp.Backend.Core.Middleware; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.RateLimiting; -using Microsoft.EntityFrameworkCore; namespace Iceshrimp.Backend.Controllers.Mastodon; @@ -28,13 +25,13 @@ public class MastodonTimelineController(DatabaseContext db, NoteRenderer noteRen [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] public async Task GetHomeTimeline() { var user = HttpContext.GetOauthUser() ?? throw new GracefulException("Failed to get user from HttpContext"); - var notes = db.Notes - .WithIncludes() - .IsFollowedBy(user) - .OrderByIdDesc() - .Take(40); + var res = await db.Notes + .WithIncludes() + .FilterByFollowingAndOwn(user) + .OrderByIdDesc() + .Take(40) + .RenderAllForMastodonAsync(noteRenderer); - var res = await notes.RenderAllForMastodonAsync(noteRenderer); return Ok(res); } @@ -43,13 +40,13 @@ public class MastodonTimelineController(DatabaseContext db, NoteRenderer noteRen [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] public async Task GetPublicTimeline() { - var notes = db.Notes - .WithIncludes() - .HasVisibility(Note.NoteVisibility.Public) - .OrderByIdDesc() - .Take(40); + var res = await db.Notes + .WithIncludes() + .HasVisibility(Note.NoteVisibility.Public) + .OrderByIdDesc() + .Take(40) + .RenderAllForMastodonAsync(noteRenderer); - var res = await notes.RenderAllForMastodonAsync(noteRenderer); return Ok(res); } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs index 0cf80d7a..3e128b6d 100644 --- a/Iceshrimp.Backend/Core/Database/DatabaseContext.cs +++ b/Iceshrimp.Backend/Core/Database/DatabaseContext.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using EntityFrameworkCore.Projectables.Infrastructure; using Iceshrimp.Backend.Core.Configuration; using Iceshrimp.Backend.Core.Database.Tables; using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore; @@ -106,6 +107,9 @@ public class DatabaseContext(DbContextOptions options) public static void Configure(DbContextOptionsBuilder optionsBuilder, NpgsqlDataSource dataSource) { optionsBuilder.UseNpgsql(dataSource); + optionsBuilder.UseProjectables(options => { + options.CompatibilityMode(CompatibilityMode.Limited); + }); } protected override void OnModelCreating(ModelBuilder modelBuilder) { @@ -348,9 +352,9 @@ public class DatabaseContext(DbContextOptions options) entity.Property(e => e.FollowerSharedInbox).HasComment("[Denormalized]"); entity.Property(e => e.RequestId).HasComment("id of Follow Activity."); - entity.HasOne(d => d.Followee).WithMany(p => p.FollowRequestFollowees); + entity.HasOne(d => d.Followee).WithMany(p => p.IncomingFollowRequests); - entity.HasOne(d => d.Follower).WithMany(p => p.FollowRequestFollowers); + entity.HasOne(d => d.Follower).WithMany(p => p.OutgoingFollowRequests); }); modelBuilder.Entity(entity => { @@ -364,9 +368,9 @@ public class DatabaseContext(DbContextOptions options) entity.Property(e => e.FollowerInbox).HasComment("[Denormalized]"); entity.Property(e => e.FollowerSharedInbox).HasComment("[Denormalized]"); - entity.HasOne(d => d.Followee).WithMany(p => p.FollowingFollowees); + entity.HasOne(d => d.Followee).WithMany(p => p.IncomingFollowRelationships); - entity.HasOne(d => d.Follower).WithMany(p => p.FollowingFollowers); + entity.HasOne(d => d.Follower).WithMany(p => p.OutgoingFollowRelationships); }); modelBuilder.Entity(entity => { diff --git a/Iceshrimp.Backend/Core/Database/Tables/AbuseUserReport.cs b/Iceshrimp.Backend/Core/Database/Tables/AbuseUserReport.cs index 1d6c1182..c416a46a 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/AbuseUserReport.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/AbuseUserReport.cs @@ -58,14 +58,14 @@ public class AbuseUserReport { [Column("forwarded")] public bool Forwarded { get; set; } [ForeignKey("AssigneeId")] - [InverseProperty("AbuseUserReportAssignees")] + [InverseProperty(nameof(User.AbuseUserReportAssignees))] public virtual User? Assignee { get; set; } [ForeignKey("ReporterId")] - [InverseProperty("AbuseUserReportReporters")] + [InverseProperty(nameof(User.AbuseUserReportReporters))] public virtual User Reporter { get; set; } = null!; [ForeignKey("TargetUserId")] - [InverseProperty("AbuseUserReportTargetUsers")] + [InverseProperty(nameof(User.AbuseUserReportTargetUsers))] public virtual User TargetUser { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/AccessToken.cs b/Iceshrimp.Backend/Core/Database/Tables/AccessToken.cs index cc9a36f3..c791aa69 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/AccessToken.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/AccessToken.cs @@ -51,13 +51,13 @@ public class AccessToken { [Column("fetched")] public bool Fetched { get; set; } [ForeignKey("AppId")] - [InverseProperty("AccessTokens")] + [InverseProperty(nameof(Tables.App.AccessTokens))] public virtual App? App { get; set; } - [InverseProperty("AppAccessToken")] + [InverseProperty(nameof(Notification.AppAccessToken))] public virtual ICollection Notifications { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("AccessTokens")] + [InverseProperty(nameof(Tables.User.AccessTokens))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Announcement.cs b/Iceshrimp.Backend/Core/Database/Tables/Announcement.cs index 484777f9..ffe66e41 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Announcement.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Announcement.cs @@ -36,6 +36,6 @@ public class Announcement { [Column("isGoodNews")] public bool IsGoodNews { get; set; } - [InverseProperty("Announcement")] + [InverseProperty(nameof(AnnouncementRead.Announcement))] public virtual ICollection AnnouncementReads { get; set; } = new List(); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/AnnouncementRead.cs b/Iceshrimp.Backend/Core/Database/Tables/AnnouncementRead.cs index 4009e4b3..96417416 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/AnnouncementRead.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/AnnouncementRead.cs @@ -27,10 +27,10 @@ public class AnnouncementRead { public DateTime CreatedAt { get; set; } [ForeignKey("AnnouncementId")] - [InverseProperty("AnnouncementReads")] + [InverseProperty(nameof(Tables.Announcement.AnnouncementReads))] public virtual Announcement Announcement { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("AnnouncementReads")] + [InverseProperty(nameof(Tables.User.AnnouncementReads))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Antenna.cs b/Iceshrimp.Backend/Core/Database/Tables/Antenna.cs index 6a62dcac..d64e36d8 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Antenna.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Antenna.cs @@ -68,15 +68,15 @@ public class Antenna { public string Instances { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("Antennas")] + [InverseProperty(nameof(Tables.User.Antennas))] public virtual User User { get; set; } = null!; [ForeignKey("UserGroupMemberId")] - [InverseProperty("Antennas")] + [InverseProperty(nameof(Tables.UserGroupMember.Antennas))] public virtual UserGroupMember? UserGroupMember { get; set; } [ForeignKey("UserListId")] - [InverseProperty("Antennas")] + [InverseProperty(nameof(Tables.UserList.Antennas))] public virtual UserList? UserList { get; set; } [PgName("antenna_src_enum")] diff --git a/Iceshrimp.Backend/Core/Database/Tables/App.cs b/Iceshrimp.Backend/Core/Database/Tables/App.cs index 9c85a15f..5ba4c8cc 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/App.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/App.cs @@ -61,13 +61,13 @@ public class App { [StringLength(512)] public string? CallbackUrl { get; set; } - [InverseProperty("App")] + [InverseProperty(nameof(AccessToken.App))] public virtual ICollection AccessTokens { get; set; } = new List(); - [InverseProperty("App")] + [InverseProperty(nameof(AuthSession.App))] public virtual ICollection AuthSessions { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("Apps")] + [InverseProperty(nameof(Tables.User.Apps))] public virtual User? User { get; set; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/AttestationChallenge.cs b/Iceshrimp.Backend/Core/Database/Tables/AttestationChallenge.cs index 0d19b29a..0e8fc7cd 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/AttestationChallenge.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/AttestationChallenge.cs @@ -40,6 +40,6 @@ public class AttestationChallenge { public bool RegistrationChallenge { get; set; } [ForeignKey("UserId")] - [InverseProperty("AttestationChallenges")] + [InverseProperty(nameof(Tables.User.AttestationChallenges))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/AuthSession.cs b/Iceshrimp.Backend/Core/Database/Tables/AuthSession.cs index e3d4b2fd..2fd2d9f0 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/AuthSession.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/AuthSession.cs @@ -25,10 +25,10 @@ public class AuthSession { [Column("appId")] [StringLength(32)] public string AppId { get; set; } = null!; [ForeignKey("AppId")] - [InverseProperty("AuthSessions")] + [InverseProperty(nameof(Tables.App.AuthSessions))] public virtual App App { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("AuthSessions")] + [InverseProperty(nameof(Tables.User.AuthSessions))] public virtual User? User { get; set; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Blocking.cs b/Iceshrimp.Backend/Core/Database/Tables/Blocking.cs index 3b9e9407..96a0b299 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Blocking.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Blocking.cs @@ -36,10 +36,10 @@ public class Blocking { public string BlockerId { get; set; } = null!; [ForeignKey("BlockeeId")] - [InverseProperty("BlockingBlockees")] + [InverseProperty(nameof(User.BlockingBlockees))] public virtual User Blockee { get; set; } = null!; [ForeignKey("BlockerId")] - [InverseProperty("BlockingBlockers")] + [InverseProperty(nameof(User.BlockingBlockers))] public virtual User Blocker { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Channel.cs b/Iceshrimp.Backend/Core/Database/Tables/Channel.cs index 12e69aa2..aa469d14 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Channel.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Channel.cs @@ -65,18 +65,18 @@ public class Channel { public int UsersCount { get; set; } [ForeignKey("BannerId")] - [InverseProperty("Channels")] + [InverseProperty(nameof(DriveFile.Channels))] public virtual DriveFile? Banner { get; set; } - [InverseProperty("Followee")] + [InverseProperty(nameof(ChannelFollowing.Followee))] public virtual ICollection ChannelFollowings { get; set; } = new List(); - [InverseProperty("Channel")] + [InverseProperty(nameof(ChannelNotePin.Channel))] public virtual ICollection ChannelNotePins { get; set; } = new List(); - [InverseProperty("Channel")] public virtual ICollection Notes { get; set; } = new List(); + [InverseProperty(nameof(Note.Channel))] public virtual ICollection Notes { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("Channels")] + [InverseProperty(nameof(Tables.User.Channels))] public virtual User? User { get; set; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/ChannelFollowing.cs b/Iceshrimp.Backend/Core/Database/Tables/ChannelFollowing.cs index c3b732cc..4c04ef5f 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/ChannelFollowing.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/ChannelFollowing.cs @@ -36,10 +36,10 @@ public class ChannelFollowing { public string FollowerId { get; set; } = null!; [ForeignKey("FolloweeId")] - [InverseProperty("ChannelFollowings")] + [InverseProperty(nameof(Channel.ChannelFollowings))] public virtual Channel Followee { get; set; } = null!; [ForeignKey("FollowerId")] - [InverseProperty("ChannelFollowings")] + [InverseProperty(nameof(User.ChannelFollowings))] public virtual User Follower { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/ChannelNotePin.cs b/Iceshrimp.Backend/Core/Database/Tables/ChannelNotePin.cs index 851eed54..a3e788a4 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/ChannelNotePin.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/ChannelNotePin.cs @@ -26,10 +26,10 @@ public class ChannelNotePin { [Column("noteId")] [StringLength(32)] public string NoteId { get; set; } = null!; [ForeignKey("ChannelId")] - [InverseProperty("ChannelNotePins")] + [InverseProperty(nameof(Tables.Channel.ChannelNotePins))] public virtual Channel Channel { get; set; } = null!; [ForeignKey("NoteId")] - [InverseProperty("ChannelNotePins")] + [InverseProperty(nameof(Tables.Note.ChannelNotePins))] public virtual Note Note { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Clip.cs b/Iceshrimp.Backend/Core/Database/Tables/Clip.cs index d9deacd4..cdc92b3c 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Clip.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Clip.cs @@ -41,9 +41,9 @@ public class Clip { [StringLength(2048)] public string? Description { get; set; } - [InverseProperty("Clip")] public virtual ICollection ClipNotes { get; set; } = new List(); + [InverseProperty(nameof(ClipNote.Clip))] public virtual ICollection ClipNotes { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("Clips")] + [InverseProperty(nameof(Tables.User.Clips))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/ClipNote.cs b/Iceshrimp.Backend/Core/Database/Tables/ClipNote.cs index bfd03072..cc25a67a 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/ClipNote.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/ClipNote.cs @@ -29,10 +29,10 @@ public class ClipNote { public string ClipId { get; set; } = null!; [ForeignKey("ClipId")] - [InverseProperty("ClipNotes")] + [InverseProperty(nameof(Tables.Clip.ClipNotes))] public virtual Clip Clip { get; set; } = null!; [ForeignKey("NoteId")] - [InverseProperty("ClipNotes")] + [InverseProperty(nameof(Tables.Note.ClipNotes))] public virtual Note Note { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/DriveFile.cs b/Iceshrimp.Backend/Core/Database/Tables/DriveFile.cs index aef416c9..8bd7e7a8 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/DriveFile.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/DriveFile.cs @@ -165,22 +165,22 @@ public class DriveFile { [StringLength(128)] public string? RequestIp { get; set; } - [InverseProperty("Banner")] public virtual ICollection Channels { get; set; } = new List(); + [InverseProperty(nameof(Channel.Banner))] public virtual ICollection Channels { get; set; } = new List(); [ForeignKey("FolderId")] - [InverseProperty("DriveFiles")] + [InverseProperty(nameof(DriveFolder.DriveFiles))] public virtual DriveFolder? Folder { get; set; } - [InverseProperty("File")] + [InverseProperty(nameof(MessagingMessage.File))] public virtual ICollection MessagingMessages { get; set; } = new List(); - [InverseProperty("EyeCatchingImage")] public virtual ICollection Pages { get; set; } = new List(); + [InverseProperty(nameof(Page.EyeCatchingImage))] public virtual ICollection Pages { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("DriveFiles")] + [InverseProperty(nameof(Tables.User.DriveFiles))] public virtual User? User { get; set; } - [InverseProperty("Avatar")] public virtual User? UserAvatar { get; set; } + [InverseProperty(nameof(Tables.User.Avatar))] public virtual User? UserAvatar { get; set; } - [InverseProperty("Banner")] public virtual User? UserBanner { get; set; } + [InverseProperty(nameof(Tables.User.Banner))] public virtual User? UserBanner { get; set; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/DriveFolder.cs b/Iceshrimp.Backend/Core/Database/Tables/DriveFolder.cs index b9ffb093..3c1b1f84 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/DriveFolder.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/DriveFolder.cs @@ -41,16 +41,16 @@ public class DriveFolder { [StringLength(32)] public string? ParentId { get; set; } - [InverseProperty("Folder")] public virtual ICollection DriveFiles { get; set; } = new List(); + [InverseProperty(nameof(DriveFile.Folder))] public virtual ICollection DriveFiles { get; set; } = new List(); - [InverseProperty("Parent")] + [InverseProperty(nameof(Parent))] public virtual ICollection InverseParent { get; set; } = new List(); [ForeignKey("ParentId")] - [InverseProperty("InverseParent")] + [InverseProperty(nameof(InverseParent))] public virtual DriveFolder? Parent { get; set; } [ForeignKey("UserId")] - [InverseProperty("DriveFolders")] + [InverseProperty(nameof(Tables.User.DriveFolders))] public virtual User? User { get; set; } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/FollowRequest.cs b/Iceshrimp.Backend/Core/Database/Tables/FollowRequest.cs index ecdee935..f67ac75e 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/FollowRequest.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/FollowRequest.cs @@ -84,13 +84,13 @@ public class FollowRequest { public string? FolloweeSharedInbox { get; set; } [ForeignKey("FolloweeId")] - [InverseProperty("FollowRequestFollowees")] + [InverseProperty(nameof(User.IncomingFollowRequests))] public virtual User Followee { get; set; } = null!; [ForeignKey("FollowerId")] - [InverseProperty("FollowRequestFollowers")] + [InverseProperty(nameof(User.OutgoingFollowRequests))] public virtual User Follower { get; set; } = null!; - [InverseProperty("FollowRequest")] + [InverseProperty(nameof(Notification.FollowRequest))] public virtual ICollection Notifications { get; set; } = new List(); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Following.cs b/Iceshrimp.Backend/Core/Database/Tables/Following.cs index 960e43c4..81835def 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Following.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Following.cs @@ -80,10 +80,10 @@ public class Following { public string? FolloweeSharedInbox { get; set; } [ForeignKey("FolloweeId")] - [InverseProperty("FollowingFollowees")] + [InverseProperty(nameof(User.IncomingFollowRelationships))] public virtual User Followee { get; set; } = null!; [ForeignKey("FollowerId")] - [InverseProperty("FollowingFollowers")] + [InverseProperty(nameof(User.OutgoingFollowRelationships))] public virtual User Follower { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/GalleryLike.cs b/Iceshrimp.Backend/Core/Database/Tables/GalleryLike.cs index 2a1f4d2e..4365bb22 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/GalleryLike.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/GalleryLike.cs @@ -20,10 +20,10 @@ public class GalleryLike { [Column("postId")] [StringLength(32)] public string PostId { get; set; } = null!; [ForeignKey("PostId")] - [InverseProperty("GalleryLikes")] + [InverseProperty(nameof(GalleryPost.GalleryLikes))] public virtual GalleryPost Post { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("GalleryLikes")] + [InverseProperty(nameof(Tables.User.GalleryLikes))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/GalleryPost.cs b/Iceshrimp.Backend/Core/Database/Tables/GalleryPost.cs index ce3c5e85..3c1e1709 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/GalleryPost.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/GalleryPost.cs @@ -57,10 +57,10 @@ public class GalleryPost { [Column("tags", TypeName = "character varying(128)[]")] public List Tags { get; set; } = null!; - [InverseProperty("Post")] + [InverseProperty(nameof(GalleryLike.Post))] public virtual ICollection GalleryLikes { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("GalleryPosts")] + [InverseProperty(nameof(Tables.User.GalleryPosts))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/HtmlNoteCacheEntry.cs b/Iceshrimp.Backend/Core/Database/Tables/HtmlNoteCacheEntry.cs index 01446dd5..bf6a2b58 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/HtmlNoteCacheEntry.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/HtmlNoteCacheEntry.cs @@ -15,6 +15,6 @@ public class HtmlNoteCacheEntry { [Column("content")] public string? Content { get; set; } [ForeignKey("NoteId")] - [InverseProperty("HtmlNoteCacheEntry")] + [InverseProperty(nameof(Tables.Note.HtmlNoteCacheEntry))] public virtual Note Note { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/HtmlUserCacheEntry.cs b/Iceshrimp.Backend/Core/Database/Tables/HtmlUserCacheEntry.cs index 5778c65b..224f4580 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/HtmlUserCacheEntry.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/HtmlUserCacheEntry.cs @@ -17,6 +17,6 @@ public class HtmlUserCacheEntry { [Column("fields", TypeName = "jsonb")] public string Fields { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("HtmlUserCacheEntry")] + [InverseProperty(nameof(Tables.User.HtmlUserCacheEntry))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/MessagingMessage.cs b/Iceshrimp.Backend/Core/Database/Tables/MessagingMessage.cs index 1bd01bb1..cf16efd9 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/MessagingMessage.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/MessagingMessage.cs @@ -54,18 +54,18 @@ public class MessagingMessage { [Column("uri")] [StringLength(512)] public string? Uri { get; set; } [ForeignKey("FileId")] - [InverseProperty("MessagingMessages")] + [InverseProperty(nameof(DriveFile.MessagingMessages))] public virtual DriveFile? File { get; set; } [ForeignKey("GroupId")] - [InverseProperty("MessagingMessages")] + [InverseProperty(nameof(UserGroup.MessagingMessages))] public virtual UserGroup? Group { get; set; } [ForeignKey("RecipientId")] - [InverseProperty("MessagingMessageRecipients")] + [InverseProperty(nameof(Tables.User.MessagingMessageRecipients))] public virtual User? Recipient { get; set; } [ForeignKey("UserId")] - [InverseProperty("MessagingMessageUsers")] + [InverseProperty(nameof(Tables.User.MessagingMessageUsers))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/ModerationLog.cs b/Iceshrimp.Backend/Core/Database/Tables/ModerationLog.cs index 40368f6f..f2d71f01 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/ModerationLog.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/ModerationLog.cs @@ -25,6 +25,6 @@ public class ModerationLog { [Column("info", TypeName = "jsonb")] public string Info { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("ModerationLogs")] + [InverseProperty(nameof(Tables.User.ModerationLogs))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Muting.cs b/Iceshrimp.Backend/Core/Database/Tables/Muting.cs index 2c26c6e8..14f0dbfc 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Muting.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Muting.cs @@ -39,10 +39,10 @@ public class Muting { [Column("expiresAt")] public DateTime? ExpiresAt { get; set; } [ForeignKey("MuteeId")] - [InverseProperty("MutingMutees")] + [InverseProperty(nameof(User.MutingMutees))] public virtual User Mutee { get; set; } = null!; [ForeignKey("MuterId")] - [InverseProperty("MutingMuters")] + [InverseProperty(nameof(User.MutingMuters))] public virtual User Muter { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Note.cs b/Iceshrimp.Backend/Core/Database/Tables/Note.cs index c0e2b264..4e588726 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Note.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Note.cs @@ -173,56 +173,56 @@ public class Note { public DateTime? UpdatedAt { get; set; } [ForeignKey("ChannelId")] - [InverseProperty("Notes")] + [InverseProperty(nameof(Tables.Channel.Notes))] public virtual Channel? Channel { get; set; } - [InverseProperty("Note")] + [InverseProperty(nameof(ChannelNotePin.Note))] public virtual ICollection ChannelNotePins { get; set; } = new List(); - [InverseProperty("Note")] public virtual ICollection ClipNotes { get; set; } = new List(); + [InverseProperty(nameof(ClipNote.Note))] public virtual ICollection ClipNotes { get; set; } = new List(); - [InverseProperty("Note")] public virtual HtmlNoteCacheEntry? HtmlNoteCacheEntry { get; set; } + [InverseProperty(nameof(Tables.HtmlNoteCacheEntry.Note))] public virtual HtmlNoteCacheEntry? HtmlNoteCacheEntry { get; set; } - [InverseProperty("Renote")] public virtual ICollection InverseRenote { get; set; } = new List(); + [InverseProperty(nameof(Renote))] public virtual ICollection InverseRenote { get; set; } = new List(); - [InverseProperty("Reply")] public virtual ICollection InverseReply { get; set; } = new List(); + [InverseProperty(nameof(Reply))] public virtual ICollection InverseReply { get; set; } = new List(); - [InverseProperty("Note")] public virtual ICollection NoteEdits { get; set; } = new List(); + [InverseProperty(nameof(NoteEdit.Note))] public virtual ICollection NoteEdits { get; set; } = new List(); - [InverseProperty("Note")] + [InverseProperty(nameof(NoteFavorite.Note))] public virtual ICollection NoteFavorites { get; set; } = new List(); - [InverseProperty("Note")] + [InverseProperty(nameof(NoteReaction.Note))] public virtual ICollection NoteReactions { get; set; } = new List(); - [InverseProperty("Note")] public virtual ICollection NoteUnreads { get; set; } = new List(); + [InverseProperty(nameof(NoteUnread.Note))] public virtual ICollection NoteUnreads { get; set; } = new List(); - [InverseProperty("Note")] + [InverseProperty(nameof(NoteWatching.Note))] public virtual ICollection NoteWatchings { get; set; } = new List(); - [InverseProperty("Note")] + [InverseProperty(nameof(Notification.Note))] public virtual ICollection Notifications { get; set; } = new List(); - [InverseProperty("Note")] public virtual Poll? Poll { get; set; } + [InverseProperty(nameof(Tables.Poll.Note))] public virtual Poll? Poll { get; set; } - [InverseProperty("Note")] public virtual ICollection PollVotes { get; set; } = new List(); + [InverseProperty(nameof(PollVote.Note))] public virtual ICollection PollVotes { get; set; } = new List(); - [InverseProperty("Note")] public virtual PromoNote? PromoNote { get; set; } + [InverseProperty(nameof(Tables.PromoNote.Note))] public virtual PromoNote? PromoNote { get; set; } - [InverseProperty("Note")] public virtual ICollection PromoReads { get; set; } = new List(); + [InverseProperty(nameof(PromoRead.Note))] public virtual ICollection PromoReads { get; set; } = new List(); [ForeignKey("RenoteId")] - [InverseProperty("InverseRenote")] + [InverseProperty(nameof(InverseRenote))] public virtual Note? Renote { get; set; } [ForeignKey("ReplyId")] - [InverseProperty("InverseReply")] + [InverseProperty(nameof(InverseReply))] public virtual Note? Reply { get; set; } [ForeignKey("UserId")] - [InverseProperty("Notes")] + [InverseProperty(nameof(Tables.User.Notes))] public virtual User User { get; set; } = null!; - [InverseProperty("Note")] + [InverseProperty(nameof(UserNotePin.Note))] public virtual ICollection UserNotePins { get; set; } = new List(); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/NoteEdit.cs b/Iceshrimp.Backend/Core/Database/Tables/NoteEdit.cs index 2316ad67..2618d000 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/NoteEdit.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/NoteEdit.cs @@ -33,6 +33,6 @@ public class NoteEdit { public DateTime UpdatedAt { get; set; } [ForeignKey("NoteId")] - [InverseProperty("NoteEdits")] + [InverseProperty(nameof(Tables.Note.NoteEdits))] public virtual Note Note { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/NoteFavorite.cs b/Iceshrimp.Backend/Core/Database/Tables/NoteFavorite.cs index 791eef57..9815b099 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/NoteFavorite.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/NoteFavorite.cs @@ -24,10 +24,10 @@ public class NoteFavorite { [Column("noteId")] [StringLength(32)] public string NoteId { get; set; } = null!; [ForeignKey("NoteId")] - [InverseProperty("NoteFavorites")] + [InverseProperty(nameof(Tables.Note.NoteFavorites))] public virtual Note Note { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("NoteFavorites")] + [InverseProperty(nameof(Tables.User.NoteFavorites))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/NoteReaction.cs b/Iceshrimp.Backend/Core/Database/Tables/NoteReaction.cs index 52c7274c..1a5ddd5d 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/NoteReaction.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/NoteReaction.cs @@ -30,10 +30,10 @@ public class NoteReaction { public string Reaction { get; set; } = null!; [ForeignKey("NoteId")] - [InverseProperty("NoteReactions")] + [InverseProperty(nameof(Tables.Note.NoteReactions))] public virtual Note Note { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("NoteReactions")] + [InverseProperty(nameof(Tables.User.NoteReactions))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/NoteThreadMuting.cs b/Iceshrimp.Backend/Core/Database/Tables/NoteThreadMuting.cs index c0ca3add..905a3013 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/NoteThreadMuting.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/NoteThreadMuting.cs @@ -23,6 +23,6 @@ public class NoteThreadMuting { public string ThreadId { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("NoteThreadMutings")] + [InverseProperty(nameof(Tables.User.NoteThreadMutings))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/NoteUnread.cs b/Iceshrimp.Backend/Core/Database/Tables/NoteUnread.cs index 0adf2ef9..b06a2bd0 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/NoteUnread.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/NoteUnread.cs @@ -41,10 +41,10 @@ public class NoteUnread { public string? NoteChannelId { get; set; } [ForeignKey("NoteId")] - [InverseProperty("NoteUnreads")] + [InverseProperty(nameof(Tables.Note.NoteUnreads))] public virtual Note Note { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("NoteUnreads")] + [InverseProperty(nameof(Tables.User.NoteUnreads))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/NoteWatching.cs b/Iceshrimp.Backend/Core/Database/Tables/NoteWatching.cs index 4f34f708..b7ba1f3b 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/NoteWatching.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/NoteWatching.cs @@ -44,10 +44,10 @@ public class NoteWatching { public string NoteUserId { get; set; } = null!; [ForeignKey("NoteId")] - [InverseProperty("NoteWatchings")] + [InverseProperty(nameof(Tables.Note.NoteWatchings))] public virtual Note Note { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("NoteWatchings")] + [InverseProperty(nameof(Tables.User.NoteWatchings))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Notification.cs b/Iceshrimp.Backend/Core/Database/Tables/Notification.cs index 80b8fba2..9d581ebc 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Notification.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Notification.cs @@ -79,27 +79,27 @@ public class Notification { public string? AppAccessTokenId { get; set; } [ForeignKey("AppAccessTokenId")] - [InverseProperty("Notifications")] + [InverseProperty(nameof(AccessToken.Notifications))] public virtual AccessToken? AppAccessToken { get; set; } [ForeignKey("FollowRequestId")] - [InverseProperty("Notifications")] + [InverseProperty(nameof(Tables.FollowRequest.Notifications))] public virtual FollowRequest? FollowRequest { get; set; } [ForeignKey("NoteId")] - [InverseProperty("Notifications")] + [InverseProperty(nameof(Tables.Note.Notifications))] public virtual Note? Note { get; set; } [ForeignKey("NotifieeId")] - [InverseProperty("NotificationNotifiees")] + [InverseProperty(nameof(User.NotificationNotifiees))] public virtual User Notifiee { get; set; } = null!; [ForeignKey("NotifierId")] - [InverseProperty("NotificationNotifiers")] + [InverseProperty(nameof(User.NotificationNotifiers))] public virtual User? Notifier { get; set; } [ForeignKey("UserGroupInvitationId")] - [InverseProperty("Notifications")] + [InverseProperty(nameof(Tables.UserGroupInvitation.Notifications))] public virtual UserGroupInvitation? UserGroupInvitation { get; set; } [PgName("notification_type_enum")] diff --git a/Iceshrimp.Backend/Core/Database/Tables/OauthApp.cs b/Iceshrimp.Backend/Core/Database/Tables/OauthApp.cs index b22a4665..b8ccf0f1 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/OauthApp.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/OauthApp.cs @@ -58,5 +58,5 @@ public class OauthApp { [Column("redirectUris", TypeName = "character varying(512)[]")] public List RedirectUris { get; set; } = null!; - [InverseProperty("App")] public virtual ICollection OauthTokens { get; set; } = new List(); + [InverseProperty(nameof(OauthToken.App))] public virtual ICollection OauthTokens { get; set; } = new List(); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/OauthToken.cs b/Iceshrimp.Backend/Core/Database/Tables/OauthToken.cs index 62aa6de1..67565425 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/OauthToken.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/OauthToken.cs @@ -57,10 +57,10 @@ public class OauthToken { public string RedirectUri { get; set; } = null!; [ForeignKey("AppId")] - [InverseProperty("OauthTokens")] + [InverseProperty(nameof(OauthApp.OauthTokens))] public virtual OauthApp App { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("OauthTokens")] + [InverseProperty(nameof(Tables.User.OauthTokens))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Page.cs b/Iceshrimp.Backend/Core/Database/Tables/Page.cs index 30f59451..2bd6815d 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Page.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Page.cs @@ -75,16 +75,16 @@ public class Page { [Column("isPublic")] public bool IsPublic { get; set; } [ForeignKey("EyeCatchingImageId")] - [InverseProperty("Pages")] + [InverseProperty(nameof(DriveFile.Pages))] public virtual DriveFile? EyeCatchingImage { get; set; } - [InverseProperty("Page")] public virtual ICollection PageLikes { get; set; } = new List(); + [InverseProperty(nameof(PageLike.Page))] public virtual ICollection PageLikes { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("Pages")] + [InverseProperty(nameof(Tables.User.Pages))] public virtual User User { get; set; } = null!; - [InverseProperty("PinnedPage")] public virtual UserProfile? UserProfile { get; set; } + [InverseProperty(nameof(Tables.UserProfile.PinnedPage))] public virtual UserProfile? UserProfile { get; set; } [PgName("page_visibility_enum")] public enum PageVisibility { diff --git a/Iceshrimp.Backend/Core/Database/Tables/PageLike.cs b/Iceshrimp.Backend/Core/Database/Tables/PageLike.cs index 66c8081c..0259af58 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/PageLike.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/PageLike.cs @@ -20,10 +20,10 @@ public class PageLike { [Column("pageId")] [StringLength(32)] public string PageId { get; set; } = null!; [ForeignKey("PageId")] - [InverseProperty("PageLikes")] + [InverseProperty(nameof(Tables.Page.PageLikes))] public virtual Page Page { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("PageLikes")] + [InverseProperty(nameof(Tables.User.PageLikes))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/PasswordResetRequest.cs b/Iceshrimp.Backend/Core/Database/Tables/PasswordResetRequest.cs index a3d42a3d..0bfa76ad 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/PasswordResetRequest.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/PasswordResetRequest.cs @@ -20,6 +20,6 @@ public class PasswordResetRequest { [Column("userId")] [StringLength(32)] public string UserId { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("PasswordResetRequests")] + [InverseProperty(nameof(Tables.User.PasswordResetRequests))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Poll.cs b/Iceshrimp.Backend/Core/Database/Tables/Poll.cs index 53af6b74..2cb138ca 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Poll.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Poll.cs @@ -38,7 +38,7 @@ public class Poll { public string? UserHost { get; set; } [ForeignKey("NoteId")] - [InverseProperty("Poll")] + [InverseProperty(nameof(Tables.Note.Poll))] public virtual Note Note { get; set; } = null!; /// diff --git a/Iceshrimp.Backend/Core/Database/Tables/PollVote.cs b/Iceshrimp.Backend/Core/Database/Tables/PollVote.cs index 1fec36af..95d5c16f 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/PollVote.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/PollVote.cs @@ -28,10 +28,10 @@ public class PollVote { [Column("choice")] public int Choice { get; set; } [ForeignKey("NoteId")] - [InverseProperty("PollVotes")] + [InverseProperty(nameof(Tables.Note.PollVotes))] public virtual Note Note { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("PollVotes")] + [InverseProperty(nameof(Tables.User.PollVotes))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/PromoNote.cs b/Iceshrimp.Backend/Core/Database/Tables/PromoNote.cs index 4e6665a8..5ff7476c 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/PromoNote.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/PromoNote.cs @@ -22,6 +22,6 @@ public class PromoNote { public string UserId { get; set; } = null!; [ForeignKey("NoteId")] - [InverseProperty("PromoNote")] + [InverseProperty(nameof(Tables.Note.PromoNote))] public virtual Note Note { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/PromoRead.cs b/Iceshrimp.Backend/Core/Database/Tables/PromoRead.cs index 29788e01..d2e55380 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/PromoRead.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/PromoRead.cs @@ -24,10 +24,10 @@ public class PromoRead { [Column("noteId")] [StringLength(32)] public string NoteId { get; set; } = null!; [ForeignKey("NoteId")] - [InverseProperty("PromoReads")] + [InverseProperty(nameof(Tables.Note.PromoReads))] public virtual Note Note { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("PromoReads")] + [InverseProperty(nameof(Tables.User.PromoReads))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/RegistryItem.cs b/Iceshrimp.Backend/Core/Database/Tables/RegistryItem.cs index 0cdb39d9..b400a5ee 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/RegistryItem.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/RegistryItem.cs @@ -52,6 +52,6 @@ public class RegistryItem { public string? Value { get; set; } [ForeignKey("UserId")] - [InverseProperty("RegistryItems")] + [InverseProperty(nameof(Tables.User.RegistryItems))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/RenoteMuting.cs b/Iceshrimp.Backend/Core/Database/Tables/RenoteMuting.cs index 86b7e089..641e541c 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/RenoteMuting.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/RenoteMuting.cs @@ -36,10 +36,10 @@ public class RenoteMuting { public string MuterId { get; set; } = null!; [ForeignKey("MuteeId")] - [InverseProperty("RenoteMutingMutees")] + [InverseProperty(nameof(User.RenoteMutingMutees))] public virtual User Mutee { get; set; } = null!; [ForeignKey("MuterId")] - [InverseProperty("RenoteMutingMuters")] + [InverseProperty(nameof(User.RenoteMutingMuters))] public virtual User Muter { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Session.cs b/Iceshrimp.Backend/Core/Database/Tables/Session.cs index d7e97db2..e15394b4 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Session.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Session.cs @@ -34,6 +34,6 @@ public class Session { public bool Active { get; set; } [ForeignKey("UserId")] - [InverseProperty("Sessions")] + [InverseProperty(nameof(Tables.User.Sessions))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Signin.cs b/Iceshrimp.Backend/Core/Database/Tables/Signin.cs index 1d013174..aa01ceac 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Signin.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Signin.cs @@ -28,6 +28,6 @@ public class Signin { [Column("success")] public bool Success { get; set; } [ForeignKey("UserId")] - [InverseProperty("Signins")] + [InverseProperty(nameof(Tables.User.Signins))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/SwSubscription.cs b/Iceshrimp.Backend/Core/Database/Tables/SwSubscription.cs index 20b3cac9..4e0a93a9 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/SwSubscription.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/SwSubscription.cs @@ -29,6 +29,6 @@ public class SwSubscription { [Column("sendReadMessage")] public bool SendReadMessage { get; set; } [ForeignKey("UserId")] - [InverseProperty("SwSubscriptions")] + [InverseProperty(nameof(Tables.User.SwSubscriptions))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/User.cs b/Iceshrimp.Backend/Core/Database/Tables/User.cs index 5aca3cb4..1fa7c524 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/User.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/User.cs @@ -1,5 +1,7 @@ -using System.ComponentModel.DataAnnotations; +using System.Collections; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using EntityFrameworkCore.Projectables; using Microsoft.EntityFrameworkCore; namespace Iceshrimp.Backend.Core.Database.Tables; @@ -258,169 +260,181 @@ public class User { [StringLength(128)] public string? BannerBlurhash { get; set; } - [InverseProperty("Assignee")] + [InverseProperty(nameof(AbuseUserReport.Assignee))] public virtual ICollection AbuseUserReportAssignees { get; set; } = new List(); - [InverseProperty("Reporter")] + [InverseProperty(nameof(AbuseUserReport.Reporter))] public virtual ICollection AbuseUserReportReporters { get; set; } = new List(); - [InverseProperty("TargetUser")] + [InverseProperty(nameof(AbuseUserReport.TargetUser))] public virtual ICollection AbuseUserReportTargetUsers { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(AccessToken.User))] public virtual ICollection AccessTokens { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(AnnouncementRead.User))] public virtual ICollection AnnouncementReads { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Antennas { get; set; } = new List(); + [InverseProperty(nameof(Antenna.User))] public virtual ICollection Antennas { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Apps { get; set; } = new List(); + [InverseProperty(nameof(App.User))] public virtual ICollection Apps { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(AttestationChallenge.User))] public virtual ICollection AttestationChallenges { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(AuthSession.User))] public virtual ICollection AuthSessions { get; set; } = new List(); [ForeignKey("AvatarId")] - [InverseProperty("UserAvatar")] + [InverseProperty(nameof(DriveFile.UserAvatar))] public virtual DriveFile? Avatar { get; set; } [ForeignKey("BannerId")] - [InverseProperty("UserBanner")] + [InverseProperty(nameof(DriveFile.UserBanner))] public virtual DriveFile? Banner { get; set; } - [InverseProperty("Blockee")] + [InverseProperty(nameof(Blocking.Blockee))] public virtual ICollection BlockingBlockees { get; set; } = new List(); - [InverseProperty("Blocker")] + [InverseProperty(nameof(Blocking.Blocker))] public virtual ICollection BlockingBlockers { get; set; } = new List(); - [InverseProperty("Follower")] + [InverseProperty(nameof(ChannelFollowing.Follower))] public virtual ICollection ChannelFollowings { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Channels { get; set; } = new List(); + [InverseProperty(nameof(Channel.User))] public virtual ICollection Channels { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Clips { get; set; } = new List(); + [InverseProperty(nameof(Clip.User))] public virtual ICollection Clips { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection DriveFiles { get; set; } = new List(); + [InverseProperty(nameof(DriveFile.User))] public virtual ICollection DriveFiles { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(DriveFolder.User))] public virtual ICollection DriveFolders { get; set; } = new List(); - [InverseProperty("Followee")] - public virtual ICollection FollowRequestFollowees { get; set; } = new List(); + [InverseProperty(nameof(FollowRequest.Followee))] + public virtual ICollection IncomingFollowRequests { get; set; } = new List(); - [InverseProperty("Follower")] - public virtual ICollection FollowRequestFollowers { get; set; } = new List(); + [InverseProperty(nameof(FollowRequest.Follower))] + public virtual ICollection OutgoingFollowRequests { get; set; } = new List(); - [InverseProperty("Followee")] - public virtual ICollection FollowingFollowees { get; set; } = new List(); + [InverseProperty(nameof(Tables.Following.Followee))] + public virtual ICollection IncomingFollowRelationships { get; set; } = new List(); - [InverseProperty("Follower")] - public virtual ICollection FollowingFollowers { get; set; } = new List(); + [InverseProperty(nameof(Tables.Following.Follower))] + public virtual ICollection OutgoingFollowRelationships { get; set; } = new List(); - [InverseProperty("User")] + [Projectable] + public virtual IEnumerable Followers => IncomingFollowRelationships.Select(p => p.Follower); + + [Projectable] + public virtual IEnumerable Following => OutgoingFollowRelationships.Select(p => p.Followee); + + [Projectable] + public bool IsFollowedBy(User user) => Followers.Contains(user); + + [Projectable] + public bool IsFollowing(User user) => Following.Contains(user); + + [InverseProperty(nameof(GalleryLike.User))] public virtual ICollection GalleryLikes { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(GalleryPost.User))] public virtual ICollection GalleryPosts { get; set; } = new List(); - [InverseProperty("User")] public virtual HtmlUserCacheEntry? HtmlUserCacheEntry { get; set; } + [InverseProperty(nameof(Tables.HtmlUserCacheEntry.User))] public virtual HtmlUserCacheEntry? HtmlUserCacheEntry { get; set; } - [InverseProperty("Recipient")] + [InverseProperty(nameof(MessagingMessage.Recipient))] public virtual ICollection MessagingMessageRecipients { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(MessagingMessage.User))] public virtual ICollection MessagingMessageUsers { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(ModerationLog.User))] public virtual ICollection ModerationLogs { get; set; } = new List(); - [InverseProperty("Mutee")] public virtual ICollection MutingMutees { get; set; } = new List(); + [InverseProperty(nameof(Muting.Mutee))] public virtual ICollection MutingMutees { get; set; } = new List(); - [InverseProperty("Muter")] public virtual ICollection MutingMuters { get; set; } = new List(); + [InverseProperty(nameof(Muting.Muter))] public virtual ICollection MutingMuters { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(NoteFavorite.User))] public virtual ICollection NoteFavorites { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(NoteReaction.User))] public virtual ICollection NoteReactions { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(NoteThreadMuting.User))] public virtual ICollection NoteThreadMutings { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection NoteUnreads { get; set; } = new List(); + [InverseProperty(nameof(NoteUnread.User))] public virtual ICollection NoteUnreads { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(NoteWatching.User))] public virtual ICollection NoteWatchings { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Notes { get; set; } = new List(); + [InverseProperty(nameof(Note.User))] public virtual ICollection Notes { get; set; } = new List(); - [InverseProperty("Notifiee")] + [InverseProperty(nameof(Notification.Notifiee))] public virtual ICollection NotificationNotifiees { get; set; } = new List(); - [InverseProperty("Notifier")] + [InverseProperty(nameof(Notification.Notifier))] public virtual ICollection NotificationNotifiers { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection OauthTokens { get; set; } = new List(); + [InverseProperty(nameof(OauthToken.User))] public virtual ICollection OauthTokens { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection PageLikes { get; set; } = new List(); + [InverseProperty(nameof(PageLike.User))] public virtual ICollection PageLikes { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Pages { get; set; } = new List(); + [InverseProperty(nameof(Page.User))] public virtual ICollection Pages { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(PasswordResetRequest.User))] public virtual ICollection PasswordResetRequests { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection PollVotes { get; set; } = new List(); + [InverseProperty(nameof(PollVote.User))] public virtual ICollection PollVotes { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection PromoReads { get; set; } = new List(); + [InverseProperty(nameof(PromoRead.User))] public virtual ICollection PromoReads { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(RegistryItem.User))] public virtual ICollection RegistryItems { get; set; } = new List(); - [InverseProperty("Mutee")] + [InverseProperty(nameof(RenoteMuting.Mutee))] public virtual ICollection RenoteMutingMutees { get; set; } = new List(); - [InverseProperty("Muter")] + [InverseProperty(nameof(RenoteMuting.Muter))] public virtual ICollection RenoteMutingMuters { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Sessions { get; set; } = new List(); + [InverseProperty(nameof(Session.User))] public virtual ICollection Sessions { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Signins { get; set; } = new List(); + [InverseProperty(nameof(Signin.User))] public virtual ICollection Signins { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(SwSubscription.User))] public virtual ICollection SwSubscriptions { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(UserGroupInvitation.User))] public virtual ICollection UserGroupInvitations { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(UserGroupMember.User))] public virtual ICollection UserGroupMemberships { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection UserGroups { get; set; } = new List(); + [InverseProperty(nameof(UserGroup.User))] public virtual ICollection UserGroups { get; set; } = new List(); - [InverseProperty("User")] public virtual UserKeypair? UserKeypair { get; set; } + [InverseProperty(nameof(Tables.UserKeypair.User))] public virtual UserKeypair? UserKeypair { get; set; } - [InverseProperty("User")] + [InverseProperty(nameof(UserListMember.User))] public virtual ICollection UserListMembers { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection UserLists { get; set; } = new List(); + [InverseProperty(nameof(UserList.User))] public virtual ICollection UserLists { get; set; } = new List(); - [InverseProperty("User")] + [InverseProperty(nameof(UserNotePin.User))] public virtual ICollection UserNotePins { get; set; } = new List(); - [InverseProperty("User")] public virtual UserProfile? UserProfile { get; set; } + [InverseProperty(nameof(Tables.UserProfile.User))] public virtual UserProfile? UserProfile { get; set; } - [InverseProperty("User")] public virtual UserPublickey? UserPublickey { get; set; } + [InverseProperty(nameof(Tables.UserPublickey.User))] public virtual UserPublickey? UserPublickey { get; set; } - [InverseProperty("User")] + [InverseProperty(nameof(UserSecurityKey.User))] public virtual ICollection UserSecurityKeys { get; set; } = new List(); - [InverseProperty("User")] public virtual ICollection Webhooks { get; set; } = new List(); + [InverseProperty(nameof(Webhook.User))] public virtual ICollection Webhooks { get; set; } = new List(); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserGroup.cs b/Iceshrimp.Backend/Core/Database/Tables/UserGroup.cs index 1d47fb6e..336de81d 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserGroup.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserGroup.cs @@ -30,17 +30,17 @@ public class UserGroup { [Column("isPrivate")] public bool IsPrivate { get; set; } - [InverseProperty("Group")] + [InverseProperty(nameof(MessagingMessage.Group))] public virtual ICollection MessagingMessages { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("UserGroups")] + [InverseProperty(nameof(Tables.User.UserGroups))] public virtual User User { get; set; } = null!; - [InverseProperty("UserGroup")] + [InverseProperty(nameof(UserGroupInvitation.UserGroup))] public virtual ICollection UserGroupInvitations { get; set; } = new List(); - [InverseProperty("UserGroup")] + [InverseProperty(nameof(UserGroupMember.UserGroup))] public virtual ICollection UserGroupMembers { get; set; } = new List(); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserGroupInvitation.cs b/Iceshrimp.Backend/Core/Database/Tables/UserGroupInvitation.cs index ccdd3bc4..90c5a0f9 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserGroupInvitation.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserGroupInvitation.cs @@ -34,14 +34,14 @@ public class UserGroupInvitation { [StringLength(32)] public string UserGroupId { get; set; } = null!; - [InverseProperty("UserGroupInvitation")] + [InverseProperty(nameof(Notification.UserGroupInvitation))] public virtual ICollection Notifications { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("UserGroupInvitations")] + [InverseProperty(nameof(Tables.User.UserGroupInvitations))] public virtual User User { get; set; } = null!; [ForeignKey("UserGroupId")] - [InverseProperty("UserGroupInvitations")] + [InverseProperty(nameof(Tables.UserGroup.UserGroupInvitations))] public virtual UserGroup UserGroup { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserGroupMember.cs b/Iceshrimp.Backend/Core/Database/Tables/UserGroupMember.cs index 20fab7c5..6239b7d3 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserGroupMember.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserGroupMember.cs @@ -34,14 +34,14 @@ public class UserGroupMember { [StringLength(32)] public string UserGroupId { get; set; } = null!; - [InverseProperty("UserGroupMember")] + [InverseProperty(nameof(Antenna.UserGroupMember))] public virtual ICollection Antennas { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("UserGroupMemberships")] + [InverseProperty(nameof(Tables.User.UserGroupMemberships))] public virtual User User { get; set; } = null!; [ForeignKey("UserGroupId")] - [InverseProperty("UserGroupMembers")] + [InverseProperty(nameof(Tables.UserGroup.UserGroupMembers))] public virtual UserGroup UserGroup { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserKeypair.cs b/Iceshrimp.Backend/Core/Database/Tables/UserKeypair.cs index 7a2f109f..3242c87a 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserKeypair.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserKeypair.cs @@ -19,6 +19,6 @@ public class UserKeypair { public string PrivateKey { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("UserKeypair")] + [InverseProperty(nameof(Tables.User.UserKeypair))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserList.cs b/Iceshrimp.Backend/Core/Database/Tables/UserList.cs index 542eb321..e4124853 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserList.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserList.cs @@ -38,12 +38,12 @@ public class UserList { [Column("hideFromHomeTl")] public bool HideFromHomeTl { get; set; } - [InverseProperty("UserList")] public virtual ICollection Antennas { get; set; } = new List(); + [InverseProperty(nameof(Antenna.UserList))] public virtual ICollection Antennas { get; set; } = new List(); [ForeignKey("UserId")] - [InverseProperty("UserLists")] + [InverseProperty(nameof(Tables.User.UserLists))] public virtual User User { get; set; } = null!; - [InverseProperty("UserList")] + [InverseProperty(nameof(UserListMember.UserList))] public virtual ICollection UserListMembers { get; set; } = new List(); } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserListMember.cs b/Iceshrimp.Backend/Core/Database/Tables/UserListMember.cs index 1e8f6d44..92910c09 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserListMember.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserListMember.cs @@ -35,10 +35,10 @@ public class UserListMember { public string UserListId { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("UserListMembers")] + [InverseProperty(nameof(Tables.User.UserListMembers))] public virtual User User { get; set; } = null!; [ForeignKey("UserListId")] - [InverseProperty("UserListMembers")] + [InverseProperty(nameof(Tables.UserList.UserListMembers))] public virtual UserList UserList { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserNotePin.cs b/Iceshrimp.Backend/Core/Database/Tables/UserNotePin.cs index 93e56920..35ebea54 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserNotePin.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserNotePin.cs @@ -24,10 +24,10 @@ public class UserNotePin { [Column("noteId")] [StringLength(32)] public string NoteId { get; set; } = null!; [ForeignKey("NoteId")] - [InverseProperty("UserNotePins")] + [InverseProperty(nameof(Tables.Note.UserNotePins))] public virtual Note Note { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("UserNotePins")] + [InverseProperty(nameof(Tables.User.UserNotePins))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserProfile.cs b/Iceshrimp.Backend/Core/Database/Tables/UserProfile.cs index 01144b81..05f55006 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserProfile.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserProfile.cs @@ -155,11 +155,11 @@ public class UserProfile { public string Mentions { get; set; } = null!; [ForeignKey("PinnedPageId")] - [InverseProperty("UserProfile")] + [InverseProperty(nameof(Page.UserProfile))] public virtual Page? PinnedPage { get; set; } [ForeignKey("UserId")] - [InverseProperty("UserProfile")] + [InverseProperty(nameof(Tables.User.UserProfile))] public virtual User User { get; set; } = null!; [PgName("user_profile_ffvisibility_enum")] diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserPublickey.cs b/Iceshrimp.Backend/Core/Database/Tables/UserPublickey.cs index 58c0ef10..d8d4e3d2 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserPublickey.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserPublickey.cs @@ -19,6 +19,6 @@ public class UserPublickey { public string KeyPem { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("UserPublickey")] + [InverseProperty(nameof(Tables.User.UserPublickey))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/UserSecurityKey.cs b/Iceshrimp.Backend/Core/Database/Tables/UserSecurityKey.cs index c904fe10..64a8c479 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/UserSecurityKey.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/UserSecurityKey.cs @@ -37,6 +37,6 @@ public class UserSecurityKey { public string Name { get; set; } = null!; [ForeignKey("UserId")] - [InverseProperty("UserSecurityKeys")] + [InverseProperty(nameof(Tables.User.UserSecurityKeys))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Database/Tables/Webhook.cs b/Iceshrimp.Backend/Core/Database/Tables/Webhook.cs index 7810a259..c8a85457 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/Webhook.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/Webhook.cs @@ -50,6 +50,6 @@ public class Webhook { [Column("latestStatus")] public int? LatestStatus { get; set; } [ForeignKey("UserId")] - [InverseProperty("Webhooks")] + [InverseProperty(nameof(Tables.User.Webhooks))] public virtual User User { get; set; } = null!; } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Extensions/EnumerableExtensions.cs b/Iceshrimp.Backend/Core/Extensions/EnumerableExtensions.cs index 5908ac24..e69bcc9f 100644 --- a/Iceshrimp.Backend/Core/Extensions/EnumerableExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/EnumerableExtensions.cs @@ -1,16 +1,7 @@ -using Iceshrimp.Backend.Controllers.Mastodon.Renderers; -using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities; -using Iceshrimp.Backend.Core.Database.Tables; - namespace Iceshrimp.Backend.Core.Extensions; public static class EnumerableExtensions { public static async Task> AwaitAllAsync(this IEnumerable> tasks) { return await Task.WhenAll(tasks); } - - public static async Task> RenderAllForMastodonAsync( - this IEnumerable notes, NoteRenderer renderer) { - return await notes.Select(async p => await renderer.RenderAsync(p)).AwaitAllAsync(); - } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Core/Helpers/QueryHelpers.cs b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs similarity index 52% rename from Iceshrimp.Backend/Core/Helpers/QueryHelpers.cs rename to Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs index 0631ddb8..4d239cfd 100644 --- a/Iceshrimp.Backend/Core/Helpers/QueryHelpers.cs +++ b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs @@ -1,9 +1,11 @@ +using Iceshrimp.Backend.Controllers.Mastodon.Renderers; +using Iceshrimp.Backend.Controllers.Mastodon.Schemas.Entities; using Iceshrimp.Backend.Core.Database.Tables; using Microsoft.EntityFrameworkCore; -namespace Iceshrimp.Backend.Core.Helpers; +namespace Iceshrimp.Backend.Core.Extensions; -public static class QueryHelpers { +public static class NoteQueryableExtensions { public static IQueryable WithIncludes(this IQueryable query) { return query.Include(p => p.User) .Include(p => p.Renote) @@ -16,11 +18,17 @@ public static class QueryHelpers { return query.Where(note => note.Visibility == visibility); } - public static IQueryable IsFollowedBy(this IQueryable query, User user) { - return query.Where(note => note.User.FollowingFollowees.Any(following => following.Follower == user)); + public static IQueryable FilterByFollowingAndOwn(this IQueryable query, User user) { + return query.Where(note => note.User == user || note.User.IsFollowedBy(user)); } public static IQueryable OrderByIdDesc(this IQueryable query) { return query.OrderByDescending(note => note.Id); } + + public static async Task> RenderAllForMastodonAsync( + this IQueryable notes, NoteRenderer renderer) { + var list = await notes.ToListAsync(); + return await list.Select(renderer.RenderAsync).AwaitAllAsync(); + } } \ No newline at end of file diff --git a/Iceshrimp.Backend/Iceshrimp.Backend.csproj b/Iceshrimp.Backend/Iceshrimp.Backend.csproj index 37a40e1d..2de2c4a9 100644 --- a/Iceshrimp.Backend/Iceshrimp.Backend.csproj +++ b/Iceshrimp.Backend/Iceshrimp.Backend.csproj @@ -18,6 +18,7 @@ +