[backend/core] Emit note edit notification for polls that have been voted in
This commit is contained in:
parent
081f1ac646
commit
10d1cb4768
2 changed files with 17 additions and 5 deletions
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue