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.MusicSourceResponse;
|
||||
import me.bobert.netneutrality.http.server.dto.MusicStatusResponse;
|
||||
import me.bobert.netneutrality.http.server.dto.PlayRequest;
|
||||
import me.bobert.netneutrality.http.server.dto.PlayResponse;
|
||||
import me.bobert.netneutrality.http.server.dto.QueueRequest;
|
||||
import me.bobert.netneutrality.http.server.dto.QueueResponse;
|
||||
import me.bobert.netneutrality.http.server.dto.QueuedTrackResponse;
|
||||
import me.bobert.netneutrality.http.server.dto.SearchRequest;
|
||||
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",
|
||||
tags = {"Music"},
|
||||
pathParams = @OpenApiParam(name = "guildId", description = "The Discord guild id"),
|
||||
requestBody = @OpenApiRequestBody(content = @OpenApiContent(from = PlayRequest.class)),
|
||||
requestBody = @OpenApiRequestBody(content = @OpenApiContent(from = QueueRequest.class)),
|
||||
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 = "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) {
|
||||
Guild guild = GuildRoutes.guild(jdaSupplier, ctx);
|
||||
MusicManager manager = musicService.get(guild);
|
||||
PlayRequest body = ctx.bodyAsClass(PlayRequest.class);
|
||||
QueueRequest body = ctx.bodyAsClass(QueueRequest.class);
|
||||
String userId = requireNonBlank(body.userId(), "userId");
|
||||
requireNonBlank(body.searchId(), "searchId");
|
||||
|
||||
@@ -303,7 +303,7 @@ public final class MusicRoutes {
|
||||
pathParams = @OpenApiParam(name = "guildId", description = "The Discord guild id"),
|
||||
requestBody = @OpenApiRequestBody(content = @OpenApiContent(from = SearchRequest.class)),
|
||||
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 = "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}.
|
||||
* 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();
|
||||
Integer index = body.index();
|
||||
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 index the index of the candidate to queue within the {@code searchId}'s results
|
||||
*/
|
||||
public record PlayRequest(
|
||||
public record QueueRequest(
|
||||
String userId,
|
||||
String searchId,
|
||||
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_search} fills {@code search_id}/{@code candidates}.
|
||||
*/
|
||||
public record PlayResponse(
|
||||
public record QueueResponse(
|
||||
String status,
|
||||
TrackSummaryResponse track,
|
||||
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,
|
||||
* 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 {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
/**
|
||||
* 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
|
||||
* {@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
|
||||
* stashed as candidates in {@link PendingSearchResults} and reported back with their own
|
||||
|
||||
Reference in new issue
Block a user