From ebb1316469378e2e1b068b06970d9b430be77167 Mon Sep 17 00:00:00 2001 From: Sebastien Date: Sat, 15 Jun 2019 14:20:19 +0200 Subject: [PATCH] Correct change guild not working on music page --- .../java/net/Broken/webView/GeneralWebView.java | 2 +- src/main/java/net/Broken/webView/MusicWebView.java | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/net/Broken/webView/GeneralWebView.java b/src/main/java/net/Broken/webView/GeneralWebView.java index a344f16..570bfbe 100644 --- a/src/main/java/net/Broken/webView/GeneralWebView.java +++ b/src/main/java/net/Broken/webView/GeneralWebView.java @@ -197,7 +197,7 @@ public class GeneralWebView { - private Model addGuildAndRedirect(Model model, String token, String guildId, List mutualGuilds){ + public static Model addGuildAndRedirect(Model model, String token, String guildId, List mutualGuilds){ Guild guild = MainBot.jda.getGuildById(guildId); if(guild != null){ model.addAttribute("guild_name", guild.getName()); diff --git a/src/main/java/net/Broken/webView/MusicWebView.java b/src/main/java/net/Broken/webView/MusicWebView.java index f58fe8a..05a9804 100644 --- a/src/main/java/net/Broken/webView/MusicWebView.java +++ b/src/main/java/net/Broken/webView/MusicWebView.java @@ -26,11 +26,11 @@ import javax.servlet.http.HttpServletResponse; @Controller public class MusicWebView { - UserRepository userRepository; + private UserRepository userRepository; - UserUtils userUtils = UserUtils.getInstance(); + private UserUtils userUtils = UserUtils.getInstance(); - Logger logger = LogManager.getLogger(); + private Logger logger = LogManager.getLogger(); @Autowired @@ -51,12 +51,7 @@ public class MusicWebView { User user = MainBot.jda.getUserById(userE.getJdaId()); if(user == null) return "redirect:/"; - Guild guild = MainBot.jda.getGuildById(guildId); - if(guild != null) - model.addAttribute("guild_name", guild.getName()); - else - model.addAttribute("guild_name", ""); - model.addAttribute("isAdmin", SettingsUtils.getInstance().checkPermission(token, guildId)); + GeneralWebView.addGuildAndRedirect(model, token, guildId, user.getMutualGuilds()); return CheckPage.getPageIfReady("music"); } catch (UnknownTokenException e) {