Spiegel von
https://github.com/dani-garcia/vaultwarden.git
synchronisiert 2024-11-04 02:18:00 +01:00
Merge branch 'BlackDex-add-avatar-color-feature'
Dieser Commit ist enthalten in:
Commit
174bea8d6e
12 geänderte Dateien mit 42 neuen und 1 gelöschten Zeilen
0
migrations/mysql/2023-01-11-205851_add_avatar_color/down.sql
Normale Datei
0
migrations/mysql/2023-01-11-205851_add_avatar_color/down.sql
Normale Datei
2
migrations/mysql/2023-01-11-205851_add_avatar_color/up.sql
Normale Datei
2
migrations/mysql/2023-01-11-205851_add_avatar_color/up.sql
Normale Datei
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE users
|
||||||
|
ADD COLUMN avatar_color VARCHAR(7);
|
2
migrations/postgresql/2023-01-11-205851_add_avatar_color/up.sql
Normale Datei
2
migrations/postgresql/2023-01-11-205851_add_avatar_color/up.sql
Normale Datei
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE users
|
||||||
|
ADD COLUMN avatar_color TEXT;
|
0
migrations/sqlite/2023-01-11-205851_add_avatar_color/down.sql
Normale Datei
0
migrations/sqlite/2023-01-11-205851_add_avatar_color/down.sql
Normale Datei
2
migrations/sqlite/2023-01-11-205851_add_avatar_color/up.sql
Normale Datei
2
migrations/sqlite/2023-01-11-205851_add_avatar_color/up.sql
Normale Datei
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE users
|
||||||
|
ADD COLUMN avatar_color TEXT;
|
|
@ -39,6 +39,7 @@ pub fn routes() -> Vec<rocket::Route> {
|
||||||
api_key,
|
api_key,
|
||||||
rotate_api_key,
|
rotate_api_key,
|
||||||
get_known_device,
|
get_known_device,
|
||||||
|
put_avatar,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +229,32 @@ async fn post_profile(data: JsonUpcase<ProfileData>, headers: Headers, mut conn:
|
||||||
Ok(Json(user.to_json(&mut conn).await))
|
Ok(Json(user.to_json(&mut conn).await))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
struct AvatarData {
|
||||||
|
AvatarColor: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[put("/accounts/avatar", data = "<data>")]
|
||||||
|
async fn put_avatar(data: JsonUpcase<AvatarData>, headers: Headers, mut conn: DbConn) -> JsonResult {
|
||||||
|
let data: AvatarData = data.into_inner().data;
|
||||||
|
|
||||||
|
// It looks like it only supports the 6 hex color format.
|
||||||
|
// If you try to add the short value it will not show that color.
|
||||||
|
// Check and force 7 chars, including the #.
|
||||||
|
if let Some(color) = &data.AvatarColor {
|
||||||
|
if color.len() != 7 {
|
||||||
|
err!("The field AvatarColor must be a HTML/Hex color code with a length of 7 characters")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut user = headers.user;
|
||||||
|
user.avatar_color = data.AvatarColor;
|
||||||
|
|
||||||
|
user.save(&mut conn).await?;
|
||||||
|
Ok(Json(user.to_json(&mut conn).await))
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/users/<uuid>/public-key")]
|
#[get("/users/<uuid>/public-key")]
|
||||||
async fn get_public_keys(uuid: String, _headers: Headers, mut conn: DbConn) -> JsonResult {
|
async fn get_public_keys(uuid: String, _headers: Headers, mut conn: DbConn) -> JsonResult {
|
||||||
let user = match User::find_by_uuid(&uuid, &mut conn).await {
|
let user = match User::find_by_uuid(&uuid, &mut conn).await {
|
||||||
|
|
|
@ -46,6 +46,8 @@ db_object! {
|
||||||
pub client_kdf_iter: i32,
|
pub client_kdf_iter: i32,
|
||||||
|
|
||||||
pub api_key: Option<String>,
|
pub api_key: Option<String>,
|
||||||
|
|
||||||
|
pub avatar_color: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Identifiable, Queryable, Insertable)]
|
#[derive(Identifiable, Queryable, Insertable)]
|
||||||
|
@ -113,6 +115,8 @@ impl User {
|
||||||
client_kdf_iter: Self::CLIENT_KDF_ITER_DEFAULT,
|
client_kdf_iter: Self::CLIENT_KDF_ITER_DEFAULT,
|
||||||
|
|
||||||
api_key: None,
|
api_key: None,
|
||||||
|
|
||||||
|
avatar_color: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,6 +230,7 @@ impl User {
|
||||||
"Providers": [],
|
"Providers": [],
|
||||||
"ProviderOrganizations": [],
|
"ProviderOrganizations": [],
|
||||||
"ForcePasswordReset": false,
|
"ForcePasswordReset": false,
|
||||||
|
"AvatarColor": self.avatar_color,
|
||||||
"Object": "profile",
|
"Object": "profile",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,6 +200,7 @@ table! {
|
||||||
client_kdf_type -> Integer,
|
client_kdf_type -> Integer,
|
||||||
client_kdf_iter -> Integer,
|
client_kdf_iter -> Integer,
|
||||||
api_key -> Nullable<Text>,
|
api_key -> Nullable<Text>,
|
||||||
|
avatar_color -> Nullable<Text>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ table! {
|
||||||
client_kdf_type -> Integer,
|
client_kdf_type -> Integer,
|
||||||
client_kdf_iter -> Integer,
|
client_kdf_iter -> Integer,
|
||||||
api_key -> Nullable<Text>,
|
api_key -> Nullable<Text>,
|
||||||
|
avatar_color -> Nullable<Text>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ table! {
|
||||||
client_kdf_type -> Integer,
|
client_kdf_type -> Integer,
|
||||||
client_kdf_iter -> Integer,
|
client_kdf_iter -> Integer,
|
||||||
api_key -> Nullable<Text>,
|
api_key -> Nullable<Text>,
|
||||||
|
avatar_color -> Nullable<Text>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
// The more key/value pairs there are the more recursion occurs.
|
// The more key/value pairs there are the more recursion occurs.
|
||||||
// We want to keep this as low as possible, but not higher then 128.
|
// We want to keep this as low as possible, but not higher then 128.
|
||||||
// If you go above 128 it will cause rust-analyzer to fail,
|
// If you go above 128 it will cause rust-analyzer to fail,
|
||||||
#![recursion_limit = "94"]
|
#![recursion_limit = "97"]
|
||||||
|
|
||||||
// When enabled use MiMalloc as malloc instead of the default malloc
|
// When enabled use MiMalloc as malloc instead of the default malloc
|
||||||
#[cfg(feature = "enable_mimalloc")]
|
#[cfg(feature = "enable_mimalloc")]
|
||||||
|
|
Laden …
In neuem Issue referenzieren