From 2d4a3c621c901e5c9563d93676e3afdad92e37e9 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sat, 3 Jan 2026 15:21:28 -0500 Subject: [PATCH] refactor: remove UserID from scrobbler request structure Signed-off-by: Deluan --- plugins/README.md | 3 +-- plugins/capabilities/scrobbler.go | 6 ------ plugins/capabilities/scrobbler.yaml | 12 ------------ plugins/examples/webhook-rs/src/lib.rs | 5 +---- plugins/pdk/go/scrobbler/scrobbler.go | 6 ------ plugins/pdk/go/scrobbler/scrobbler_stub.go | 6 ------ .../pdk/rust/nd-pdk-capabilities/src/scrobbler.rs | 9 --------- plugins/scrobbler_adapter.go | 3 --- 8 files changed, 2 insertions(+), 48 deletions(-) diff --git a/plugins/README.md b/plugins/README.md index ff53ce36d..082322e01 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -215,7 +215,7 @@ Integrates with external scrobbling services. Export one or more of these functi | Function | Input | Output | Description | |------------------------------|-----------------------|----------------|-----------------------------| -| `nd_scrobbler_is_authorized` | `{userId, username}` | `bool` | Check if user is authorized | +| `nd_scrobbler_is_authorized` | `{username}` | `bool` | Check if user is authorized | | `nd_scrobbler_now_playing` | See below | (none) | Send now playing | | `nd_scrobbler_scrobble` | See below | (none) | Submit a scrobble | @@ -223,7 +223,6 @@ Integrates with external scrobbling services. Export one or more of these functi ```json { - "userId": "abc123", "username": "john", "track": { "id": "track-id", diff --git a/plugins/capabilities/scrobbler.go b/plugins/capabilities/scrobbler.go index cca50d503..5ba091bff 100644 --- a/plugins/capabilities/scrobbler.go +++ b/plugins/capabilities/scrobbler.go @@ -24,8 +24,6 @@ type Scrobbler interface { // IsAuthorizedRequest is the request for authorization check. type IsAuthorizedRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` } @@ -64,8 +62,6 @@ type TrackInfo struct { // NowPlayingRequest is the request for now playing notification. type NowPlayingRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` // Track is the track currently playing. @@ -76,8 +72,6 @@ type NowPlayingRequest struct { // ScrobbleRequest is the request for submitting a scrobble. type ScrobbleRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` // Track is the track that was played. diff --git a/plugins/capabilities/scrobbler.yaml b/plugins/capabilities/scrobbler.yaml index d708c44e6..b4dd2d1fa 100644 --- a/plugins/capabilities/scrobbler.yaml +++ b/plugins/capabilities/scrobbler.yaml @@ -23,21 +23,14 @@ components: IsAuthorizedRequest: description: IsAuthorizedRequest is the request for authorization check. properties: - userId: - type: string - description: UserID is the internal Navidrome user ID. username: type: string description: Username is the username of the user. required: - - userId - username NowPlayingRequest: description: NowPlayingRequest is the request for now playing notification. properties: - userId: - type: string - description: UserID is the internal Navidrome user ID. username: type: string description: Username is the username of the user. @@ -49,16 +42,12 @@ components: format: int32 description: Position is the current playback position in seconds. required: - - userId - username - track - position ScrobbleRequest: description: ScrobbleRequest is the request for submitting a scrobble. properties: - userId: - type: string - description: UserID is the internal Navidrome user ID. username: type: string description: Username is the username of the user. @@ -70,7 +59,6 @@ components: format: int64 description: Timestamp is the Unix timestamp when the track started playing. required: - - userId - username - track - timestamp diff --git a/plugins/examples/webhook-rs/src/lib.rs b/plugins/examples/webhook-rs/src/lib.rs index a32c57ae4..e872d845d 100644 --- a/plugins/examples/webhook-rs/src/lib.rs +++ b/plugins/examples/webhook-rs/src/lib.rs @@ -32,10 +32,7 @@ struct WebhookPlugin; impl Scrobbler for WebhookPlugin { /// Checks if a user is authorized. This plugin authorizes all users. fn is_authorized(&self, req: IsAuthorizedRequest) -> Result { - info!( - "Authorization check for user: {} ({})", - req.username, req.user_id - ); + info!("Authorization check for user: {}", req.username); Ok(true) } diff --git a/plugins/pdk/go/scrobbler/scrobbler.go b/plugins/pdk/go/scrobbler/scrobbler.go index 46b7de58b..7f57698d1 100644 --- a/plugins/pdk/go/scrobbler/scrobbler.go +++ b/plugins/pdk/go/scrobbler/scrobbler.go @@ -28,16 +28,12 @@ func (e ScrobblerError) Error() string { return string(e) } // IsAuthorizedRequest is the request for authorization check. type IsAuthorizedRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` } // NowPlayingRequest is the request for now playing notification. type NowPlayingRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` // Track is the track currently playing. @@ -48,8 +44,6 @@ type NowPlayingRequest struct { // ScrobbleRequest is the request for submitting a scrobble. type ScrobbleRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` // Track is the track that was played. diff --git a/plugins/pdk/go/scrobbler/scrobbler_stub.go b/plugins/pdk/go/scrobbler/scrobbler_stub.go index 05b04716f..b3b665113 100644 --- a/plugins/pdk/go/scrobbler/scrobbler_stub.go +++ b/plugins/pdk/go/scrobbler/scrobbler_stub.go @@ -25,16 +25,12 @@ func (e ScrobblerError) Error() string { return string(e) } // IsAuthorizedRequest is the request for authorization check. type IsAuthorizedRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` } // NowPlayingRequest is the request for now playing notification. type NowPlayingRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` // Track is the track currently playing. @@ -45,8 +41,6 @@ type NowPlayingRequest struct { // ScrobbleRequest is the request for submitting a scrobble. type ScrobbleRequest struct { - // UserID is the internal Navidrome user ID. - UserID string `json:"userId"` // Username is the username of the user. Username string `json:"username"` // Track is the track that was played. diff --git a/plugins/pdk/rust/nd-pdk-capabilities/src/scrobbler.rs b/plugins/pdk/rust/nd-pdk-capabilities/src/scrobbler.rs index 72e5a2a7a..1d879b749 100644 --- a/plugins/pdk/rust/nd-pdk-capabilities/src/scrobbler.rs +++ b/plugins/pdk/rust/nd-pdk-capabilities/src/scrobbler.rs @@ -16,9 +16,6 @@ pub const SCROBBLER_ERROR_UNRECOVERABLE: ScrobblerError = "scrobbler(unrecoverab #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct IsAuthorizedRequest { - /// UserID is the internal Navidrome user ID. - #[serde(default)] - pub user_id: String, /// Username is the username of the user. #[serde(default)] pub username: String, @@ -27,9 +24,6 @@ pub struct IsAuthorizedRequest { #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct NowPlayingRequest { - /// UserID is the internal Navidrome user ID. - #[serde(default)] - pub user_id: String, /// Username is the username of the user. #[serde(default)] pub username: String, @@ -44,9 +38,6 @@ pub struct NowPlayingRequest { #[derive(Debug, Clone, Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ScrobbleRequest { - /// UserID is the internal Navidrome user ID. - #[serde(default)] - pub user_id: String, /// Username is the username of the user. #[serde(default)] pub username: String, diff --git a/plugins/scrobbler_adapter.go b/plugins/scrobbler_adapter.go index 928723842..c5cdc3454 100644 --- a/plugins/scrobbler_adapter.go +++ b/plugins/scrobbler_adapter.go @@ -41,7 +41,6 @@ type ScrobblerPlugin struct { func (s *ScrobblerPlugin) IsAuthorized(ctx context.Context, userId string) bool { username := getUsernameFromContext(ctx) input := capabilities.IsAuthorizedRequest{ - UserID: userId, Username: username, } @@ -57,7 +56,6 @@ func (s *ScrobblerPlugin) IsAuthorized(ctx context.Context, userId string) bool func (s *ScrobblerPlugin) NowPlaying(ctx context.Context, userId string, track *model.MediaFile, position int) error { username := getUsernameFromContext(ctx) input := capabilities.NowPlayingRequest{ - UserID: userId, Username: username, Track: mediaFileToTrackInfo(track), Position: int32(position), @@ -71,7 +69,6 @@ func (s *ScrobblerPlugin) NowPlaying(ctx context.Context, userId string, track * func (s *ScrobblerPlugin) Scrobble(ctx context.Context, userId string, sc scrobbler.Scrobble) error { username := getUsernameFromContext(ctx) input := capabilities.ScrobbleRequest{ - UserID: userId, Username: username, Track: mediaFileToTrackInfo(&sc.MediaFile), Timestamp: sc.TimeStamp.Unix(),