From 022a0af00713380be333f78ee71671e6d239ca58 Mon Sep 17 00:00:00 2001 From: FireMaskterK <20838718+FireMasterK@users.noreply.github.com> Date: Sun, 10 Oct 2021 00:24:29 +0100 Subject: [PATCH] Include search corrections in API. --- src/main/java/me/kavin/piped/utils/ResponseHelper.java | 4 ++-- .../java/me/kavin/piped/utils/obj/SearchResults.java | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index 06b38fe..833b99f 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -407,8 +407,8 @@ public class ResponseHelper { Page nextpage = info.getNextPage(); - return Constants.mapper - .writeValueAsBytes(new SearchResults(items, Constants.mapper.writeValueAsString(nextpage))); + return Constants.mapper.writeValueAsBytes(new SearchResults(items, + Constants.mapper.writeValueAsString(nextpage), info.getSearchSuggestion(), info.isCorrectedSearch())); } diff --git a/src/main/java/me/kavin/piped/utils/obj/SearchResults.java b/src/main/java/me/kavin/piped/utils/obj/SearchResults.java index 718e639..72c2728 100644 --- a/src/main/java/me/kavin/piped/utils/obj/SearchResults.java +++ b/src/main/java/me/kavin/piped/utils/obj/SearchResults.java @@ -5,10 +5,18 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; public class SearchResults { public ObjectArrayList items; - public String nextpage; + public String nextpage, suggestion; + public boolean corrected; public SearchResults(ObjectArrayList items, String nextpage) { this.nextpage = nextpage; this.items = items; } + + public SearchResults(ObjectArrayList items, String nextpage, String suggestion, boolean corrected) { + this.items = items; + this.nextpage = nextpage; + this.suggestion = suggestion; + this.corrected = corrected; + } }