From cf3a5d8c979b114fceef43b35541b941bcbd62a1 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 17 Apr 2023 15:00:14 +0300 Subject: Private posts --- src/main/java/com/juick/www/api/Messages.java | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/main/java/com/juick/www') diff --git a/src/main/java/com/juick/www/api/Messages.java b/src/main/java/com/juick/www/api/Messages.java index e3426454..f059aa88 100644 --- a/src/main/java/com/juick/www/api/Messages.java +++ b/src/main/java/com/juick/www/api/Messages.java @@ -203,4 +203,13 @@ public class Messages { } throw new HttpBadRequestException(); } + @PostMapping("/api/messages/set_privacy") + public void togglePrivacy(@Parameter(hidden = true) User visitor, @RequestParam Integer mid) { + if (visitor.isPremium() || userService.isAdminUser(visitor)) { + var msg = messagesService.getMessage(mid).orElseThrow(HttpNotFoundException::new); + messagesService.setFriendsOnly(mid, !msg.FriendsOnly); + } else { + throw new HttpBadRequestException(); + } + } } -- cgit v1.2.3