diff options
author | Vitaly Takmazov | 2023-04-17 16:01:28 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-04-17 16:01:28 +0300 |
commit | 106c53cce6725591337773d412c0fb74eaf81ed8 (patch) | |
tree | fe07a0136c63787d6e5f53349af16541faebaf89 /src/main/java/com/juick/www/api/Users.java | |
parent | cf3a5d8c979b114fceef43b35541b941bcbd62a1 (diff) |
Add/remove from whitelist on web
Diffstat (limited to 'src/main/java/com/juick/www/api/Users.java')
-rw-r--r-- | src/main/java/com/juick/www/api/Users.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main/java/com/juick/www/api/Users.java b/src/main/java/com/juick/www/api/Users.java index afca7ee3..19075fe5 100644 --- a/src/main/java/com/juick/www/api/Users.java +++ b/src/main/java/com/juick/www/api/Users.java @@ -28,12 +28,7 @@ import javax.inject.Inject; import com.juick.model.AnonymousUser; import com.juick.model.ApplicationStatus; import com.juick.model.User; -import com.juick.service.EmailService; -import com.juick.service.MessagesService; -import com.juick.service.StorageService; -import com.juick.service.TagService; -import com.juick.service.TelegramService; -import com.juick.service.UserService; +import com.juick.service.*; import com.juick.service.activities.UpdateUserEvent; import com.juick.service.component.MailVerificationEvent; import com.juick.util.HttpBadRequestException; @@ -59,6 +54,8 @@ public class Users { @Inject private UserService userService; @Inject + private PrivacyQueriesService privacyQueriesService; + @Inject private MessagesService messagesService; @Inject private TelegramService telegramService; @@ -222,6 +219,18 @@ public class Users { throw new HttpNotFoundException(); } + @PostMapping("/api/users/wl") + public void toggleWL(@Parameter(hidden = true) User visitor, @RequestParam String name) { + if (!visitor.isAnonymous()) { + User user = userService.getUserByName(name); + if (!user.isAnonymous()) { + privacyQueriesService.whiteListUser(visitor, user); + } + } else { + throw new HttpBadRequestException(); + } + } + @GetMapping("/api/info/{uname}") public User getUserInfo(@Parameter(hidden = true) User visitor, @PathVariable String uname) { User user = userService.getUserByName(uname); |