mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-12-13 22:00:29 +05:30
Add some parameter checking to search and feed routes. (#294)
This commit is contained in:
parent
374d067a95
commit
943e4a3de8
@ -491,6 +491,9 @@ public class ResponseHelper {
|
||||
public static byte[] suggestionsResponse(String query)
|
||||
throws IOException, ExtractionException {
|
||||
|
||||
if (StringUtils.isEmpty(query))
|
||||
return mapper.writeValueAsBytes(new InvalidRequestResponse());
|
||||
|
||||
return mapper.writeValueAsBytes(YOUTUBE_SERVICE.getSuggestionExtractor().suggestionList(query));
|
||||
|
||||
}
|
||||
@ -498,6 +501,9 @@ public class ResponseHelper {
|
||||
public static byte[] opensearchSuggestionsResponse(String query)
|
||||
throws IOException, ExtractionException {
|
||||
|
||||
if (StringUtils.isEmpty(query))
|
||||
return mapper.writeValueAsBytes(new InvalidRequestResponse());
|
||||
|
||||
return mapper.writeValueAsBytes(Arrays.asList(
|
||||
query,
|
||||
YOUTUBE_SERVICE.getSuggestionExtractor().suggestionList(query)
|
||||
@ -836,6 +842,9 @@ public class ResponseHelper {
|
||||
|
||||
public static byte[] feedResponse(String session) throws IOException {
|
||||
|
||||
if (StringUtils.isBlank(session))
|
||||
return mapper.writeValueAsBytes(new AuthenticationFailureResponse());
|
||||
|
||||
User user = DatabaseHelper.getUserFromSession(session);
|
||||
|
||||
if (user != null) {
|
||||
@ -876,6 +885,9 @@ public class ResponseHelper {
|
||||
|
||||
public static byte[] feedResponseRSS(String session) throws IOException, FeedException {
|
||||
|
||||
if (StringUtils.isBlank(session))
|
||||
return mapper.writeValueAsBytes(new AuthenticationFailureResponse());
|
||||
|
||||
User user = DatabaseHelper.getUserFromSession(session);
|
||||
|
||||
if (user != null) {
|
||||
@ -1062,7 +1074,7 @@ public class ResponseHelper {
|
||||
s.remove(playlist);
|
||||
tr.commit();
|
||||
|
||||
Multithreading.runAsync(() -> pruneUnusedPlaylistVideos());
|
||||
Multithreading.runAsync(ResponseHelper::pruneUnusedPlaylistVideos);
|
||||
}
|
||||
|
||||
return mapper.writeValueAsBytes(new AcceptedResponse());
|
||||
|
Loading…
Reference in New Issue
Block a user