[backend/api] Add renotes endpoint

This commit is contained in:
Lilian 2024-09-24 00:48:10 +02:00
parent f15e1d5bb5
commit a30693e596
No known key found for this signature in database

View file

@ -274,6 +274,31 @@ public class NoteController(
return new ValueResponse(note.RenoteCount - count); return new ValueResponse(note.RenoteCount - count);
} }
[HttpGet("{id}/renotes")]
[Authenticate]
[Authorize]
[ProducesResults(HttpStatusCode.OK)]
[ProducesErrors(HttpStatusCode.NotFound)]
public async Task<IEnumerable<UserResponse>> GetRenotes(string id)
{
var user = HttpContext.GetUser();
var note = await db.Notes
.Where(p => p.Id == id)
.EnsureVisibleFor(user)
.FirstOrDefaultAsync() ??
throw GracefulException.NotFound("Note not found");
var users = await db.Notes
.Where(p => p.Renote == note && p.IsPureRenote)
.EnsureVisibleFor(user)
.Include(p => p.User.UserProfile)
.FilterHidden(user, db)
.Select(p => p.User)
.ToListAsync();
return await userRenderer.RenderMany(users);
}
[HttpPost("{id}/react/{name}")] [HttpPost("{id}/react/{name}")]
[Authenticate] [Authenticate]
[Authorize] [Authorize]