- 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().setAutoFollow(autoFollow);
+ boolean enableSoneInsertNotifications = request.getHttpRequest().isPartSet("enable-sone-insert-notifications");
+ currentSone.getOptions().setSoneInsertNotificationEnabled(enableSoneInsertNotifications);
+ boolean showNotificationNewSones = request.getHttpRequest().isPartSet("show-notification-new-sones");
+ currentSone.getOptions().setShowNewSoneNotifications(showNotificationNewSones);
+ boolean showNotificationNewPosts = request.getHttpRequest().isPartSet("show-notification-new-posts");
+ currentSone.getOptions().setShowNewPostNotifications(showNotificationNewPosts);
+ boolean showNotificationNewReplies = request.getHttpRequest().isPartSet("show-notification-new-replies");
+ currentSone.getOptions().setShowNewReplyNotifications(showNotificationNewReplies);
+ String showCustomAvatars = request.getHttpRequest().getPartAsStringFailsafe("show-custom-avatars", 32);
+ currentSone.getOptions().setShowCustomAvatars(ShowCustomAvatars.valueOf(showCustomAvatars));
+ webInterface.getCore().touchConfiguration();
+ }
+ Integer insertionDelay = parseInt(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16), null);
+ if (!preferences.validateInsertionDelay(insertionDelay)) {
+ fieldErrors.add("insertion-delay");
+ } else {
+ preferences.setInsertionDelay(insertionDelay);
+ }
+ Integer postsPerPage = parseInt(request.getHttpRequest().getPartAsStringFailsafe("posts-per-page", 4), null);
+ if (!preferences.validatePostsPerPage(postsPerPage)) {
+ fieldErrors.add("posts-per-page");
+ } else {
+ preferences.setPostsPerPage(postsPerPage);
+ }
+ Integer imagesPerPage = parseInt(request.getHttpRequest().getPartAsStringFailsafe("images-per-page", 4), null);
+ if (!preferences.validateImagesPerPage(imagesPerPage)) {
+ fieldErrors.add("images-per-page");
+ } else {
+ preferences.setImagesPerPage(imagesPerPage);
+ }
+ Integer charactersPerPost = parseInt(request.getHttpRequest().getPartAsStringFailsafe("characters-per-post", 10), null);
+ if (!preferences.validateCharactersPerPost(charactersPerPost)) {
+ fieldErrors.add("characters-per-post");
+ } else {
+ preferences.setCharactersPerPost(charactersPerPost);
+ }
+ Integer postCutOffLength = parseInt(request.getHttpRequest().getPartAsStringFailsafe("post-cut-off-length", 10), null);
+ 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 = parseInt(request.getHttpRequest().getPartAsStringFailsafe("positive-trust", 3), null);
+ if (!preferences.validatePositiveTrust(positiveTrust)) {
+ fieldErrors.add("positive-trust");
+ } else {
+ preferences.setPositiveTrust(positiveTrust);
+ }
+ Integer negativeTrust = parseInt(request.getHttpRequest().getPartAsStringFailsafe("negative-trust", 4), null);
+ if (!preferences.validateNegativeTrust(negativeTrust)) {
+ fieldErrors.add("negative-trust");
+ } else {
+ preferences.setNegativeTrust(negativeTrust);
+ }