diff --git a/src/routes/projects.rs b/src/routes/projects.rs index ab8a67b9d..4a9b693a5 100644 --- a/src/routes/projects.rs +++ b/src/routes/projects.rs @@ -457,11 +457,11 @@ pub async fn project_edit( )); } - if !user.role.is_mod() - && !(!project_item.inner.status.is_approved() + if !(user.role.is_mod() + || !project_item.inner.status.is_approved() && status == &ProjectStatus::Processing - || project_item.inner.status.is_approved() - && status.can_be_requested()) + || project_item.inner.status.is_approved() + && status.can_be_requested()) { return Err(ApiError::CustomAuthentication( "You don't have permission to set this status!" diff --git a/src/util/webhook.rs b/src/util/webhook.rs index 8420e9328..38345a5a0 100644 --- a/src/util/webhook.rs +++ b/src/util/webhook.rs @@ -57,6 +57,17 @@ struct DiscordWebhook { pub embeds: Vec, } +const PLUGIN_LOADERS: &[&str] = &[ + "bukkit", + "spigot", + "paper", + "purpur", + "bungeecord", + "waterfall", + "velocity", + "sponge", +]; + pub async fn send_discord_webhook( project_id: ProjectId, pool: &PgPool, @@ -125,8 +136,8 @@ pub async fn send_discord_webhook( if !loaders.is_empty() { let mut formatted_loaders: String = String::new(); - for loader in loaders { - let emoji_id: i64 = match &*loader { + for loader in &loaders { + let emoji_id: i64 = match &**loader { "bukkit" => 1049793345481883689, "bungeecord" => 1049793347067314220, "fabric" => 1049793348719890532, @@ -170,6 +181,12 @@ pub async fn send_discord_webhook( }); } + let mut project_type = project.project_type; + + if loaders.iter().all(|x| PLUGIN_LOADERS.contains(&&**x)) { + project_type = "plugin".to_string(); + } + let embed = DiscordEmbed { author: Some(DiscordEmbedAuthor { name: project.username.clone(), @@ -183,7 +200,7 @@ pub async fn send_discord_webhook( url: format!( "{}/{}/{}", dotenvy::var("SITE_URL").unwrap_or_default(), - project.project_type, + project_type, project.slug.unwrap_or_else(|| project_id.to_string()) ), title: project.title, @@ -203,7 +220,10 @@ pub async fn send_discord_webhook( } .map(|x| DiscordEmbedImage { url: Some(x) }), footer: Some(DiscordEmbedFooter { - text: "Modrinth".to_string(), + text: format!( + "{project_type}{} on Modrinth", + project_type.remove(0).to_uppercase() + ), icon_url: Some( "https://cdn-raw.modrinth.com/modrinth-new.png".to_string(), ),