mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Use int values for canvas size
This commit is contained in:
@@ -204,6 +204,7 @@ public class ChannelDirectoryService {
|
||||
}
|
||||
|
||||
public CanvasSettingsRequest updateCanvasSettings(String broadcaster, CanvasSettingsRequest req, String actor) {
|
||||
validateCanvasSettings(req);
|
||||
Channel channel = getOrCreateChannel(broadcaster);
|
||||
double beforeWidth = channel.getCanvasWidth();
|
||||
double beforeHeight = channel.getCanvasHeight();
|
||||
@@ -230,6 +231,30 @@ public class ChannelDirectoryService {
|
||||
return response;
|
||||
}
|
||||
|
||||
private void validateCanvasSettings(CanvasSettingsRequest req) {
|
||||
Settings settings = settingsService.get();
|
||||
int canvasMaxSizePixels = settings.getMaxCanvasSideLengthPixels();
|
||||
|
||||
if (
|
||||
req.getWidth() <= 0 ||
|
||||
req.getWidth() > canvasMaxSizePixels ||
|
||||
!Double.isFinite(req.getWidth()) ||
|
||||
req.getWidth() % 1 != 0
|
||||
) throw new ResponseStatusException(
|
||||
BAD_REQUEST,
|
||||
"Canvas width must be a whole number within [1 to " + canvasMaxSizePixels + "]"
|
||||
);
|
||||
if (
|
||||
req.getHeight() <= 0 ||
|
||||
req.getHeight() > canvasMaxSizePixels ||
|
||||
!Double.isFinite(req.getHeight()) ||
|
||||
req.getHeight() % 1 != 0
|
||||
) throw new ResponseStatusException(
|
||||
BAD_REQUEST,
|
||||
"Canvas height must be a whole number within [1 to " + canvasMaxSizePixels + "]"
|
||||
);
|
||||
}
|
||||
|
||||
public ChannelScriptSettingsRequest getChannelScriptSettings(String broadcaster) {
|
||||
Channel channel = getOrCreateChannel(broadcaster);
|
||||
return new ChannelScriptSettingsRequest(
|
||||
|
||||
Reference in New Issue
Block a user