Removed utils mod, moved hexing the name to entity library

This commit is contained in:
2024-02-03 16:31:19 +03:00
parent e8f0fcd819
commit a359364606
12 changed files with 18 additions and 26 deletions

View File

@ -16,3 +16,4 @@ sqlx = { version = "0.7", features = [
"macros",
"migrate",
], default-features = false }
hex = "0.4"

View File

@ -93,13 +93,14 @@ impl Account {
.map(|_| ())
}
/// Gets a name by a hex of a SHA256 hash of the name
/// Gets a name by a SHA256 hash of the name
#[inline]
pub async fn get_name_by_hash(
user_id: u64,
hash: String,
hash: &[u8],
pool: &Pool,
) -> crate::Result<Option<String>> {
let hash = hex::encode(hash);
let name = query_as::<_, (String,)>(
"SELECT `name` FROM `account` WHERE SHA2(`name`, 256) = ? AND `user_id` = ?;",
)