Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/checkFrontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: checkFrontend.yml
permissions:
contents: read
on:
push:

jobs:
check-frontend:
name: Check Frontend
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '24'
- name: Set up pnpm
uses: pnpm/action-setup@v2
with:
version: 10
- name: Install dependencies
working-directory: ui
run: pnpm install
- name: Test frontend
working-directory: ui
run: pnpm run test
- name: Run tsc
working-directory: ui
run: pnpm run tsc:check
- name: Build project
working-directory: ui
run: pnpm run build
2 changes: 1 addition & 1 deletion .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
uses: "pascalgn/automerge-action@v0.16.3"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_METHOD: squash
MERGE_METHOD: squash
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "podfetch"
version = "0.1.0"
edition = "2021"
edition = "2024"
build = "build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
11 changes: 5 additions & 6 deletions src/adapters/api/models/podcast_episode_dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,11 @@ fn map_url(
&ENVIRONMENT_SERVICE.server_url
))
.unwrap();
if ENVIRONMENT_SERVICE.any_auth_enabled {
if let Some(user) = user {
if let Some(key) = &user.api_key {
url.query_pairs_mut().append_pair("apiKey", key);
}
}
if ENVIRONMENT_SERVICE.any_auth_enabled
&& let Some(user) = user
&& let Some(key) = &user.api_key
{
url.query_pairs_mut().append_pair("apiKey", key);
}
url.query_pairs_mut()
.append_pair("episodeId", &episode.episode_id);
Expand Down
56 changes: 24 additions & 32 deletions src/adapters/file/file_handle_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,15 @@ impl FileHandleWrapper {
if let Some(download_type) = &episode.download_location {
let file_type = FileHandlerType::from(download_type.as_str());
if FileHandlerType::S3 == file_type {
if let Some(file_path) = &episode.file_image_path {
if let Err(e) = S3Handler::remove_file(file_path) {
log::error!(
"Error removing file: {file_path} with reason {e}"
);
}
if let Some(file_path) = &episode.file_image_path
&& let Err(e) = S3Handler::remove_file(file_path)
{
log::error!("Error removing file: {file_path} with reason {e}");
}
if let Some(file_path) = &episode.file_episode_path {
if let Err(e) = S3Handler::remove_file(file_path) {
log::error!(
"Error removing file: {file_path} with reason {e}"
);
}
if let Some(file_path) = &episode.file_episode_path
&& let Err(e) = S3Handler::remove_file(file_path)
{
log::error!("Error removing file: {file_path} with reason {e}");
}
}
}
Expand All @@ -83,30 +79,26 @@ impl FileHandleWrapper {
if let Some(download_type) = &episode.download_location {
let file_type = FileHandlerType::from(download_type.as_str());
if FileHandlerType::S3 == file_type {
if let Some(file_path) = &episode.file_image_path {
if let Err(e) = S3Handler::remove_file(file_path) {
log::error!(
"Error removing file: {file_path} with reason {e}"
);
}
if let Some(file_path) = &episode.file_image_path
&& let Err(e) = S3Handler::remove_file(file_path)
{
log::error!("Error removing file: {file_path} with reason {e}");
}
if let Some(file_path) = &episode.file_episode_path {
if let Err(e) = S3Handler::remove_file(file_path) {
log::error!("Error removing file: {file_path} {e}");
}
if let Some(file_path) = &episode.file_episode_path
&& let Err(e) = S3Handler::remove_file(file_path)
{
log::error!("Error removing file: {file_path} {e}");
}
} else {
if let Some(file_path) = &episode.file_image_path {
if let Err(e) = LocalFileHandler::remove_file(file_path) {
log::error!(
"Error removing file: {file_path} with reason {e}"
);
}
if let Some(file_path) = &episode.file_image_path
&& let Err(e) = LocalFileHandler::remove_file(file_path)
{
log::error!("Error removing file: {file_path} with reason {e}");
}
if let Some(file_path) = &episode.file_episode_path {
if let Err(e) = LocalFileHandler::remove_file(file_path) {
log::error!("Error removing file: {file_path} {e}");
}
if let Some(file_path) = &episode.file_episode_path
&& let Err(e) = LocalFileHandler::remove_file(file_path)
{
log::error!("Error removing file: {file_path} {e}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/file/local_file_handler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::adapters::file::file_handler::{FileHandler, FileRequest};
use crate::utils::error::{map_io_error, CustomError, ErrorSeverity};
use crate::utils::error::{CustomError, ErrorSeverity, map_io_error};
use std::fs::File;
use std::future::Future;
use std::io;
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/file/s3_file_handler.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::adapters::file::file_handler::{FileHandler, FileRequest};
use crate::utils::error::{map_s3_error, CustomError, ErrorSeverity};
use crate::utils::error::{CustomError, ErrorSeverity, map_s3_error};
use futures_util::TryFutureExt;
use std::future::Future;
use std::pin::Pin;
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/persistence/dbconfig/db.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::adapters::persistence::dbconfig::DBType;
use crate::commands::startup::DbPool;
use crate::constants::inner_constants::ENVIRONMENT_SERVICE;
use diesel::r2d2::ConnectionManager;
use diesel::Connection;
use diesel::r2d2::ConnectionManager;
use r2d2::Pool;
use std::process::exit;
use std::sync::OnceLock;
Expand Down
5 changes: 2 additions & 3 deletions src/adapters/persistence/dbconfig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pub mod db;
#[path = "schemas/sqlite/schema.rs"]
pub mod schema;


#[derive(diesel::MultiConnection)]
pub enum DBType {
#[cfg(feature = "postgresql")]
Expand Down Expand Up @@ -33,11 +32,11 @@ macro_rules! execute_with_conn {
let _ = match conn.deref_mut() {
#[cfg(feature = "sqlite")]
$crate::adapters::persistence::dbconfig::DBType::Sqlite(conn) => {
return $diesel_func(conn)
return $diesel_func(conn);
}
#[cfg(feature = "postgresql")]
$crate::adapters::persistence::dbconfig::DBType::Postgresql(conn) => {
return $diesel_func(conn)
return $diesel_func(conn);
}
};
}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::adapters::persistence::model::device::device_entity::DeviceEntity;
use crate::application::repositories::device_repository::DeviceRepository;
use crate::domain::models::device::model::Device;
use crate::execute_with_conn;
use crate::utils::error::{map_db_error, CustomError, ErrorSeverity};
use crate::utils::error::{CustomError, ErrorSeverity, map_db_error};
use diesel::RunQueryDsl;

pub struct DeviceRepositoryImpl;
Expand Down
4 changes: 2 additions & 2 deletions src/auth_middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use axum::extract::Request;
use axum::http::HeaderValue;
use axum::middleware::Next;
use axum::response::Response;
use base64::engine::general_purpose;
use base64::Engine;
use base64::engine::general_purpose;
use jsonwebtoken::jwk::{JwkSet, KeyAlgorithm};
use jsonwebtoken::{decode, Algorithm, DecodingKey, Validation};
use jsonwebtoken::{Algorithm, DecodingKey, Validation, decode};
use log::info;
use serde_json::Value;
use sha256::digest;
Expand Down
2 changes: 1 addition & 1 deletion src/command_line_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::utils::time::get_current_timestamp_str;
use log::error;
use sha256::digest;
use std::env::Args;
use std::io::{stdin, Error, ErrorKind};
use std::io::{Error, ErrorKind, stdin};
use std::process::exit;

pub async fn start_command_line(mut args: Args) -> Result<(), CustomError> {
Expand Down
30 changes: 18 additions & 12 deletions src/commands/startup.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::adapters::api::controllers::routes::global_routes;
use crate::adapters::persistence::dbconfig::db::get_connection;
use crate::adapters::persistence::dbconfig::DBType;
use crate::adapters::persistence::dbconfig::db::get_connection;
use crate::auth_middleware::{
handle_basic_auth, handle_no_auth, handle_oidc_auth, handle_proxy_auth,
};
Expand All @@ -26,20 +26,20 @@ use crate::service::file_service::FileService;
use crate::service::podcast_episode_service::PodcastEpisodeService;
use crate::service::rust_service::PodcastService;
use crate::utils::error::{CustomError, CustomErrorInner};
use axum::Router;
use axum::body::Body;
use axum::extract::Request;
use axum::middleware::from_fn;
use axum::response::{IntoResponse, Redirect, Response};
use axum::routing::get;
use axum::Router;
use clokwerk::{Scheduler, TimeUnits};
use diesel::r2d2::ConnectionManager;
use diesel_migrations::MigrationHarness;
use log::info;
use maud::{html, Markup};
use maud::{Markup, html};
use r2d2::Pool;
use socketioxide::extract::SocketRef;
use socketioxide::SocketIoBuilder;
use socketioxide::extract::SocketRef;
use std::ops::DerefMut;
use std::process::exit;
use std::sync::OnceLock;
Expand All @@ -55,9 +55,9 @@ use utoipa_scalar::Servable as UtoipaServable;
use utoipa_swagger_ui::SwaggerUi;

pub type DbPool = Pool<ConnectionManager<DBType>>;
use crate::EmbeddedMigrations;
use crate::embed_migrations;
use crate::utils::error::ErrorSeverity::Warning;
use crate::EmbeddedMigrations;

import_database_config!();

Expand Down Expand Up @@ -167,7 +167,9 @@ pub fn check_server_config() {
if ENVIRONMENT_SERVICE.http_basic
&& (ENVIRONMENT_SERVICE.password.is_none() || ENVIRONMENT_SERVICE.username.is_none())
{
eprintln!("BASIC_AUTH activated but no username or password set. Please set username and password in the .env file.");
eprintln!(
"BASIC_AUTH activated but no username or password set. Please set username and password in the .env file."
);
exit(1);
}

Expand All @@ -176,12 +178,16 @@ pub fn check_server_config() {
|| ENVIRONMENT_SERVICE.oidc_configured
|| ENVIRONMENT_SERVICE.reverse_proxy)
{
eprintln!("GPODDER_INTEGRATION_ENABLED activated but no BASIC_AUTH or OIDC_AUTH set. Please set BASIC_AUTH or OIDC_AUTH in the .env file.");
eprintln!(
"GPODDER_INTEGRATION_ENABLED activated but no BASIC_AUTH or OIDC_AUTH set. Please set BASIC_AUTH or OIDC_AUTH in the .env file."
);
exit(1);
}

if check_if_multiple_auth_is_configured() {
eprintln!("You cannot have oidc and basic auth enabled at the same time. Please disable one of them.");
eprintln!(
"You cannot have oidc and basic auth enabled at the same time. Please disable one of them."
);
exit(1);
}
}
Expand Down Expand Up @@ -295,15 +301,15 @@ pub fn run_migrations() {

match conn {
#[cfg(feature = "postgresql")]
DBType::Postgresql(ref mut conn) => {
DBType::Postgresql(conn) => {
let res_migration = conn.run_pending_migrations(POSTGRES_MIGRATIONS);

if res_migration.is_err() {
panic!("Could not run migrations: {}", res_migration.err().unwrap());
}
}
#[cfg(feature = "sqlite")]
DBType::Sqlite(ref mut conn) => {
DBType::Sqlite(conn) => {
let res_migration = conn.run_pending_migrations(SQLITE_MIGRATIONS);

if res_migration.is_err() {
Expand Down Expand Up @@ -424,10 +430,10 @@ pub mod tests {
#[cfg(feature = "postgresql")]
use crate::commands::startup::handle_config_for_server_startup;
#[cfg(feature = "postgresql")]
use testcontainers::runners::AsyncRunner;
#[cfg(feature = "postgresql")]
use testcontainers::ContainerAsync;
#[cfg(feature = "postgresql")]
use testcontainers::runners::AsyncRunner;
#[cfg(feature = "postgresql")]
use testcontainers_modules::postgres::Postgres;

pub struct TestServerWrapper<'a> {
Expand Down
1 change: 1 addition & 0 deletions src/constants/inner_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ pub const SUB_DIRECTORY: &str = "SUB_DIRECTORY";
pub const POLLING_INTERVAL: &str = "POLLING_INTERVAL";

pub const STANDARD_USER: &str = "user123";
pub const STANDARD_USER_ID: i32 = 9999;

pub const PODCAST_FILENAME: &str = "podcast";
pub const PODCAST_IMAGENAME: &str = "image";
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/manifest_controller.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::constants::inner_constants::ENVIRONMENT_SERVICE;
use crate::utils::error::CustomError;
use axum::routing::get;
use axum::Json;
use axum::routing::get;
use utoipa_axum::router::OpenApiRouter;

#[derive(Serialize)]
Expand Down
13 changes: 6 additions & 7 deletions src/controllers/podcast_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ use axum::body::Body;
use axum::extract::{Path, Query};
use axum::http::StatusCode;
use axum::response::IntoResponse;
use axum::{debug_handler, Extension, Json};
use axum::{Extension, Json, debug_handler};
use axum_extra::extract::OptionalQuery;
use opml::{Outline, OPML};
use rand::rngs::ThreadRng;
use opml::{OPML, Outline};
use rand::Rng;
use rand::rngs::ThreadRng;
use rss::Channel;
use serde_json::{from_str, Value};
use serde_json::{Value, from_str};
use std::thread;
use tokio::task::spawn_blocking;

Expand All @@ -29,12 +29,11 @@ use crate::models::podcast_episode::PodcastEpisode;
use crate::models::podcast_rssadd_model::PodcastRSSAddModel;
use crate::models::podcasts::Podcast;
use crate::models::user::User;
use crate::service::file_service::{perform_podcast_variable_replacement, FileService};
use crate::service::file_service::{FileService, perform_podcast_variable_replacement};
use crate::utils::append_to_header::add_basic_auth_headers_conditionally;
use reqwest::header::HeaderMap;
use tokio::runtime::Runtime;


#[derive(Serialize, Deserialize, IntoParams)]
#[serde(rename_all = "camelCase")]
pub struct PodcastSearchModelUtoipa {
Expand Down Expand Up @@ -628,7 +627,7 @@ use utoipa::{IntoParams, ToSchema};
use utoipa_axum::router::OpenApiRouter;
use utoipa_axum::routes;

use crate::utils::error::{map_reqwest_error, CustomError, CustomErrorInner, ErrorSeverity};
use crate::utils::error::{CustomError, CustomErrorInner, ErrorSeverity, map_reqwest_error};
use crate::utils::http_client::get_http_client;
use crate::utils::rss_feed_parser::PodcastParsed;

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::adapters::api::models::podcast_episode_dto::PodcastEpisodeDto;
use crate::constants::inner_constants::{PodcastType, MAIN_ROOM};
use crate::constants::inner_constants::{MAIN_ROOM, PodcastType};
use crate::models::favorite_podcast_episode::FavoritePodcastEpisode;
use crate::models::podcast_dto::PodcastDto;
use crate::models::podcast_episode::PodcastEpisode;
Expand Down
Loading