mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
refactor: remove UserID from scrobbler request structure
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
parent
5c1b8498ce
commit
2d4a3c621c
@ -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",
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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<bool, Error> {
|
||||
info!(
|
||||
"Authorization check for user: {} ({})",
|
||||
req.username, req.user_id
|
||||
);
|
||||
info!("Authorization check for user: {}", req.username);
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user