Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8becd9a49c
|
||
|
|
6ec7c4e212 | ||
|
|
5c98486f75 | ||
|
|
8e91af657e | ||
|
|
d751622bac | ||
|
|
6022347cb7 | ||
|
|
e6ab0bcd83 | ||
|
|
94d97cb81d | ||
|
|
d6d7197419 | ||
|
|
fe9d101bd0 | ||
|
|
859b0fb1b3 | ||
|
|
c04f27570e | ||
|
|
0a1949c706 | ||
|
|
e2995fd223 |
No files matched your search
@@ -10,18 +10,19 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Important for git describe --tags
|
fetch-depth: 0 # Important for git describe --tags
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.99.1
|
||||||
components: cargo
|
components: cargo
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
id: version
|
id: version
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Rust Build
|
name: simodels Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -8,55 +8,65 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.99.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: cargo check
|
- run: cargo check
|
||||||
|
|
||||||
test:
|
test:
|
||||||
name: Test Suite
|
name: Test Suite
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.99.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: cargo test
|
- run: cargo test
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
name: Rustfmt
|
name: Rustfmt
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.99.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add rustfmt
|
- run: rustup component add rustfmt
|
||||||
- run: cargo fmt --all -- --check
|
- run: cargo fmt --all -- --check
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
name: Clippy
|
name: Clippy
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.99.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- run: cargo clippy -- -D warnings
|
- run: cargo clippy -- -D warnings
|
||||||
|
|
||||||
build:
|
build:
|
||||||
name: build
|
name: build
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-26.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.95
|
toolchain: 1.99.1
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
- run: cargo build
|
- run: cargo build
|
||||||
+3
-28
@@ -6,7 +6,7 @@ stages:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
image: rust:1.85
|
image: rust:1.95
|
||||||
script:
|
script:
|
||||||
- cargo build --release
|
- cargo build --release
|
||||||
- ls -R target/release/
|
- ls -R target/release/
|
||||||
@@ -22,7 +22,7 @@ build:
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
image: rust:1.85
|
image: rust:1.95
|
||||||
script:
|
script:
|
||||||
- cargo test
|
- cargo test
|
||||||
cache:
|
cache:
|
||||||
@@ -33,7 +33,7 @@ test:
|
|||||||
|
|
||||||
test_variable:
|
test_variable:
|
||||||
stage: test
|
stage: test
|
||||||
image: rust:1.85
|
image: rust:1.95
|
||||||
script:
|
script:
|
||||||
- echo "Checking CARGO_LOGIN_TOKEN..."
|
- echo "Checking CARGO_LOGIN_TOKEN..."
|
||||||
- if [[ -z "$CARGO_LOGIN_TOKEN" ]]; then echo "CARGO_LOGIN_TOKEN is empty!"; exit 1; else echo "CARGO_LOGIN_TOKEN is set."; fi
|
- if [[ -z "$CARGO_LOGIN_TOKEN" ]]; then echo "CARGO_LOGIN_TOKEN is empty!"; exit 1; else echo "CARGO_LOGIN_TOKEN is set."; fi
|
||||||
@@ -56,28 +56,3 @@ extract_version:
|
|||||||
artifacts:
|
artifacts:
|
||||||
reports:
|
reports:
|
||||||
dotenv: version.env
|
dotenv: version.env
|
||||||
|
|
||||||
tag_release:
|
|
||||||
stage: deploy
|
|
||||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
||||||
rules:
|
|
||||||
- if: '($CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "main") && $CI_PIPELINE_SOURCE == "push"'
|
|
||||||
dependencies:
|
|
||||||
- extract_version
|
|
||||||
script:
|
|
||||||
- release-cli create --name "Release $CI_COMMIT_BRANCH-v$VERSION" --tag-name "$CI_COMMIT_BRANCH-v$VERSION"
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
stage: deploy
|
|
||||||
image: rust:1.85
|
|
||||||
script:
|
|
||||||
- echo "Deployment will be configured when this is ready for use"
|
|
||||||
# - env
|
|
||||||
# Uncomment when you are ready for this to be published
|
|
||||||
# - cargo login "$CARGO_LOGIN_TOKEN"
|
|
||||||
# - cargo publish
|
|
||||||
dependencies:
|
|
||||||
- build
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_TAG'
|
|
||||||
|
|
||||||
Generated
+210
-393
File diff suppressed because it is too large.
Load diff
+26
-9
@@ -1,19 +1,36 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus_models"
|
name = "simodels"
|
||||||
version = "0.10.0"
|
version = "0.11.20"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.95"
|
rust-version = "1.95"
|
||||||
description = "models used for the icarus project"
|
description = "Models used for the soaricarus project"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0.228", features = ["derive"] }
|
serde = { version = "1.0.229", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.145" }
|
serde_json = { version = "1.0.154" }
|
||||||
rand = { version = "0.9.2" }
|
rand = { version = "0.10.4" }
|
||||||
time = { version = "0.3.44", features = ["formatting", "macros", "parsing", "serde"] }
|
time = { version = "0.3.55", features = ["formatting", "macros", "parsing", "serde"] }
|
||||||
uuid = { version = "1.18.1", features = ["v4", "serde"] }
|
uuid = { version = "1.29.3", features = ["v4", "serde"] }
|
||||||
josekit = { version = "0.10.3" }
|
josekit = { version = "0.10.3" }
|
||||||
utoipa = { version = "5.4.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", "register_result", "token", "user"]
|
||||||
|
access_level = ["constants"]
|
||||||
|
album = []
|
||||||
|
constants = []
|
||||||
|
coverart = ["constants", "types"]
|
||||||
|
ledger = ["constants", "song", "types", "user"]
|
||||||
|
login_result = ["constants", "token", "user"]
|
||||||
|
register_result = []
|
||||||
|
song = ["constants", "types"]
|
||||||
|
token = []
|
||||||
|
types = []
|
||||||
|
user = []
|
||||||
|
util = []
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { version = "3.27.0" }
|
tempfile = { version = "3.27.0" }
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 2026 Kun Deng.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
A library containing commonly used structs, functions, enums, constants and other code
|
# simodels
|
||||||
that is used throughout the icarus projects. Code from this library serves as the model
|
Library containing structs, functions, enums, constants and other code
|
||||||
for other projects in the icarus project.
|
that is used throughout the soaricarus projects. Code from this library serves as the model
|
||||||
|
for other projects in the soaricarus project.
|
||||||
+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(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+36
-1
@@ -37,7 +37,42 @@ pub mod collection {
|
|||||||
pub artist: String,
|
pub artist: String,
|
||||||
pub disc: i32,
|
pub disc: i32,
|
||||||
pub track: i32,
|
pub track: i32,
|
||||||
// In seconds
|
/// In seconds
|
||||||
pub duration: f64,
|
pub duration: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn deserialize_json(json_data: &str, album: &mut Album) -> Result<(), serde_json::Error> {
|
||||||
|
match serde_json::from_str::<Album>(json_data) {
|
||||||
|
Ok(parsed_album) => {
|
||||||
|
*album = parsed_album;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
#[test]
|
||||||
|
fn test_deserilize_album_collection_json() {
|
||||||
|
let album_file_path = "tests/album.json";
|
||||||
|
let album_file_content = match std::fs::read_to_string(album_file_path) {
|
||||||
|
Ok(content) => content,
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
String::new()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut album = super::collection::Album::default();
|
||||||
|
match super::collection::deserialize_json(&album_file_content, &mut album) {
|
||||||
|
Ok(_) => {
|
||||||
|
assert_eq!(3, album.tracks.len(), "Track count do not match");
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "Error: {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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";
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::RngExt;
|
||||||
|
|
||||||
const FILENAME_LENGTH: i32 = 16;
|
const FILENAME_LENGTH: i32 = 16;
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ pub struct CoverArt {
|
|||||||
pub directory: String,
|
pub directory: String,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub file_type: String,
|
pub file_type: String,
|
||||||
|
pub file_key: String,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
pub song_id: uuid::Uuid,
|
pub song_id: uuid::Uuid,
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#[derive(Debug, Default, serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
|
||||||
|
pub struct SongEvent {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub song_id: uuid::Uuid,
|
||||||
|
pub user_id: uuid::Uuid,
|
||||||
|
pub event_type: String,
|
||||||
|
#[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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,10 @@ pub mod access_level;
|
|||||||
pub mod album;
|
pub mod album;
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
pub mod coverart;
|
pub mod coverart;
|
||||||
|
pub mod ledger;
|
||||||
pub mod login_result;
|
pub mod login_result;
|
||||||
|
pub mod playback_queue;
|
||||||
|
pub mod register_result;
|
||||||
pub mod song;
|
pub mod song;
|
||||||
pub mod token;
|
pub mod token;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use utoipa::ToSchema;
|
||||||
|
|
||||||
|
/// Playback queue device type - Browser
|
||||||
|
pub const PLAYBACK_QUEUE_DEVICE_TYPE_BROWSER: &str = "BROWSER";
|
||||||
|
/// Playback queue device type - Mobile
|
||||||
|
pub const PLAYBACK_QUEUE_DEVICE_TYPE_MOBILE: &str = "MOBILE";
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize, Serialize, ToSchema)]
|
||||||
|
pub struct PlaybackQueue {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub name: String,
|
||||||
|
pub device_type: String,
|
||||||
|
pub user_id: uuid::Uuid,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
|
pub date_created: Option<time::OffsetDateTime>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize, Serialize, ToSchema)]
|
||||||
|
pub struct PlaybackQueueItem {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub queue_index: i32,
|
||||||
|
pub playback_queue_id: uuid::Uuid,
|
||||||
|
pub song_id: uuid::Uuid,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
|
pub date_created: Option<time::OffsetDateTime>,
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
|
pub struct RegisterResult {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub username: String,
|
||||||
|
pub email: String,
|
||||||
|
pub firstname: String,
|
||||||
|
pub lastname: String,
|
||||||
|
#[serde(with = "time::serde::rfc3339::option")]
|
||||||
|
pub date_created: Option<time::OffsetDateTime>,
|
||||||
|
}
|
||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::RngExt;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::constants;
|
use crate::constants;
|
||||||
@@ -49,6 +49,7 @@ pub struct Song {
|
|||||||
pub data: Vec<u8>,
|
pub data: Vec<u8>,
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub directory: String,
|
pub directory: String,
|
||||||
|
pub file_key: String,
|
||||||
// TODO: Think about what to do with this
|
// TODO: Think about what to do with this
|
||||||
// #[serde(skip)]
|
// #[serde(skip)]
|
||||||
// pub album_id: i32,
|
// pub album_id: i32,
|
||||||
|
|||||||
+3
-5
@@ -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;
|
||||||
@@ -164,9 +162,9 @@ mod tests {
|
|||||||
|
|
||||||
fn test_resource() -> TokenResource {
|
fn test_resource() -> TokenResource {
|
||||||
TokenResource {
|
TokenResource {
|
||||||
issuer: String::from("icarus_auth_test"),
|
issuer: String::from("soaricarus_auth_test"),
|
||||||
message: String::from("Authorization"),
|
message: String::from("Authorization"),
|
||||||
audiences: vec![String::from("icarus_test")],
|
audiences: vec![String::from("soaricarus_test")],
|
||||||
id: uuid::Uuid::nil(),
|
id: uuid::Uuid::nil(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ pub struct User {
|
|||||||
pub salt_id: uuid::Uuid,
|
pub salt_id: uuid::Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)]
|
||||||
|
pub struct UserProfile {
|
||||||
|
pub firstname: String,
|
||||||
|
pub lastname: String,
|
||||||
|
pub username: String,
|
||||||
|
pub email: String,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for User {
|
impl Default for User {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
User {
|
User {
|
||||||
|
|||||||
+3
-3
@@ -33,8 +33,8 @@ mod song_tests {
|
|||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
use icarus_models::song;
|
use simodels::song;
|
||||||
use icarus_models::types;
|
use simodels::types;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_song_to_data() {
|
fn test_song_to_data() {
|
||||||
@@ -157,7 +157,7 @@ mod song_tests {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod album_tests {
|
mod album_tests {
|
||||||
use crate::utils;
|
use crate::utils;
|
||||||
use icarus_models::album;
|
use simodels::album;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_album() {
|
fn parse_album() {
|
||||||
|
|||||||
Reference in new issue
Block a user