[backend/masto-client] Reblog endpoint should be idempotent
This commit is contained in:
parent
e14686ea8c
commit
780ffa076d
1 changed files with 10 additions and 6 deletions
|
@ -129,13 +129,17 @@ public class StatusController(
|
|||
public async Task<IActionResult> Renote(string id)
|
||||
{
|
||||
var user = HttpContext.GetUserOrFail();
|
||||
var note = await db.Notes.Where(p => p.Id == id)
|
||||
.IncludeCommonProperties()
|
||||
.EnsureVisibleFor(user)
|
||||
.FirstOrDefaultAsync() ??
|
||||
throw GracefulException.RecordNotFound();
|
||||
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)
|
||||
.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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue