From e8bd05893f5dec8efa52f441915fb73f76fb3e68 Mon Sep 17 00:00:00 2001 From: jude Date: Sat, 7 Oct 2023 16:08:25 +0100 Subject: [PATCH] Transmit guild name with patreon information --- web/src/lib.rs | 5 +---- web/src/routes/dashboard/guild.rs | 12 ++++-------- web/static/js/main.js | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/web/src/lib.rs b/web/src/lib.rs index c424f07..954a7e6 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -124,7 +124,7 @@ pub async fn initialize( routes::dashboard::user::get_user_info, routes::dashboard::user::update_user_info, routes::dashboard::user::get_user_guilds, - routes::dashboard::guild::get_guild_patreon, + routes::dashboard::guild::get_guild_info, routes::dashboard::guild::get_guild_channels, routes::dashboard::guild::get_guild_roles, routes::dashboard::guild::get_reminder_templates, @@ -202,9 +202,6 @@ pub async fn check_authorization( if std::env::var("OFFLINE").map_or(true, |v| v != "1") { match user_id { Some(user_id) => { - println!("{:?}", std::env::var("ADMIN_ID")); - println!("{:?}", user_id); - let admin_id = std::env::var("ADMIN_ID") .map_or(false, |u| u.parse::().map_or(false, |u| u == user_id)); diff --git a/web/src/routes/dashboard/guild.rs b/web/src/routes/dashboard/guild.rs index fe640ae..bdf591c 100644 --- a/web/src/routes/dashboard/guild.rs +++ b/web/src/routes/dashboard/guild.rs @@ -42,13 +42,9 @@ struct ChannelInfo { webhook_name: Option, } -#[get("/api/guild//patreon")] -pub async fn get_guild_patreon( - id: u64, - cookies: &CookieJar<'_>, - ctx: &State, -) -> JsonResult { - offline!(Ok(json!({ "patreon": true }))); +#[get("/api/guild/")] +pub async fn get_guild_info(id: u64, cookies: &CookieJar<'_>, ctx: &State) -> JsonResult { + offline!(Ok(json!({ "patreon": true, "name": "Guild" }))); check_authorization(cookies, ctx.inner(), id).await?; match GuildId(id).to_guild_cached(ctx.inner()) { @@ -63,7 +59,7 @@ pub async fn get_guild_patreon( .contains(&RoleId(env::var("PATREON_ROLE_ID").unwrap().parse().unwrap())) }); - Ok(json!({ "patreon": patreon })) + Ok(json!({ "patreon": patreon, "name": guild.name })) } None => json_err!("Bot not in guild"), diff --git a/web/static/js/main.js b/web/static/js/main.js index ce1410c..cb0d46d 100644 --- a/web/static/js/main.js +++ b/web/static/js/main.js @@ -105,7 +105,7 @@ function reset_guild_pane() { } async function fetch_patreon(guild_id) { - fetch(`/dashboard/api/guild/${guild_id}/patreon`) + fetch(`/dashboard/api/guild/${guild_id}`) .then((response) => response.json()) .then((data) => { if (data.error) {