aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/www/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/www/controllers')
-rw-r--r--juick-server/src/main/java/com/juick/server/www/controllers/Settings.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/juick-server/src/main/java/com/juick/server/www/controllers/Settings.java b/juick-server/src/main/java/com/juick/server/www/controllers/Settings.java
index 6405b3bd..cc8f43eb 100644
--- a/juick-server/src/main/java/com/juick/server/www/controllers/Settings.java
+++ b/juick-server/src/main/java/com/juick/server/www/controllers/Settings.java
@@ -16,9 +16,12 @@
*/
package com.juick.server.www.controllers;
+import com.juick.User;
import com.juick.model.NotifyOpts;
import com.juick.model.UserInfo;
-import com.juick.server.util.*;
+import com.juick.server.util.HttpBadRequestException;
+import com.juick.server.util.HttpUtils;
+import com.juick.server.util.UserUtils;
import com.juick.service.*;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
@@ -257,4 +260,19 @@ public class Settings {
model.addAttribute("result", result);
return "views/settings_result";
}
+ @PostMapping("/settings/unsubscribe")
+ public String unsubscribeOneClick(@RequestParam(name = "List-Unsubscribe") String unsubscribe,
+ ModelMap model) {
+ User user = UserUtils.getCurrentUser();
+ if (!user.isAnonymous()) {
+ if (unsubscribe.equals("One-Click")) {
+ emailService.setNotificationsEmail(user.getUid(), StringUtils.EMPTY);
+ model.addAttribute("title", "Настройки");
+ model.addAttribute("visitor", user);
+ model.addAttribute("result", "Unsubscribed");
+ return "views/settings_result";
+ }
+ }
+ throw new HttpBadRequestException();
+ }
}