diff --git a/Iceshrimp.Backend/Core/Database/Tables/User.cs b/Iceshrimp.Backend/Core/Database/Tables/User.cs index 84037f70..5ed05a0f 100644 --- a/Iceshrimp.Backend/Core/Database/Tables/User.cs +++ b/Iceshrimp.Backend/Core/Database/Tables/User.cs @@ -573,10 +573,13 @@ public class User : IEntity public bool HasReacted(Note note) => ReactedNotes.Contains(note); [Projectable] - public bool HasRenoted(Note note) => Notes.Any(p => p.Renote == note); + public bool HasRenoted(Note note) => Notes.Any(p => p.Renote == note && p.User == this); [Projectable] - public bool HasReplied(Note note) => Notes.Any(p => p.Reply == note); + public bool HasReplied(Note note) => Notes.Any(p => p.Reply == note && p.User == this); + + [Projectable] + public bool HasVoted(Note note) => PollVotes.Any(p => p.Note == note && p.User == this); [Projectable] public bool HasInteractedWith(Note note) => @@ -584,7 +587,8 @@ public class User : IEntity HasReacted(note) || HasBookmarked(note) || HasReplied(note) || - HasRenoted(note); + HasRenoted(note) || + HasVoted(note); public User WithPrecomputedBlockStatus(bool blocking, bool blockedBy) { diff --git a/Iceshrimp.Backend/Core/Services/NoteService.cs b/Iceshrimp.Backend/Core/Services/NoteService.cs index b6b79762..100d8d27 100644 --- a/Iceshrimp.Backend/Core/Services/NoteService.cs +++ b/Iceshrimp.Backend/Core/Services/NoteService.cs @@ -449,17 +449,25 @@ public class NoteService( } } - if (asNote is not ASQuestion || poll == null || isPollEdited || db.Entry(note).State != EntityState.Unchanged) + var isEdit = asNote is not ASQuestion || + poll == null || + isPollEdited || + db.Entry(note).State != EntityState.Unchanged; + + if (isEdit) { note.UpdatedAt = updatedAt ?? DateTime.UtcNow; await db.AddAsync(noteEdit); } await db.SaveChangesAsync(); + eventSvc.RaiseNoteUpdated(this, note); + + if (!isEdit) return note; + await notificationSvc.GenerateMentionNotifications(note, mentionedLocalUserIds); await notificationSvc.GenerateReplyNotifications(note, mentionedLocalUserIds); await notificationSvc.GenerateEditNotifications(note); - eventSvc.RaiseNoteUpdated(this, note); if (note.LocalOnly || note.User.Host != null) return note;