mirror of
https://github.com/agersant/polaris
synced 2024-11-26 07:30:17 +00:00
Removed preferences
This commit is contained in:
parent
a89e3d5145
commit
c51ce59fba
6 changed files with 1 additions and 96 deletions
|
@ -18,7 +18,7 @@
|
|||
- The `/thumbnail` endpoint supports a new size labeled `tiny` which returns 40x40px images.
|
||||
- Persistent data, such as playlists, is now saved in a directory that may be configured with the `--data` CLI option or the `POLARIS_DATA_DIR` environment variable.
|
||||
- Removed last.fm integration due to maintenance concerns (abandoned libraries, broken account linking) and mismatch with project goals.
|
||||
- Removed the `/config` API endpoint.
|
||||
- Removed the `/config` and `/preferences` API endpoints.
|
||||
- Removed the `/ddns` API endpoints, merged into the existing `/settings` endpoints.
|
||||
|
||||
### Web client
|
||||
|
|
|
@ -34,10 +34,6 @@ pub struct User {
|
|||
pub initial_password: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub hashed_password: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub web_theme_base: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub web_theme_accent: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
|
|
|
@ -38,8 +38,6 @@ pub fn router() -> Router<App> {
|
|||
.route("/user/:name", delete(delete_user))
|
||||
.route("/user/:name", put(put_user))
|
||||
.route("/users", get(get_users))
|
||||
.route("/preferences", get(get_preferences))
|
||||
.route("/preferences", put(put_preferences))
|
||||
// File browser
|
||||
.route("/browse", get(get_browse_root))
|
||||
.route("/browse/*path", get(get_browse))
|
||||
|
@ -219,29 +217,6 @@ async fn delete_user(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
async fn get_preferences(
|
||||
auth: Auth,
|
||||
State(config_manager): State<config::Manager>,
|
||||
) -> Result<Json<dto::Preferences>, APIError> {
|
||||
let user = config_manager.get_user(auth.get_username()).await?;
|
||||
let preferences = dto::Preferences {
|
||||
web_theme_base: user.web_theme_base,
|
||||
web_theme_accent: user.web_theme_accent,
|
||||
};
|
||||
Ok(Json(preferences))
|
||||
}
|
||||
|
||||
async fn put_preferences(
|
||||
auth: Auth,
|
||||
State(config_manager): State<config::Manager>,
|
||||
Json(preferences): Json<dto::NewPreferences>,
|
||||
) -> Result<(), APIError> {
|
||||
user_manager
|
||||
.write_preferences(auth.get_username(), &preferences)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn post_trigger_index(
|
||||
_admin_rights: AdminRights,
|
||||
State(scanner): State<scanner::Scanner>,
|
||||
|
|
|
@ -143,18 +143,6 @@ pub struct UserUpdate {
|
|||
pub new_is_admin: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Preferences {
|
||||
pub web_theme_base: Option<String>,
|
||||
pub web_theme_accent: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct NewPreferences {
|
||||
pub web_theme_base: Option<String>,
|
||||
pub web_theme_accent: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||
pub struct MountDir {
|
||||
pub source: String,
|
||||
|
|
|
@ -124,22 +124,6 @@ pub fn delete_user(username: &str) -> Request<()> {
|
|||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn get_preferences() -> Request<()> {
|
||||
Request::builder()
|
||||
.method(Method::GET)
|
||||
.uri("/api/preferences")
|
||||
.body(())
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn put_preferences(preferences: dto::NewPreferences) -> Request<dto::NewPreferences> {
|
||||
Request::builder()
|
||||
.method(Method::PUT)
|
||||
.uri("/api/preferences")
|
||||
.body(preferences)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
pub fn trigger_index() -> Request<()> {
|
||||
Request::builder()
|
||||
.method(Method::POST)
|
||||
|
|
|
@ -139,41 +139,3 @@ async fn delete_user_cannot_delete_self() {
|
|||
let response = service.fetch(&request).await;
|
||||
assert_eq!(response.status(), StatusCode::CONFLICT);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn get_preferences_requires_auth() {
|
||||
let mut service = ServiceType::new(&test_name!()).await;
|
||||
let request = protocol::get_preferences();
|
||||
let response = service.fetch(&request).await;
|
||||
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn get_preferences_golden_path() {
|
||||
let mut service = ServiceType::new(&test_name!()).await;
|
||||
service.complete_initial_setup().await;
|
||||
service.login().await;
|
||||
|
||||
let request = protocol::get_preferences();
|
||||
let response = service.fetch_json::<_, dto::Preferences>(&request).await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn put_preferences_requires_auth() {
|
||||
let mut service = ServiceType::new(&test_name!()).await;
|
||||
let request = protocol::put_preferences(dto::NewPreferences::default());
|
||||
let response = service.fetch(&request).await;
|
||||
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn put_preferences_golden_path() {
|
||||
let mut service = ServiceType::new(&test_name!()).await;
|
||||
service.complete_initial_setup().await;
|
||||
service.login().await;
|
||||
|
||||
let request = protocol::put_preferences(dto::NewPreferences::default());
|
||||
let response = service.fetch(&request).await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue