From dfa47f2a1257901b3ee9fa4a44e4e897695d2477 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 18 Feb 2024 01:38:37 +0100 Subject: [PATCH] [backend/masto-client] Rename PaginationQuery to MastodonPaginationQuery --- .../Controllers/Attributes/LinkPaginationAttribute.cs | 2 +- .../Controllers/Mastodon/AccountController.cs | 8 ++++---- .../Controllers/Mastodon/NotificationController.cs | 2 +- .../{PaginationQuery.cs => MastodonPaginationQuery.cs} | 2 +- .../Controllers/Mastodon/SearchController.cs | 6 +++--- .../Controllers/Mastodon/TimelineController.cs | 4 ++-- Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) rename Iceshrimp.Backend/Controllers/Mastodon/Schemas/{PaginationQuery.cs => MastodonPaginationQuery.cs} (92%) diff --git a/Iceshrimp.Backend/Controllers/Attributes/LinkPaginationAttribute.cs b/Iceshrimp.Backend/Controllers/Attributes/LinkPaginationAttribute.cs index 8678d805..4429d97a 100644 --- a/Iceshrimp.Backend/Controllers/Attributes/LinkPaginationAttribute.cs +++ b/Iceshrimp.Backend/Controllers/Attributes/LinkPaginationAttribute.cs @@ -26,7 +26,7 @@ public class LinkPaginationAttribute(int defaultLimit, int maxLimit) : ActionFil { if (actionArguments.Count == 0) return; - var query = actionArguments.Values.OfType().FirstOrDefault(); + var query = actionArguments.Values.OfType().FirstOrDefault(); if (query == null) return; if (context.Result is not OkObjectResult result) return; diff --git a/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs b/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs index 4ab30dc3..f81297cf 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/AccountController.cs @@ -279,7 +279,7 @@ public class AccountController( [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] public async Task GetUserStatuses( string id, AccountSchemas.AccountStatusesRequest request, - PaginationQuery query + MastodonPaginationQuery query ) { var user = HttpContext.GetUserOrFail(); @@ -302,7 +302,7 @@ public class AccountController( [LinkPagination(40, 80)] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] - public async Task GetUserFollowers(string id, PaginationQuery query) + public async Task GetUserFollowers(string id, MastodonPaginationQuery query) { var user = HttpContext.GetUser(); var account = await db.Users @@ -334,7 +334,7 @@ public class AccountController( [LinkPagination(40, 80)] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] - public async Task GetUserFollowing(string id, PaginationQuery query) + public async Task GetUserFollowing(string id, MastodonPaginationQuery query) { var user = HttpContext.GetUser(); var account = await db.Users @@ -367,7 +367,7 @@ public class AccountController( [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] [ProducesResponseType(StatusCodes.Status401Unauthorized, Type = typeof(MastodonErrorResponse))] [ProducesResponseType(StatusCodes.Status403Forbidden, Type = typeof(MastodonErrorResponse))] - public async Task GetFollowRequests(PaginationQuery query) + public async Task GetFollowRequests(MastodonPaginationQuery query) { var user = HttpContext.GetUserOrFail(); var res = await db.FollowRequests diff --git a/Iceshrimp.Backend/Controllers/Mastodon/NotificationController.cs b/Iceshrimp.Backend/Controllers/Mastodon/NotificationController.cs index a1284cb7..0c1d9069 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/NotificationController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/NotificationController.cs @@ -27,7 +27,7 @@ public class NotificationController(DatabaseContext db, NotificationRenderer not [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(List))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] - public async Task GetNotifications(PaginationQuery query) + public async Task GetNotifications(MastodonPaginationQuery query) { var user = HttpContext.GetUserOrFail(); var res = await db.Notifications diff --git a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/PaginationQuery.cs b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/MastodonPaginationQuery.cs similarity index 92% rename from Iceshrimp.Backend/Controllers/Mastodon/Schemas/PaginationQuery.cs rename to Iceshrimp.Backend/Controllers/Mastodon/Schemas/MastodonPaginationQuery.cs index 2645bfb3..1c674632 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/Schemas/PaginationQuery.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/Schemas/MastodonPaginationQuery.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Mvc; namespace Iceshrimp.Backend.Controllers.Mastodon.Schemas; -public class PaginationQuery +public class MastodonPaginationQuery { [FromQuery(Name = "max_id")] public string? MaxId { get; set; } [FromQuery(Name = "since_id")] public string? SinceId { get; set; } diff --git a/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs b/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs index 108cd305..4b9fce70 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/SearchController.cs @@ -35,7 +35,7 @@ public class SearchController( [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(SearchSchemas.SearchResponse))] [ProducesResponseType(StatusCodes.Status404NotFound, Type = typeof(MastodonErrorResponse))] - public async Task Search(SearchSchemas.SearchRequest search, PaginationQuery pagination) + public async Task Search(SearchSchemas.SearchRequest search, MastodonPaginationQuery pagination) { if (search.Query == null) throw GracefulException.BadRequest("Query is missing or invalid"); @@ -54,7 +54,7 @@ public class SearchController( Justification = "Inspection doesn't know about the Projectable attribute")] private async Task> SearchUsersAsync( SearchSchemas.SearchRequest search, - PaginationQuery pagination + MastodonPaginationQuery pagination ) { var user = HttpContext.GetUserOrFail(); @@ -122,7 +122,7 @@ public class SearchController( Justification = "Inspection doesn't know about the Projectable attribute")] private async Task> SearchNotesAsync( SearchSchemas.SearchRequest search, - PaginationQuery pagination + MastodonPaginationQuery pagination ) { var user = HttpContext.GetUserOrFail(); diff --git a/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs b/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs index 4d629b00..66fe331b 100644 --- a/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs +++ b/Iceshrimp.Backend/Controllers/Mastodon/TimelineController.cs @@ -29,7 +29,7 @@ public class TimelineController(DatabaseContext db, NoteRenderer noteRenderer, I [HttpGet("home")] [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] - public async Task GetHomeTimeline(PaginationQuery query) + public async Task GetHomeTimeline(MastodonPaginationQuery query) { var user = HttpContext.GetUserOrFail(); var heuristic = await QueryableExtensions.GetHeuristic(user, db, cache); @@ -52,7 +52,7 @@ public class TimelineController(DatabaseContext db, NoteRenderer noteRenderer, I [HttpGet("public")] [Produces("application/json")] [ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IEnumerable))] - public async Task GetPublicTimeline(PaginationQuery query) + public async Task GetPublicTimeline(MastodonPaginationQuery query) { var user = HttpContext.GetUserOrFail(); diff --git a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs index a3b6b107..e32acd77 100644 --- a/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs +++ b/Iceshrimp.Backend/Core/Extensions/QueryableExtensions.cs @@ -17,7 +17,7 @@ public static class QueryableExtensions { public static IQueryable Paginate( this IQueryable query, - PaginationQuery pq, + MastodonPaginationQuery pq, int defaultLimit, int maxLimit ) where T : IEntity