- Integer insertionDelay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16));
- options.getIntegerOption("InsertionDelay").set(insertionDelay);
- Integer positiveTrust = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("positive-trust", 3), options.getIntegerOption("PositiveTrust").getReal());
- options.getIntegerOption("PositiveTrust").set(positiveTrust);
- Integer negativeTrust = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("negative-trust", 3), options.getIntegerOption("NegativeTrust").getReal());
- options.getIntegerOption("NegativeTrust").set(negativeTrust);
+ List<String> fieldErrors = new ArrayList<String>();
+ if (currentSone != null) {
+ boolean autoFollow = request.getHttpRequest().isPartSet("auto-follow");
+ currentSone.getOptions().getBooleanOption("AutoFollow").set(autoFollow);
+ boolean enableSoneInsertNotifications = request.getHttpRequest().isPartSet("enable-sone-insert-notifications");
+ currentSone.getOptions().getBooleanOption("EnableSoneInsertNotifications").set(enableSoneInsertNotifications);
+ boolean showNotificationNewSones = request.getHttpRequest().isPartSet("show-notification-new-sones");
+ currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").set(showNotificationNewSones);
+ boolean showNotificationNewPosts = request.getHttpRequest().isPartSet("show-notification-new-posts");
+ currentSone.getOptions().getBooleanOption("ShowNotification/NewPosts").set(showNotificationNewPosts);
+ boolean showNotificationNewReplies = request.getHttpRequest().isPartSet("show-notification-new-replies");
+ currentSone.getOptions().getBooleanOption("ShowNotification/NewReplies").set(showNotificationNewReplies);
+ String showCustomAvatars = request.getHttpRequest().getPartAsStringFailsafe("show-custom-avatars", 32);
+ currentSone.getOptions().<ShowCustomAvatars> getEnumOption("ShowCustomAvatars").set(ShowCustomAvatars.valueOf(showCustomAvatars));
+ webInterface.getCore().touchConfiguration();
+ }
+ Integer insertionDelay = Ints.tryParse(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16));
+ if (!preferences.validateInsertionDelay(insertionDelay)) {
+ fieldErrors.add("insertion-delay");
+ } else {
+ preferences.setInsertionDelay(insertionDelay);
+ }
+ Integer postsPerPage = Ints.tryParse(request.getHttpRequest().getPartAsStringFailsafe("posts-per-page", 4));
+ if (!preferences.validatePostsPerPage(postsPerPage)) {
+ fieldErrors.add("posts-per-page");
+ } else {
+ preferences.setPostsPerPage(postsPerPage);
+ }
+ Integer imagesPerPage = Ints.tryParse(request.getHttpRequest().getPartAsStringFailsafe("images-per-page", 4));
+ if (!preferences.validateImagesPerPage(imagesPerPage)) {
+ fieldErrors.add("images-per-page");
+ } else {
+ preferences.setImagesPerPage(imagesPerPage);
+ }
+ Integer charactersPerPost = Ints.tryParse(request.getHttpRequest().getPartAsStringFailsafe("characters-per-post", 10));
+ if (!preferences.validateCharactersPerPost(charactersPerPost)) {
+ fieldErrors.add("characters-per-post");
+ } else {
+ preferences.setCharactersPerPost(charactersPerPost);
+ }
+ Integer postCutOffLength = Ints.tryParse(request.getHttpRequest().getPartAsStringFailsafe("post-cut-off-length", 10));
+ if (!preferences.validatePostCutOffLength(postCutOffLength)) {
+ fieldErrors.add("post-cut-off-length");
+ } else {
+ preferences.setPostCutOffLength(postCutOffLength);
+ }
+ boolean requireFullAccess = request.getHttpRequest().isPartSet("require-full-access");
+ preferences.setRequireFullAccess(requireFullAccess);
+ Integer positiveTrust = Ints.tryParse(request.getHttpRequest().getPartAsStringFailsafe("positive-trust", 3));
+ if (!preferences.validatePositiveTrust(positiveTrust)) {
+ fieldErrors.add("positive-trust");
+ } else {
+ preferences.setPositiveTrust(positiveTrust);
+ }
+ Integer negativeTrust = Ints.tryParse(request.getHttpRequest().getPartAsStringFailsafe("negative-trust", 4));
+ if (!preferences.validateNegativeTrust(negativeTrust)) {
+ fieldErrors.add("negative-trust");
+ } else {
+ preferences.setNegativeTrust(negativeTrust);
+ }