From fc5f8e888c9ccfda7d739493c439437a917b9902 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 26 Apr 2023 09:34:29 +0300 Subject: Expose 'isAdmin' user property over API --- src/main/java/com/juick/www/api/Messages.java | 4 ++-- src/main/java/com/juick/www/api/Users.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) (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 ef55944b..969bef4f 100644 --- a/src/main/java/com/juick/www/api/Messages.java +++ b/src/main/java/com/juick/www/api/Messages.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2021, Juick + * Copyright (C) 2008-2023, Juick * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -212,7 +212,7 @@ public class Messages { } @PostMapping("/api/messages/set_privacy") public void togglePrivacy(@Parameter(hidden = true) User visitor, @RequestParam Integer mid) { - if (visitor.isPremium() || userService.isAdminUser(visitor)) { + if (visitor.isPremium() || visitor.isAdmin()) { var msg = messagesService.getMessage(mid).orElseThrow(HttpNotFoundException::new); messagesService.setFriendsOnly(mid, !msg.isFriendsOnly()); msg = messagesService.getMessage(mid).orElseThrow(HttpNotFoundException::new); diff --git a/src/main/java/com/juick/www/api/Users.java b/src/main/java/com/juick/www/api/Users.java index 19075fe5..4fb53ca1 100644 --- a/src/main/java/com/juick/www/api/Users.java +++ b/src/main/java/com/juick/www/api/Users.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2020, Juick + * Copyright (C) 2008-2023, Juick * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as @@ -110,6 +110,8 @@ public class Users { me.setReaders(readers); me.setAvatar(webApp.getAvatarUrl(visitor)); me.getTagStats().addAll(tagService.getUserTagStats(me.getUid())); + me.setPremium(visitor.isPremium()); + me.setAdmin(visitor.isAdmin()); return (SecureUser)userService.getUserInfo(me); } @PostMapping("/api/me") -- cgit v1.2.3