Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d433831a2
|
||
|
|
43cc4defbb
|
||
|
|
18a7981d82
|
||
|
|
fc5644bf37
|
||
|
|
f31178b3f0
|
||
|
|
7b7d6a29f6
|
||
|
|
36781f2487
|
||
|
|
8d2ed157d5
|
||
|
|
4bf850ae15
|
||
|
|
a2c4980277
|
||
|
|
a960c7d299
|
No files matched your search
Generated
+9
-9
@@ -43,9 +43,9 @@ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.10.0"
|
version = "1.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0"
|
checksum = "375989decec1a0fa424442bed520fa12ede43a48475ce8c7417d2c69b32b5f6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
"find-msvc-tools",
|
||||||
"shlex",
|
"shlex",
|
||||||
@@ -79,9 +79,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.5.3"
|
version = "1.5.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055"
|
checksum = "5f97d3416d5337d15c4b0d78c8c91df922ca143f57ec20e2d1c188333047ef04"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
@@ -285,9 +285,9 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.10.81"
|
version = "0.10.82"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45"
|
checksum = "4de8111e94a56adca7ebfe6c365b6d42f99deb69b74b6becacd4204e2f193aa2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@@ -310,9 +310,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.117"
|
version = "0.9.118"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695"
|
checksum = "19c413d6ec9ebaf5e1c829d355cb3e9f783778d700f135be0921d52fce3c60ae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -486,7 +486,7 @@ checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "simodels"
|
name = "simodels"
|
||||||
version = "0.11.8"
|
version = "0.11.9"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"josekit",
|
"josekit",
|
||||||
"rand",
|
"rand",
|
||||||
|
|||||||
+17
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "simodels"
|
name = "simodels"
|
||||||
version = "0.11.8"
|
version = "0.11.9"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.95"
|
rust-version = "1.95"
|
||||||
description = "Models used for the soaricarus project"
|
description = "Models used for the soaricarus project"
|
||||||
@@ -15,5 +15,21 @@ uuid = { version = "1.29.0", features = ["v4", "serde"] }
|
|||||||
josekit = { version = "0.10.3" }
|
josekit = { version = "0.10.3" }
|
||||||
utoipa = { version = "6.0.0", features = ["uuid", "time"] }
|
utoipa = { version = "6.0.0", features = ["uuid", "time"] }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["full"]
|
||||||
|
full = ["access_level", "album", "constants", "coverart", "ledger", "login_result", "song", "token", "types", "user", "util"]
|
||||||
|
auth = ["constants", "login_result", "token", "user"]
|
||||||
|
access_level = ["constants"]
|
||||||
|
album = []
|
||||||
|
constants = []
|
||||||
|
coverart = ["constants", "types"]
|
||||||
|
ledger = ["constants", "song", "types", "user"]
|
||||||
|
login_result = ["constants", "token", "user"]
|
||||||
|
song = ["constants", "types"]
|
||||||
|
token = []
|
||||||
|
types = []
|
||||||
|
user = []
|
||||||
|
util = []
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { version = "3.27.0" }
|
tempfile = { version = "3.27.0" }
|
||||||
+9
-7
@@ -2,6 +2,8 @@ use std::default::Default;
|
|||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
const DEFAULT_ACCESS_LEVEL: &str = super::constants::access_level::PUBLIC;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
pub struct AccessLevel {
|
pub struct AccessLevel {
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
@@ -13,8 +15,8 @@ impl Default for AccessLevel {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
AccessLevel {
|
AccessLevel {
|
||||||
id: uuid::Uuid::nil(),
|
id: uuid::Uuid::nil(),
|
||||||
level: String::new(),
|
level: DEFAULT_ACCESS_LEVEL.to_string(),
|
||||||
song_id: uuid::Uuid::new_v4(),
|
song_id: uuid::Uuid::nil(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,16 +24,16 @@ impl Default for AccessLevel {
|
|||||||
pub fn default_level() -> AccessLevel {
|
pub fn default_level() -> AccessLevel {
|
||||||
AccessLevel {
|
AccessLevel {
|
||||||
id: uuid::Uuid::nil(),
|
id: uuid::Uuid::nil(),
|
||||||
level: String::from("Public"),
|
level: DEFAULT_ACCESS_LEVEL.to_string(),
|
||||||
song_id: uuid::Uuid::new_v4(),
|
song_id: uuid::Uuid::nil(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn private_level() -> AccessLevel {
|
pub fn private_level() -> AccessLevel {
|
||||||
AccessLevel {
|
AccessLevel {
|
||||||
id: uuid::Uuid::new_v4(),
|
id: uuid::Uuid::nil(),
|
||||||
level: String::from("Private"),
|
level: super::constants::access_level::PRIVATE.to_string(),
|
||||||
song_id: uuid::Uuid::new_v4(),
|
song_id: uuid::Uuid::nil(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,22 @@ pub mod file_extensions {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod song_event {
|
||||||
|
/// Song Event Type - Play
|
||||||
|
pub const SONG_EVENT_TYPE_PLAY: &str = "PLAY";
|
||||||
|
/// Song Event Type - PAUSE
|
||||||
|
pub const SONG_EVENT_TYPE_PAUSE: &str = "PAUSE";
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod access_level {
|
||||||
|
pub const PUBLIC: &str = "PUBLIC";
|
||||||
|
pub const PRIVATE: &str = "PRIVATE";
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod token {
|
||||||
|
pub const TOKEN_TYPE: &str = "JWT";
|
||||||
|
}
|
||||||
|
|
||||||
pub mod error {
|
pub mod error {
|
||||||
pub const DIRECTORY_NOT_INITIALIZED: &str = "Directory has not been initialized";
|
pub const DIRECTORY_NOT_INITIALIZED: &str = "Directory has not been initialized";
|
||||||
pub const FILENAME_NOT_INITIALIZED: &str = "Filename has not bee initialized";
|
pub const FILENAME_NOT_INITIALIZED: &str = "Filename has not bee initialized";
|
||||||
|
|||||||
+15
-2
@@ -1,8 +1,21 @@
|
|||||||
|
#[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
|
||||||
pub struct SongEvent {
|
pub struct SongEvent {
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
pub song_id: uuid::Uuid,
|
pub song_id: uuid::Uuid,
|
||||||
pub user_id: uuid::Uuid,
|
pub user_id: uuid::Uuid,
|
||||||
pub event_type: String,
|
pub event_type: String,
|
||||||
pub event_time: time::OffsetDateTime
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
|
pub event_time: Option<time::OffsetDateTime>,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
|
pub date_created: Option<time::OffsetDateTime>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SongEvent {
|
||||||
|
pub fn is_event_type_valid(&self) -> bool {
|
||||||
|
matches!(
|
||||||
|
self.event_type.as_str(),
|
||||||
|
super::constants::song_event::SONG_EVENT_TYPE_PLAY
|
||||||
|
| super::constants::song_event::SONG_EVENT_TYPE_PAUSE
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-3
@@ -111,15 +111,13 @@ pub struct TokenResource {
|
|||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const TOKEN_TYPE: &str = "JWT";
|
|
||||||
|
|
||||||
pub fn create_token(
|
pub fn create_token(
|
||||||
key: &String,
|
key: &String,
|
||||||
token_resource: &TokenResource,
|
token_resource: &TokenResource,
|
||||||
duration: time::Duration,
|
duration: time::Duration,
|
||||||
) -> Result<(String, i64), josekit::JoseError> {
|
) -> Result<(String, i64), josekit::JoseError> {
|
||||||
let mut header = josekit::jws::JwsHeader::new();
|
let mut header = josekit::jws::JwsHeader::new();
|
||||||
header.set_token_type(TOKEN_TYPE);
|
header.set_token_type(super::constants::token::TOKEN_TYPE);
|
||||||
|
|
||||||
let mut payload = josekit::jwt::JwtPayload::new();
|
let mut payload = josekit::jwt::JwtPayload::new();
|
||||||
let message = &token_resource.message;
|
let message = &token_resource.message;
|
||||||
|
|||||||
Reference in new issue
Block a user