[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,13 +129,17 @@ public class StatusController(
public async Task<IActionResult> Renote(string id) public async Task<IActionResult> Renote(string id)
{ {
var user = HttpContext.GetUserOrFail(); var user = HttpContext.GetUserOrFail();
var note = await db.Notes.Where(p => p.Id == id) if (!await db.Notes.AnyAsync(p => p.RenoteId == id && p.User == user && p.IsPureRenote))
.IncludeCommonProperties() {
.EnsureVisibleFor(user) var note = await db.Notes.Where(p => p.Id == id)
.FirstOrDefaultAsync() ?? .IncludeCommonProperties()
throw GracefulException.RecordNotFound(); .EnsureVisibleFor(user)
.FirstOrDefaultAsync() ??
throw GracefulException.RecordNotFound();
await noteSvc.CreateNoteAsync(user, Note.NoteVisibility.Followers, renote: note);
}
await noteSvc.CreateNoteAsync(user, Note.NoteVisibility.Followers, renote: note);
return await GetNote(id); return await GetNote(id);
} }