fix: rust plugin compilation error

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2026-01-14 14:52:47 -05:00
parent bfb6476307
commit f4477fffd4

View File

@ -19,7 +19,7 @@
//! in configuration files is not secure and may violate Discord's terms of service.
use extism_pdk::*;
use nd_pdk::host::{artwork, scheduler};
use nd_pdk::host::{artwork, config, scheduler};
use nd_pdk::scrobbler::{
Error as ScrobblerError, IsAuthorizedRequest, NowPlayingRequest,
ScrobbleRequest, Scrobbler, SCROBBLER_ERROR_NOT_AUTHORIZED, SCROBBLER_ERROR_RETRY_LATER,
@ -65,9 +65,10 @@ struct DiscordPlugin;
// ============================================================================
fn get_config() -> Result<(String, std::collections::HashMap<String, String>), Error> {
let client_id = config::get(CLIENT_ID_KEY)?
.filter(|s| !s.is_empty())
.ok_or_else(|| Error::msg("missing clientid in configuration"))?;
let (client_id, exists) = config::get(CLIENT_ID_KEY)?;
if !exists || client_id.is_empty() {
return Err(Error::msg("missing clientid in configuration"));
}
// Get all user keys with the "user." prefix
let user_keys = config::keys(USER_KEY_PREFIX)?;
@ -75,7 +76,8 @@ fn get_config() -> Result<(String, std::collections::HashMap<String, String>), E
let mut users = std::collections::HashMap::new();
for key in user_keys {
let username = key.strip_prefix(USER_KEY_PREFIX).unwrap_or(&key);
if let Some(token) = config::get(&key)?.filter(|s| !s.is_empty()) {
let (token, token_exists) = config::get(&key)?;
if token_exists && !token.is_empty() {
users.insert(username.to_string(), token);
}
}