Transmit guild name with patreon information

This commit is contained in:
jude 2023-10-07 16:08:25 +01:00
parent e3d3418f99
commit e8bd05893f
3 changed files with 6 additions and 13 deletions

View File

@ -124,7 +124,7 @@ pub async fn initialize(
routes::dashboard::user::get_user_info, routes::dashboard::user::get_user_info,
routes::dashboard::user::update_user_info, routes::dashboard::user::update_user_info,
routes::dashboard::user::get_user_guilds, 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_channels,
routes::dashboard::guild::get_guild_roles, routes::dashboard::guild::get_guild_roles,
routes::dashboard::guild::get_reminder_templates, 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") { if std::env::var("OFFLINE").map_or(true, |v| v != "1") {
match user_id { match user_id {
Some(user_id) => { Some(user_id) => {
println!("{:?}", std::env::var("ADMIN_ID"));
println!("{:?}", user_id);
let admin_id = std::env::var("ADMIN_ID") let admin_id = std::env::var("ADMIN_ID")
.map_or(false, |u| u.parse::<u64>().map_or(false, |u| u == user_id)); .map_or(false, |u| u.parse::<u64>().map_or(false, |u| u == user_id));

View File

@ -42,13 +42,9 @@ struct ChannelInfo {
webhook_name: Option<String>, webhook_name: Option<String>,
} }
#[get("/api/guild/<id>/patreon")] #[get("/api/guild/<id>")]
pub async fn get_guild_patreon( pub async fn get_guild_info(id: u64, cookies: &CookieJar<'_>, ctx: &State<Context>) -> JsonResult {
id: u64, offline!(Ok(json!({ "patreon": true, "name": "Guild" })));
cookies: &CookieJar<'_>,
ctx: &State<Context>,
) -> JsonResult {
offline!(Ok(json!({ "patreon": true })));
check_authorization(cookies, ctx.inner(), id).await?; check_authorization(cookies, ctx.inner(), id).await?;
match GuildId(id).to_guild_cached(ctx.inner()) { 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())) .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"), None => json_err!("Bot not in guild"),

View File

@ -105,7 +105,7 @@ function reset_guild_pane() {
} }
async function fetch_patreon(guild_id) { async function fetch_patreon(guild_id) {
fetch(`/dashboard/api/guild/${guild_id}/patreon`) fetch(`/dashboard/api/guild/${guild_id}`)
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((data) => {
if (data.error) { if (data.error) {