[backend/api-shared] Don't dispose DbContext prematurely in streaming connection handlers

This commit is contained in:
Laura Hausmann 2024-07-13 15:59:35 +02:00
parent bba0ea79cd
commit 9233e43b81
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 2 additions and 2 deletions

View file

@ -370,7 +370,7 @@ public sealed class WebSocketConnection(
{ {
if (note.Reply == null) return false; if (note.Reply == null) return false;
if (note.User.Id == Token.UserId) return false; if (note.User.Id == Token.UserId) return false;
await using var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>(); var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
return await db.NoteThreadMutings.AnyAsync(p => p.UserId == Token.UserId && p.ThreadId == note.ThreadId); return await db.NoteThreadMutings.AnyAsync(p => p.UserId == Token.UserId && p.ThreadId == note.ThreadId);
} }

View file

@ -157,7 +157,7 @@ public sealed class StreamingConnectionAggregate : IDisposable
{ {
if (note.Reply == null) return false; if (note.Reply == null) return false;
if (note.User.Id == _userId) return false; if (note.User.Id == _userId) return false;
await using var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>(); var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
return await db.NoteThreadMutings.AnyAsync(p => p.UserId == _userId && p.ThreadId == note.ThreadId); return await db.NoteThreadMutings.AnyAsync(p => p.UserId == _userId && p.ThreadId == note.ThreadId);
} }