Minimal subsonic functionality
This commit is contained in:
42
src/routes/subsonic/annotation.rs
Normal file
42
src/routes/subsonic/annotation.rs
Normal file
@@ -0,0 +1,42 @@
|
||||
use actix_web::{HttpRequest, HttpResponse, web};
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
use super::helpers::{authenticate, get_query_param, parse_subsonic_id};
|
||||
use super::response;
|
||||
|
||||
/// GET /rest/scrobble[.view]
|
||||
pub async fn scrobble(req: HttpRequest, state: web::Data<AppState>) -> HttpResponse {
|
||||
let (params, user) = match authenticate(&req, &state).await {
|
||||
Ok(v) => v,
|
||||
Err(resp) => return resp,
|
||||
};
|
||||
|
||||
let id_str = match get_query_param(&req, "id") {
|
||||
Some(id) => id,
|
||||
None => {
|
||||
return response::error(
|
||||
¶ms.format,
|
||||
response::ERROR_MISSING_PARAM,
|
||||
"missing required parameter: id",
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
let (prefix, entity_id) = match parse_subsonic_id(&id_str) {
|
||||
Some(v) => v,
|
||||
None => {
|
||||
return response::error(¶ms.format, response::ERROR_NOT_FOUND, "invalid id");
|
||||
}
|
||||
};
|
||||
|
||||
// Log the scrobble for now; full play tracking can be added later
|
||||
tracing::info!(
|
||||
user = %user.username,
|
||||
id_type = prefix,
|
||||
id = entity_id,
|
||||
"subsonic scrobble"
|
||||
);
|
||||
|
||||
response::ok(¶ms.format, serde_json::json!({}))
|
||||
}
|
||||
Reference in New Issue
Block a user