[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:
Lilian 2024-07-01 22:35:46 +02:00 committed by Iceshrimp development
parent ed767ecaff
commit ab2d02cfd3
No known key found for this signature in database
GPG key ID: 7249C94AE229BEAF

View file

@ -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>))]