[backend/api] Prevent users from biting notes they can't see

This commit is contained in:
pancakes 2024-10-19 15:27:26 +10:00 committed by Iceshrimp development
parent 30ff0d77b2
commit 82ed8b583b

View file

@ -162,7 +162,11 @@ public class NoteController(
if (user.Id == id)
throw GracefulException.BadRequest("You cannot bite your own note");
var target = await db.Notes.Where(p => p.Id == id).IncludeCommonProperties().FirstOrDefaultAsync() ??
var target = await db.Notes
.Where(p => p.Id == id)
.IncludeCommonProperties()
.EnsureVisibleFor(user)
.FirstOrDefaultAsync() ??
throw GracefulException.NotFound("Note not found");
await biteSvc.BiteAsync(user, target);