Rename PlayRequest/PlayResponse to QueueRequest/QueueResponse
Updated DTOs and endpoint logic to reflect the separation of search result resolution and playback queuing. Adjusted references to `/play` and `/play/select` routes, replacing them with clearer `/search` and `/queue` endpoints in comments, documentation, and API definitions.
This commit is contained in:
1 parent
a605a834b4
commit
1dca5b898a
5 files changed
+11
-11
No files matched your search
@@ -22,8 +22,8 @@ import me.bobert.netneutrality.http.server.dto.CommandResultResponse;
|
|||||||
import me.bobert.netneutrality.http.server.dto.ErrorResponse;
|
import me.bobert.netneutrality.http.server.dto.ErrorResponse;
|
||||||
import me.bobert.netneutrality.http.server.dto.MusicSourceResponse;
|
import me.bobert.netneutrality.http.server.dto.MusicSourceResponse;
|
||||||
import me.bobert.netneutrality.http.server.dto.MusicStatusResponse;
|
import me.bobert.netneutrality.http.server.dto.MusicStatusResponse;
|
||||||
import me.bobert.netneutrality.http.server.dto.PlayRequest;
|
import me.bobert.netneutrality.http.server.dto.QueueRequest;
|
||||||
import me.bobert.netneutrality.http.server.dto.PlayResponse;
|
import me.bobert.netneutrality.http.server.dto.QueueResponse;
|
||||||
import me.bobert.netneutrality.http.server.dto.QueuedTrackResponse;
|
import me.bobert.netneutrality.http.server.dto.QueuedTrackResponse;
|
||||||
import me.bobert.netneutrality.http.server.dto.SearchRequest;
|
import me.bobert.netneutrality.http.server.dto.SearchRequest;
|
||||||
import me.bobert.netneutrality.http.server.dto.VolumeRequest;
|
import me.bobert.netneutrality.http.server.dto.VolumeRequest;
|
||||||
@@ -278,9 +278,9 @@ public final class MusicRoutes {
|
|||||||
summary = "Queue a previously returned search candidate by passing the searchId/index returned by /music/{guildId}/search; the bot must already be connected to a voice channel in this guild",
|
summary = "Queue a previously returned search candidate by passing the searchId/index returned by /music/{guildId}/search; the bot must already be connected to a voice channel in this guild",
|
||||||
tags = {"Music"},
|
tags = {"Music"},
|
||||||
pathParams = @OpenApiParam(name = "guildId", description = "The Discord guild id"),
|
pathParams = @OpenApiParam(name = "guildId", description = "The Discord guild id"),
|
||||||
requestBody = @OpenApiRequestBody(content = @OpenApiContent(from = PlayRequest.class)),
|
requestBody = @OpenApiRequestBody(content = @OpenApiContent(from = QueueRequest.class)),
|
||||||
responses = {
|
responses = {
|
||||||
@OpenApiResponse(status = "200", content = @OpenApiContent(from = PlayResponse.class)),
|
@OpenApiResponse(status = "200", content = @OpenApiContent(from = QueueResponse.class)),
|
||||||
@OpenApiResponse(status = "400", content = @OpenApiContent(from = ErrorResponse.class)),
|
@OpenApiResponse(status = "400", content = @OpenApiContent(from = ErrorResponse.class)),
|
||||||
@OpenApiResponse(status = "404", content = @OpenApiContent(from = ErrorResponse.class))
|
@OpenApiResponse(status = "404", content = @OpenApiContent(from = ErrorResponse.class))
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ public final class MusicRoutes {
|
|||||||
private static void play(Supplier<JDA> jdaSupplier, MusicService musicService, Context ctx) {
|
private static void play(Supplier<JDA> jdaSupplier, MusicService musicService, Context ctx) {
|
||||||
Guild guild = GuildRoutes.guild(jdaSupplier, ctx);
|
Guild guild = GuildRoutes.guild(jdaSupplier, ctx);
|
||||||
MusicManager manager = musicService.get(guild);
|
MusicManager manager = musicService.get(guild);
|
||||||
PlayRequest body = ctx.bodyAsClass(PlayRequest.class);
|
QueueRequest body = ctx.bodyAsClass(QueueRequest.class);
|
||||||
String userId = requireNonBlank(body.userId(), "userId");
|
String userId = requireNonBlank(body.userId(), "userId");
|
||||||
requireNonBlank(body.searchId(), "searchId");
|
requireNonBlank(body.searchId(), "searchId");
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ public final class MusicRoutes {
|
|||||||
pathParams = @OpenApiParam(name = "guildId", description = "The Discord guild id"),
|
pathParams = @OpenApiParam(name = "guildId", description = "The Discord guild id"),
|
||||||
requestBody = @OpenApiRequestBody(content = @OpenApiContent(from = SearchRequest.class)),
|
requestBody = @OpenApiRequestBody(content = @OpenApiContent(from = SearchRequest.class)),
|
||||||
responses = {
|
responses = {
|
||||||
@OpenApiResponse(status = "200", content = @OpenApiContent(from = PlayResponse.class)),
|
@OpenApiResponse(status = "200", content = @OpenApiContent(from = QueueResponse.class)),
|
||||||
@OpenApiResponse(status = "400", content = @OpenApiContent(from = ErrorResponse.class)),
|
@OpenApiResponse(status = "400", content = @OpenApiContent(from = ErrorResponse.class)),
|
||||||
@OpenApiResponse(status = "404", content = @OpenApiContent(from = ErrorResponse.class))
|
@OpenApiResponse(status = "404", content = @OpenApiContent(from = ErrorResponse.class))
|
||||||
}
|
}
|
||||||
@@ -342,7 +342,7 @@ public final class MusicRoutes {
|
|||||||
* #play(Supplier, MusicService, Context)} when the request body carries a {@code searchId}.
|
* #play(Supplier, MusicService, Context)} when the request body carries a {@code searchId}.
|
||||||
* Exposed via the {@code /music/{guildId}/queue} POST endpoint.
|
* Exposed via the {@code /music/{guildId}/queue} POST endpoint.
|
||||||
*/
|
*/
|
||||||
private static void playSelect(Guild guild, MusicManager manager, PlayRequest body, String userId, Context ctx) {
|
private static void playSelect(Guild guild, MusicManager manager, QueueRequest body, String userId, Context ctx) {
|
||||||
String searchId = body.searchId();
|
String searchId = body.searchId();
|
||||||
Integer index = body.index();
|
Integer index = body.index();
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ package me.bobert.netneutrality.http.server.dto;
|
|||||||
* @param searchId a search id previously returned by {@code /music/{guildId}/search}
|
* @param searchId a search id previously returned by {@code /music/{guildId}/search}
|
||||||
* @param index the index of the candidate to queue within the {@code searchId}'s results
|
* @param index the index of the candidate to queue within the {@code searchId}'s results
|
||||||
*/
|
*/
|
||||||
public record PlayRequest(
|
public record QueueRequest(
|
||||||
String userId,
|
String userId,
|
||||||
String searchId,
|
String searchId,
|
||||||
Integer index
|
Integer index
|
||||||
+1
-1
@@ -20,7 +20,7 @@ import java.util.List;
|
|||||||
* pending_playlist} fills {@code search_id}/{@code tracks}/{@code truncated}, and {@code
|
* pending_playlist} fills {@code search_id}/{@code tracks}/{@code truncated}, and {@code
|
||||||
* pending_search} fills {@code search_id}/{@code candidates}.
|
* pending_search} fills {@code search_id}/{@code candidates}.
|
||||||
*/
|
*/
|
||||||
public record PlayResponse(
|
public record QueueResponse(
|
||||||
String status,
|
String status,
|
||||||
TrackSummaryResponse track,
|
TrackSummaryResponse track,
|
||||||
Integer queue_position,
|
Integer queue_position,
|
||||||
@@ -16,7 +16,7 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
* <p>Nothing is ever queued directly: every resolved query, whether a single track, a playlist,
|
* <p>Nothing is ever queued directly: every resolved query, whether a single track, a playlist,
|
||||||
* or an ambiguous search, is stashed in {@link PendingSearchResults} and must be confirmed via a
|
* or an ambiguous search, is stashed in {@link PendingSearchResults} and must be confirmed via a
|
||||||
* separate {@code /play} call carrying the returned {@code searchId}/{@code index}.
|
* separate {@code /music/{guildId}/queue} call carrying the returned {@code searchId}/{@code index}.
|
||||||
*/
|
*/
|
||||||
public sealed interface PlayOutcome {
|
public sealed interface PlayOutcome {
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
/**
|
/**
|
||||||
* Translates a Lavalink load result into a {@link PlayOutcome} without ever queuing anything, so
|
* Translates a Lavalink load result into a {@link PlayOutcome} without ever queuing anything, so
|
||||||
* that every REST load request, not only ambiguous text searches, requires a separate
|
* that every REST load request, not only ambiguous text searches, requires a separate
|
||||||
* {@code /play} call with {@code searchId}/{@code index} to actually queue a track.
|
* {@code /music/{guildId}/queue} call with {@code searchId}/{@code index} to actually queue a track.
|
||||||
*
|
*
|
||||||
* <p>A single resolved track, the tracks of a playlist, and ambiguous search results are each
|
* <p>A single resolved track, the tracks of a playlist, and ambiguous search results are each
|
||||||
* stashed as candidates in {@link PendingSearchResults} and reported back with their own
|
* stashed as candidates in {@link PendingSearchResults} and reported back with their own
|
||||||
|
|||||||
Reference in new issue
Block a user