diff options
Diffstat (limited to 'src/tasks/mod.rs')
| -rw-r--r-- | src/tasks/mod.rs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/tasks/mod.rs b/src/tasks/mod.rs index f0585ef..b492f61 100644 --- a/src/tasks/mod.rs +++ b/src/tasks/mod.rs | |||
| @@ -125,19 +125,15 @@ async fn execute_audio_job(ctx: &CronContext, job: &crate::database::CronJob) { | |||
| 125 | 125 | ||
| 126 | let channel_id = serenity::ChannelId::new(job.channel_id as u64); | 126 | let channel_id = serenity::ChannelId::new(job.channel_id as u64); |
| 127 | 127 | ||
| 128 | // Build the full URL with password | 128 | // Authenticate only when the URL belongs to our Copyparty host; a cron |
| 129 | let url = if audio_url.starts_with("http://") || audio_url.starts_with("https://") { | 129 | // job may point at an arbitrary third-party URL and must never receive |
| 130 | // Already a full URL (stored without password), append it now | 130 | // the password. |
| 131 | if let Some(pw) = &ctx.copyparty.password { | 131 | let url = ctx.copyparty.build_url_for(audio_url); |
| 132 | format!("{audio_url}?pw={pw}") | 132 | info!( |
| 133 | } else { | 133 | "Cron audio job {} playing: {}", |
| 134 | audio_url.clone() | 134 | job.id, |
| 135 | } | 135 | crate::copyparty::redact_url(&url) |
| 136 | } else { | 136 | ); |
| 137 | // Legacy relative path — build full URL with password | ||
| 138 | ctx.copyparty.build_url(audio_url) | ||
| 139 | }; | ||
| 140 | info!("Cron audio job {} playing: {url}", job.id); | ||
| 141 | let channel = match channel_id.to_channel(&ctx.http).await { | 137 | let channel = match channel_id.to_channel(&ctx.http).await { |
| 142 | Ok(serenity::Channel::Guild(ch)) => ch, | 138 | Ok(serenity::Channel::Guild(ch)) => ch, |
| 143 | other => { | 139 | other => { |
| @@ -175,8 +171,11 @@ async fn execute_audio_job(ctx: &CronContext, job: &crate::database::CronJob) { | |||
| 175 | } | 171 | } |
| 176 | 172 | ||
| 177 | info!( | 173 | info!( |
| 178 | "Cron audio job {} playing '{}' (url: {url}) in guild {}", | 174 | "Cron audio job {} playing '{}' (url: {}) in guild {}", |
| 179 | job.id, audio_url, channel.guild_id | 175 | job.id, |
| 176 | audio_url, | ||
| 177 | crate::copyparty::redact_url(&url), | ||
| 178 | channel.guild_id | ||
| 180 | ); | 179 | ); |
| 181 | } | 180 | } |
| 182 | 181 | ||
