mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-12-13 22:00:29 +05:30
When parameter is not provided, throw an ErrorResponse.
This commit is contained in:
parent
030acc1eb3
commit
22dcf7a88e
@ -18,10 +18,7 @@ import me.kavin.piped.server.handlers.auth.AuthPlaylistHandlers;
|
||||
import me.kavin.piped.server.handlers.auth.FeedHandlers;
|
||||
import me.kavin.piped.server.handlers.auth.UserHandlers;
|
||||
import me.kavin.piped.utils.*;
|
||||
import me.kavin.piped.utils.resp.DeleteUserRequest;
|
||||
import me.kavin.piped.utils.resp.LoginRequest;
|
||||
import me.kavin.piped.utils.resp.StackTraceResponse;
|
||||
import me.kavin.piped.utils.resp.SubscriptionUpdateRequest;
|
||||
import me.kavin.piped.utils.resp.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.hibernate.Session;
|
||||
@ -289,7 +286,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
||||
})).map(GET, "/feed/unauthenticated", AsyncServlet.ofBlocking(executor, request -> {
|
||||
try {
|
||||
return getJsonResponse(FeedHandlers.unauthenticatedFeedResponse(
|
||||
Objects.requireNonNull(request.getQueryParameter("channels")).split(",")
|
||||
getArray(request.getQueryParameter("channels"))
|
||||
), "public, s-maxage=120");
|
||||
} catch (Exception e) {
|
||||
return getErrorResponse(e, request.getPath());
|
||||
@ -297,7 +294,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
||||
})).map(GET, "/feed/unauthenticated/rss", AsyncServlet.ofBlocking(executor, request -> {
|
||||
try {
|
||||
return getRawResponse(FeedHandlers.unauthenticatedFeedResponseRSS(
|
||||
Objects.requireNonNull(request.getQueryParameter("channels")).split(",")
|
||||
getArray(request.getQueryParameter("channels"))
|
||||
), "application/atom+xml", "public, s-maxage=120");
|
||||
} catch (Exception e) {
|
||||
return getErrorResponse(e, request.getPath());
|
||||
@ -409,6 +406,15 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
|
||||
return new CustomServletDecorator(router);
|
||||
}
|
||||
|
||||
private static String[] getArray(String s) {
|
||||
|
||||
if (s == null) {
|
||||
ExceptionHandler.throwErrorResponse(new InvalidRequestResponse());
|
||||
}
|
||||
|
||||
return s.split(",");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Module getOverrideModule() {
|
||||
return new AbstractModule() {
|
||||
|
Loading…
Reference in New Issue
Block a user