current track

This commit is contained in:
_Bastler 2022-01-03 12:56:36 +01:00
parent 2e4b48729d
commit e4fc3950b6

View File

@ -157,6 +157,40 @@ public class JukeboxController extends BaseController {
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.
*