[backend/masto-client] Reblog endpoint should be idempotent

This commit is contained in:
Laura Hausmann 2024-02-22 17:39:09 +01:00
parent e14686ea8c
commit 780ffa076d
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -129,6 +129,8 @@ public class StatusController(
public async Task<IActionResult> Renote(string id)
{
var user = HttpContext.GetUserOrFail();
if (!await db.Notes.AnyAsync(p => p.RenoteId == id && p.User == user && p.IsPureRenote))
{
var note = await db.Notes.Where(p => p.Id == id)
.IncludeCommonProperties()
.EnsureVisibleFor(user)
@ -136,6 +138,8 @@ public class StatusController(
throw GracefulException.RecordNotFound();
await noteSvc.CreateNoteAsync(user, Note.NoteVisibility.Followers, renote: note);
}
return await GetNote(id);
}