[backend/api] Add Note delete endpoint (ISH-394)
Co-authored-by: Lilian <lilian@blahaj.space> Co-committed-by: Lilian <lilian@blahaj.space>
This commit is contained in:
parent
ed767ecaff
commit
ab2d02cfd3
1 changed files with 15 additions and 0 deletions
|
@ -53,6 +53,21 @@ public class NoteController(
|
|||
return Ok(await noteRenderer.RenderOne(note.EnforceRenoteReplyVisibility(), user));
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
[Authenticate]
|
||||
[Authorize]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(ErrorResponse))]
|
||||
public async Task<IActionResult> DeleteNote(string id)
|
||||
{
|
||||
var user = HttpContext.GetUserOrFail();
|
||||
var note = await db.Notes.FirstOrDefaultAsync(p => p.Id == id && p.User == user) ??
|
||||
throw GracefulException.NotFound("Note not found");
|
||||
|
||||
await noteSvc.DeleteNoteAsync(note);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpGet("{id}/ascendants")]
|
||||
[Authenticate]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable<NoteResponse>))]
|
||||
|
|
Loading…
Add table
Reference in a new issue