[backend/core] Replace sync DB call with async equivalent

This commit is contained in:
Laura Hausmann 2024-06-10 19:42:06 +02:00
parent 173b01fbf3
commit dc8511632b
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -347,7 +347,9 @@ public class NoteService(
if (note is { Renote.Id: not null, IsPureRenote: true }) if (note is { Renote.Id: not null, IsPureRenote: true })
{ {
if (!db.Notes.Any(p => p.UserId == note.User.Id && p.RenoteId == note.Renote.Id && p.IsPureRenote)) if (!await db.Notes.AnyAsync(p => p.UserId == note.User.Id &&
p.RenoteId == note.Renote.Id &&
p.IsPureRenote))
{ {
await db.Notes.Where(p => p.Id == note.Renote.Id) await db.Notes.Where(p => p.Id == note.Renote.Id)
.ExecuteUpdateAsync(p => p.SetProperty(n => n.RenoteCount, n => n.RenoteCount + diff)); .ExecuteUpdateAsync(p => p.SetProperty(n => n.RenoteCount, n => n.RenoteCount + diff));