current track
This commit is contained in:
@@ -157,6 +157,40 @@ public class JukeboxController extends BaseController {
|
|||||||
queueList.put(getCurrentUserId(), Instant.now());
|
queueList.put(getCurrentUserId(), Instant.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current.
|
||||||
|
*
|
||||||
|
* @param response the response
|
||||||
|
* @throws JsonIOException the json IO exception
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
@PreAuthorize("isAuthenticated()")
|
||||||
|
@GetMapping("/current")
|
||||||
|
public void current(HttpServletResponse response) throws JsonIOException, IOException {
|
||||||
|
if (!permissionManager.hasPermission(getCurrentUserId(), ParteyPermissions.PARTEY)) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!jukeboxManager.getConfig().isActive()) {
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonElement status = jukeboxManager.getStatus();
|
||||||
|
|
||||||
|
if (status != null) {
|
||||||
|
JsonObject statusObject = status.getAsJsonObject();
|
||||||
|
if (statusObject.has("item")) {
|
||||||
|
response.setContentType("application/json");
|
||||||
|
response.setCharacterEncoding("UTF-8");
|
||||||
|
response.setStatus(HttpStatus.OK.value());
|
||||||
|
gson.toJson(statusObject.getAsJsonObject("item"), response.getWriter());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new EntityResponseStatusException(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last.
|
* Last.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user