Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronleopold committed May 2, 2024
2 parents 1108406 + 316cd09 commit 707b9d0
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 95 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion apps/server/src/routers/api/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,15 @@ async fn check_for_updates() -> APIResult<Json<UpdateCheck>> {
if github_response.status().is_success() {
let github_json: serde_json::Value = github_response.json().await?;

let latest_semver = github_json["tag_name"].as_str().ok_or_else(|| {
let mut latest_semver = github_json["tag_name"].as_str().ok_or_else(|| {
APIError::InternalServerError(
"Failed to parse latest release tag name".to_string(),
)
})?;
if latest_semver.starts_with('v') && latest_semver.len() > 1 {
latest_semver = &latest_semver[1..];
}

let has_update_available = latest_semver != current_semver;

Ok(Json(UpdateCheck {
Expand Down
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ xml-rs = "0.8.20" # XML reader/writer
zip = "0.6.6"

[dev-dependencies]
temp-env = "0.3.6"
tempfile = { workspace = true }
criterion = { version = "0.5.1", features = ["html_reports", "async_tokio"] }

Expand Down
155 changes: 85 additions & 70 deletions core/src/config/stump_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,43 +540,50 @@ mod tests {

#[test]
fn test_getting_config_from_environment() {
// Set environment variables
env::set_var(PROFILE_KEY, "release");
env::set_var(PORT_KEY, "1337");
env::set_var(VERBOSITY_KEY, "3");
env::set_var(DB_PATH_KEY, "not_a_real_path");
env::set_var(CLIENT_KEY, "not_a_real_dir");
env::set_var(CONFIG_DIR_KEY, "also_not_a_real_dir");
env::set_var(DISABLE_SWAGGER_KEY, "true");
env::set_var(HASH_COST_KEY, "24");
env::set_var(SESSION_TTL_KEY, (3600 * 24).to_string());
env::set_var(SESSION_EXPIRY_INTERVAL_KEY, (60 * 60 * 8).to_string());

// Create a new StumpConfig and load values from the environment.
let config = StumpConfig::new("not_a_dir".to_string())
.with_environment()
.unwrap();

// Confirm values are as expected
assert_eq!(
config,
StumpConfig {
profile: "release".to_string(),
port: 1337,
verbosity: 3,
pretty_logs: true,
db_path: Some("not_a_real_path".to_string()),
client_dir: "not_a_real_dir".to_string(),
config_dir: "also_not_a_real_dir".to_string(),
custom_templates_dir: None,
allowed_origins: vec![],
pdfium_path: None,
disable_swagger: true,
password_hash_cost: 24,
session_ttl: 3600 * 24,
expired_session_cleanup_interval: 60 * 60 * 8,
scanner_chunk_size: DEFAULT_SCANNER_CHUNK_SIZE,
}
temp_env::with_vars(
[
(PROFILE_KEY, Some("release")),
(PORT_KEY, Some("1337")),
(VERBOSITY_KEY, Some("2")),
(DB_PATH_KEY, Some("not_a_real_path")),
(CLIENT_KEY, Some("not_a_real_dir")),
(CONFIG_DIR_KEY, Some("also_not_a_real_dir")),
(DISABLE_SWAGGER_KEY, Some("true")),
(HASH_COST_KEY, Some("24")),
(SESSION_TTL_KEY, Some(&(3600 * 24).to_string())),
(
SESSION_EXPIRY_INTERVAL_KEY,
Some(&(60 * 60 * 8).to_string()),
),
],
|| {
// Create a new StumpConfig and load values from the environment.
let config = StumpConfig::new("not_a_dir".to_string())
.with_environment()
.unwrap();

// Confirm values are as expected
assert_eq!(
config,
StumpConfig {
profile: "release".to_string(),
port: 1337,
verbosity: 2,
pretty_logs: true,
db_path: Some("not_a_real_path".to_string()),
client_dir: "not_a_real_dir".to_string(),
config_dir: "also_not_a_real_dir".to_string(),
allowed_origins: vec![],
pdfium_path: None,
disable_swagger: true,
password_hash_cost: 24,
session_ttl: 3600 * 24,
expired_session_cleanup_interval: 60 * 60 * 8,
scanner_chunk_size: DEFAULT_SCANNER_CHUNK_SIZE,
custom_templates_dir: None,
}
);
},
);
}

Expand Down Expand Up @@ -687,39 +694,47 @@ mod tests {

#[test]
fn test_simulate_first_boot() {
env::set_var(PORT_KEY, "1337");
env::set_var(VERBOSITY_KEY, "2");
env::set_var(DISABLE_SWAGGER_KEY, "true");
env::set_var(HASH_COST_KEY, "1");

let tempdir = tempfile::tempdir().expect("Failed to create temporary directory");
// Now we can create a StumpConfig rooted at the temporary directory
let config_dir = tempdir.path().to_string_lossy().to_string();
let generated = StumpConfig::new(config_dir.clone())
.with_config_file()
.expect("Failed to generate StumpConfig from Stump.toml")
.with_environment()
.expect("Failed to generate StumpConfig from environment");

let expected = StumpConfig {
profile: "debug".to_string(),
port: 1337,
verbosity: 2,
pretty_logs: true,
db_path: None,
client_dir: "./dist".to_string(),
config_dir,
allowed_origins: vec![],
pdfium_path: None,
disable_swagger: true,
password_hash_cost: 1,
session_ttl: DEFAULT_SESSION_TTL,
expired_session_cleanup_interval: DEFAULT_SESSION_EXPIRY_CLEANUP_INTERVAL,
scanner_chunk_size: DEFAULT_SCANNER_CHUNK_SIZE,
custom_templates_dir: None,
};

assert_eq!(generated, expected);
temp_env::with_vars(
[
(PORT_KEY, Some("1337")),
(VERBOSITY_KEY, Some("2")),
(DISABLE_SWAGGER_KEY, Some("true")),
(HASH_COST_KEY, Some("1")),
],
|| {
let tempdir =
tempfile::tempdir().expect("Failed to create temporary directory");
// Now we can create a StumpConfig rooted at the temporary directory
let config_dir = tempdir.path().to_string_lossy().to_string();
let generated = StumpConfig::new(config_dir.clone())
.with_config_file()
.expect("Failed to generate StumpConfig from Stump.toml")
.with_environment()
.expect("Failed to generate StumpConfig from environment");

assert_eq!(
generated,
StumpConfig {
profile: "debug".to_string(),
port: 1337,
verbosity: 2,
pretty_logs: true,
db_path: None,
client_dir: "./dist".to_string(),
config_dir,
allowed_origins: vec![],
pdfium_path: None,
disable_swagger: true,
password_hash_cost: 1,
session_ttl: DEFAULT_SESSION_TTL,
expired_session_cleanup_interval:
DEFAULT_SESSION_EXPIRY_CLEANUP_INTERVAL,
scanner_chunk_size: DEFAULT_SCANNER_CHUNK_SIZE,
custom_templates_dir: None,
}
);
},
);
}

fn get_mock_config_file() -> String {
Expand Down
1 change: 1 addition & 0 deletions crates/integrations/src/notifier/discord_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ mod tests {
DiscordClient::new(webhook_url)
}

#[ignore = "No token"]
#[tokio::test]
async fn test_send_message() {
let client = get_debug_client();
Expand Down
2 changes: 2 additions & 0 deletions crates/integrations/src/notifier/telegram_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ mod tests {
let chat_id = std::env::var("DUMMY_TG_CHAT_ID").expect("Failed to load chat ID");
TelegramClient::new(token, chat_id)
}

#[ignore = "No token"]
#[tokio::test]
async fn test_send_message() {
let client = get_debug_client();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function SideBarButtonLink({
return (
<div
className={cn(
'group inline-flex h-[2.35rem] w-full items-center justify-start rounded-md px-2 text-sm transition-all duration-150 hover:bg-sidebar-300',
'group inline-flex h-[2.35rem] w-full shrink-0 items-center justify-start rounded-md px-2 text-sm transition-all duration-150 hover:bg-sidebar-300',
{
'justify-center border border-dashed border-sidebar-300 bg-opacity-50 text-contrast text-opacity-90 hover:bg-sidebar-200 hover:text-opacity-100':
variant === 'action',
Expand Down
46 changes: 23 additions & 23 deletions packages/i18n/src/locales/fr.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"underConstruction": {
"heading": "This is awkward",
"message": "You've stumbled upon a page that's still being developed. I'd love to show it to you, but it isn't quite ready yet.",
"homeLink": "Go Home",
"githubLink": "View the GitHub issue"
"heading": "C'est embarrassant",
"message": "Vous êtes tombé sur une page qui est encore en cours de développement. J'aimerais vous la montrer, mais elle n'est pas encore tout à fait prête.",
"homeLink": "Aller à l'accueil",
"githubLink": "Voir le ticket GitHub"
},
"authScene": {
"claimHeading": "Initialisez votre serveur",
Expand Down Expand Up @@ -375,29 +375,29 @@
}
},
"navigationArrangement": {
"label": "Navigation arrangement",
"label": "Disposition de la navigation",
"description": {
"sidebar": "Arrange and customize the navigation items in the sidebar",
"topbar": "Arrange and customize the navigation items in the topbar"
"sidebar": "Organiser et personnaliser les éléments de navigation dans la barre latérale",
"topbar": "Organiser et personnaliser les éléments de navigation dans la barre supérieure"
},
"isLocked": "Arrangement is locked",
"lock": "Lock arrangement",
"unlock": "Unlock arrangement",
"isLocked": "L'organisation est verrouillée",
"lock": "Verrouiller la disposition",
"unlock": "Déverrouiller la disposition",
"options": {
"Home": "Home",
"Explore": "Explore",
"Libraries": "Libraries",
"BookClubs": "Book clubs",
"SmartLists": "Smart lists"
"Home": "Accueil",
"Explore": "Explorer",
"Libraries": "Bibliothèques",
"BookClubs": "Clubs de lecture",
"SmartLists": "Listes intelligentes"
},
"entityOptions": {
"createAction": {
"label": "Show create action",
"help": "Show the create action in the navigation"
"label": "Afficher l'action Créer",
"help": "Afficher l'action Créer dans la navigation"
},
"linkToAll": {
"label": "See all link",
"help": "A link to a page dedicated to viewing all items of this type"
"label": "Voir tous les liens",
"help": "Un lien vers une page dédiée à la visualisation de tous les éléments de ce type"
}
}
}
Expand All @@ -409,7 +409,7 @@
"description": "Options par défaut pour les lecteurs. Elles sont liées à votre appareil actuel uniquement",
"sections": {
"imageBasedBooks": {
"label": "Livres illustrés",
"label": "Livres à base d'images",
"description": "Bandes dessinées, mangas, et autres livres illustrés",
"sections": {
"preloadAheadCount": {
Expand Down Expand Up @@ -578,8 +578,8 @@
"description": "Permet à l'utilisateur de télécharger des fichiers à partir du serveur"
},
"download": {
"label": "Download files",
"description": "Allows the user to download files from the server"
"label": "Télécharger les fichiers",
"description": "Permet à l'utilisateur de télécharger des fichiers à partir du serveur"
},
"upload": {
"label": "Envoyer des fichiers",
Expand Down Expand Up @@ -689,7 +689,7 @@
"smartlists": "Listes intelligentes",
"noSmartlists": "Aucune liste intelligente",
"createSmartlist": "Créer une liste intelligente",
"seeAll": "See all"
"seeAll": "Afficher tout"
},
"libraryOptions": {
"scanLibrary": "Scanner",
Expand Down

0 comments on commit 707b9d0

Please sign in to comment.