diff --git a/crates/jetstream/src/repo.rs b/crates/jetstream/src/repo.rs index 4cf07ec0..37baa894 100644 --- a/crates/jetstream/src/repo.rs +++ b/crates/jetstream/src/repo.rs @@ -110,7 +110,7 @@ pub async fn save_scrobble( state, &WebhookEnvelope { r#type: "scrobble.created".to_string(), - id: Some(commit.rkey.clone()), + id: commit.rkey.clone(), data: ScrobbleData { user: discord::model::User { did: did.to_string(), diff --git a/crates/jetstream/src/webhook/discord/mod.rs b/crates/jetstream/src/webhook/discord/mod.rs index e4f983b3..5ba67b1c 100644 --- a/crates/jetstream/src/webhook/discord/mod.rs +++ b/crates/jetstream/src/webhook/discord/mod.rs @@ -3,14 +3,8 @@ pub mod model; use crate::webhook::discord::model::*; use reqwest::Client; -pub fn embed_from_scrobble(s: &ScrobbleData) -> DiscordEmbed { - let url = s - .track - .spotify_url - .as_ref() - .or(s.track.tidal_url.as_ref()) - .or(s.track.youtube_url.as_ref()) - .cloned(); +pub fn embed_from_scrobble(s: &ScrobbleData, rkey: &str) -> DiscordEmbed { + let url = format!("https://rocksky.app/{}/scrobble/{}", s.user.did, rkey); let mut desc = format!("**{}**\nby {}", esc(&s.track.title), esc(&s.track.artist)); desc.push_str(&format!("\non *{}*", esc(&s.track.album))); diff --git a/crates/jetstream/src/webhook/discord/model.rs b/crates/jetstream/src/webhook/discord/model.rs index 9bf3dedf..76788351 100644 --- a/crates/jetstream/src/webhook/discord/model.rs +++ b/crates/jetstream/src/webhook/discord/model.rs @@ -4,8 +4,7 @@ use serde::{Deserialize, Serialize}; pub struct WebhookEnvelope { #[serde(default)] pub r#type: String, - #[serde(default)] - pub id: Option, + pub id: String, #[serde(default)] pub delivered_at: Option, pub data: ScrobbleData, @@ -54,8 +53,7 @@ pub struct DiscordWebhookPayload { #[derive(Debug, Serialize)] pub struct DiscordEmbed { pub title: String, - #[serde(skip_serializing_if = "Option::is_none")] - pub url: Option, + pub url: String, #[serde(skip_serializing_if = "Option::is_none")] pub description: Option, #[serde(skip_serializing_if = "Option::is_none")] diff --git a/crates/jetstream/src/webhook_worker.rs b/crates/jetstream/src/webhook_worker.rs index 2835396e..0c072b0d 100644 --- a/crates/jetstream/src/webhook_worker.rs +++ b/crates/jetstream/src/webhook_worker.rs @@ -74,7 +74,7 @@ async fn run_worker( match brpop_once(st.clone(), 1).await { Ok(Some(json_str)) => { if let Ok(env) = serde_json::from_str::(&json_str) { - embeds.push(discord::embed_from_scrobble(&env.data)); + embeds.push(discord::embed_from_scrobble(&env.data, &env.id)); } } Ok(None) => break,