aboutsummaryrefslogtreecommitdiffstats
path: root/src/tasks
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-04 01:06:38 +0100
committersalmonik <salmonik@tuta.io>2026-11-04 01:06:38 +0100
commit64afa0fd8c863deb6a1568428dfaf2ce67ef9085 (patch)
tree14ff21f7bcb30d8a5234a2d535e0977d0d5f5a04 /src/tasks
parentsay: do not abort if the ephemeral ack is already gone (diff)
downloadsenator-sperma-64afa0fd8c863deb6a1568428dfaf2ce67ef9085.tar.gz
senator-sperma-64afa0fd8c863deb6a1568428dfaf2ce67ef9085.zip
copyparty: never send the password to foreign hosts
Diffstat (limited to 'src/tasks')
-rw-r--r--src/tasks/mod.rs29
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