diff --git a/Iceshrimp.Backend/Controllers/Web/MiscController.cs b/Iceshrimp.Backend/Controllers/Web/MiscController.cs new file mode 100644 index 00000000..b2f1bd74 --- /dev/null +++ b/Iceshrimp.Backend/Controllers/Web/MiscController.cs @@ -0,0 +1,40 @@ +using System.Net; +using System.Net.Mime; +using Iceshrimp.Backend.Controllers.Shared.Attributes; +using Iceshrimp.Backend.Controllers.Shared.Schemas; +using Iceshrimp.Backend.Controllers.Web.Renderers; +using Iceshrimp.Backend.Core.Database; +using Iceshrimp.Backend.Core.Extensions; +using Iceshrimp.Backend.Core.Middleware; +using Iceshrimp.Shared.Schemas.Web; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.RateLimiting; +using Microsoft.EntityFrameworkCore; + +namespace Iceshrimp.Backend.Controllers.Web; + +[ApiController] +[Authenticate] +[Authorize] +[EnableRateLimiting("sliding")] +[Route("/api/iceshrimp/misc")] +[Produces(MediaTypeNames.Application.Json)] +public class MiscController(DatabaseContext db, NoteRenderer noteRenderer) : ControllerBase +{ + [HttpGet("muted_threads")] + [LinkPagination(20, 40)] + [ProducesResults(HttpStatusCode.OK)] + public async Task> GetMutedThreads(PaginationQuery pq) + { + var user = HttpContext.GetUserOrFail(); + var notes = await db.Notes.IncludeCommonProperties() + .Where(p => db.NoteThreadMutings.Any(m => m.ThreadId == (p.ThreadId ?? p.Id))) + .EnsureVisibleFor(user) + .FilterHidden(user, db, false, false) + .Paginate(pq, ControllerContext) + .PrecomputeVisibilities(user) + .ToListAsync(); + + return await noteRenderer.RenderMany(notes.EnforceRenoteReplyVisibility(), user); + } +} \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/ControllerModels/MiscControllerModel.cs b/Iceshrimp.Frontend/Core/ControllerModels/MiscControllerModel.cs new file mode 100644 index 00000000..404775c4 --- /dev/null +++ b/Iceshrimp.Frontend/Core/ControllerModels/MiscControllerModel.cs @@ -0,0 +1,11 @@ +using Iceshrimp.Frontend.Core.Miscellaneous; +using Iceshrimp.Frontend.Core.Services; +using Iceshrimp.Shared.Schemas.Web; + +namespace Iceshrimp.Frontend.Core.ControllerModels; + +internal class MiscControllerModel(ApiClient api) +{ + public Task> GetMutedThreads(PaginationQuery pq) => + api.Call>(HttpMethod.Get, "/misc/muted_threads", pq); +} \ No newline at end of file diff --git a/Iceshrimp.Frontend/Core/Services/ApiService.cs b/Iceshrimp.Frontend/Core/Services/ApiService.cs index dcecae12..3b9ce10b 100644 --- a/Iceshrimp.Frontend/Core/Services/ApiService.cs +++ b/Iceshrimp.Frontend/Core/Services/ApiService.cs @@ -15,6 +15,7 @@ internal class ApiService(ApiClient client) public readonly TimelineControllerModel Timelines = new(client); public readonly UserControllerModel Users = new(client); public readonly FollowRequestControllerModel FollowRequests = new(client); + public readonly MiscControllerModel Misc = new(client); public void SetBearerToken(string token) => client.SetToken(token); } \ No newline at end of file