From f45d4978ccdb062efcc8b2fe9fca5b6a9eddeb2e Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Thu, 22 Feb 2024 17:59:10 +0100 Subject: [PATCH] [backend/masto-client] Support renote visibility parameter --- .../Controllers/Mastodon/StatusController.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs b/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs index e6508a28..b7f87866 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/StatusController.cs @@ -126,7 +126,7 @@ public class StatusController( [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] - public async Task Renote(string id) + public async Task Renote(string id, [FromHybrid] string? visibility) { var user = HttpContext.GetUserOrFail(); if (!await db.Notes.AnyAsync(p => p.RenoteId == id && p.User == user && p.IsPureRenote)) @@ -137,7 +137,14 @@ public class StatusController( .FirstOrDefaultAsync() ?? throw GracefulException.RecordNotFound(); - await noteSvc.CreateNoteAsync(user, Note.NoteVisibility.Followers, renote: note); + var renoteVisibility = visibility != null + ? StatusEntity.DecodeVisibility(visibility) + : Note.NoteVisibility.Followers; + + if (renoteVisibility == Note.NoteVisibility.Specified) + throw GracefulException.BadRequest("Renote visibility must be one of: public, unlisted, private"); + + await noteSvc.CreateNoteAsync(user, renoteVisibility, renote: note); } return await GetNote(id);