fix: Make push notifications optional for MIPS compatibility
- Add push-notifications feature flag (enabled by default) - Make web-push and openssl optional dependencies - Conditionally compile push notification code - Disable push notifications for MIPS builds in CI - Fixes AtomicU64 error on 32-bit MIPS architecture - x86_64/ARM builds still have full push notification support
This commit is contained in:
2
.github/workflows/build-mips.yml
vendored
2
.github/workflows/build-mips.yml
vendored
@@ -55,7 +55,7 @@ jobs:
|
|||||||
CROSS_NO_WARNINGS: 0
|
CROSS_NO_WARNINGS: 0
|
||||||
run: |
|
run: |
|
||||||
cd backend
|
cd backend
|
||||||
cross build --target mips-unknown-linux-musl --release -Z build-std=std,panic_abort
|
cross build --target mips-unknown-linux-musl --release --no-default-features -Z build-std=std,panic_abort
|
||||||
|
|
||||||
- name: Debug - List Files
|
- name: Debug - List Files
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"chat.tools.terminal.autoApprove": {
|
||||||
|
"cargo check": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,10 @@ name = "backend"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["push-notifications"]
|
||||||
|
push-notifications = ["web-push", "openssl"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = { version = "0.8", features = ["macros", "ws"] }
|
axum = { version = "0.8", features = ["macros", "ws"] }
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
@@ -26,6 +30,6 @@ thiserror = "2.0.18"
|
|||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
||||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||||
web-push = "0.10"
|
web-push = { version = "0.10", optional = true }
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
openssl = { version = "0.10", features = ["vendored"] }
|
openssl = { version = "0.10", features = ["vendored"], optional = true }
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
push,
|
|
||||||
xmlrpc::{self, RpcParam},
|
xmlrpc::{self, RpcParam},
|
||||||
AppState,
|
AppState,
|
||||||
};
|
};
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
|
use crate::push;
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{Json, Path, State},
|
extract::{Json, Path, State},
|
||||||
http::{header, StatusCode, Uri},
|
http::{header, StatusCode, Uri},
|
||||||
@@ -677,6 +678,7 @@ pub async fn handle_timeout_error(err: BoxError) -> (StatusCode, &'static str) {
|
|||||||
|
|
||||||
// --- PUSH NOTIFICATION HANDLERS ---
|
// --- PUSH NOTIFICATION HANDLERS ---
|
||||||
|
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
/// Get VAPID public key for push subscription
|
/// Get VAPID public key for push subscription
|
||||||
#[utoipa::path(
|
#[utoipa::path(
|
||||||
get,
|
get,
|
||||||
@@ -690,6 +692,8 @@ pub async fn get_push_public_key_handler() -> impl IntoResponse {
|
|||||||
(StatusCode::OK, Json(serde_json::json!({ "publicKey": public_key }))).into_response()
|
(StatusCode::OK, Json(serde_json::json!({ "publicKey": public_key }))).into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
/// Subscribe to push notifications
|
/// Subscribe to push notifications
|
||||||
#[utoipa::path(
|
#[utoipa::path(
|
||||||
post,
|
post,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
mod diff;
|
mod diff;
|
||||||
mod handlers;
|
mod handlers;
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
mod push;
|
mod push;
|
||||||
mod scgi;
|
mod scgi;
|
||||||
mod sse;
|
mod sse;
|
||||||
@@ -31,6 +32,7 @@ pub struct AppState {
|
|||||||
pub tx: Arc<watch::Sender<Vec<Torrent>>>,
|
pub tx: Arc<watch::Sender<Vec<Torrent>>>,
|
||||||
pub event_bus: broadcast::Sender<AppEvent>,
|
pub event_bus: broadcast::Sender<AppEvent>,
|
||||||
pub scgi_socket_path: String,
|
pub scgi_socket_path: String,
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
pub push_store: push::PushSubscriptionStore,
|
pub push_store: push::PushSubscriptionStore,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +53,7 @@ struct Args {
|
|||||||
port: u16,
|
port: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
#[derive(OpenApi)]
|
#[derive(OpenApi)]
|
||||||
#[openapi(
|
#[openapi(
|
||||||
paths(
|
paths(
|
||||||
@@ -89,6 +92,41 @@ struct Args {
|
|||||||
)]
|
)]
|
||||||
struct ApiDoc;
|
struct ApiDoc;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "push-notifications"))]
|
||||||
|
#[derive(OpenApi)]
|
||||||
|
#[openapi(
|
||||||
|
paths(
|
||||||
|
handlers::add_torrent_handler,
|
||||||
|
handlers::handle_torrent_action,
|
||||||
|
handlers::get_version_handler,
|
||||||
|
handlers::get_files_handler,
|
||||||
|
handlers::get_peers_handler,
|
||||||
|
handlers::get_trackers_handler,
|
||||||
|
handlers::set_file_priority_handler,
|
||||||
|
handlers::set_label_handler,
|
||||||
|
handlers::get_global_limit_handler,
|
||||||
|
handlers::set_global_limit_handler
|
||||||
|
),
|
||||||
|
components(
|
||||||
|
schemas(
|
||||||
|
handlers::AddTorrentRequest,
|
||||||
|
shared::TorrentActionRequest,
|
||||||
|
shared::Torrent,
|
||||||
|
shared::TorrentStatus,
|
||||||
|
shared::TorrentFile,
|
||||||
|
shared::TorrentPeer,
|
||||||
|
shared::TorrentTracker,
|
||||||
|
shared::SetFilePriorityRequest,
|
||||||
|
shared::SetLabelRequest,
|
||||||
|
shared::GlobalLimitRequest
|
||||||
|
)
|
||||||
|
),
|
||||||
|
tags(
|
||||||
|
(name = "vibetorrent", description = "VibeTorrent API")
|
||||||
|
)
|
||||||
|
)]
|
||||||
|
struct ApiDoc;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// Load .env file
|
// Load .env file
|
||||||
@@ -143,6 +181,7 @@ async fn main() {
|
|||||||
tx: tx.clone(),
|
tx: tx.clone(),
|
||||||
event_bus: event_bus.clone(),
|
event_bus: event_bus.clone(),
|
||||||
scgi_socket_path: args.socket.clone(),
|
scgi_socket_path: args.socket.clone(),
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
push_store: push::PushSubscriptionStore::new(),
|
push_store: push::PushSubscriptionStore::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -150,6 +189,7 @@ async fn main() {
|
|||||||
let tx_clone = tx.clone();
|
let tx_clone = tx.clone();
|
||||||
let event_bus_tx = event_bus.clone();
|
let event_bus_tx = event_bus.clone();
|
||||||
let socket_path = args.socket.clone(); // Clone for background task
|
let socket_path = args.socket.clone(); // Clone for background task
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
let push_store_clone = app_state.push_store.clone();
|
let push_store_clone = app_state.push_store.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
@@ -202,6 +242,7 @@ async fn main() {
|
|||||||
diff::DiffResult::Partial(updates) => {
|
diff::DiffResult::Partial(updates) => {
|
||||||
for update in updates {
|
for update in updates {
|
||||||
// Check if this is a torrent completion notification
|
// Check if this is a torrent completion notification
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
if let AppEvent::Notification(ref notif) = update {
|
if let AppEvent::Notification(ref notif) = update {
|
||||||
if notif.message.contains("tamamlandı") {
|
if notif.message.contains("tamamlandı") {
|
||||||
// Send push notification in background
|
// Send push notification in background
|
||||||
@@ -295,9 +336,14 @@ async fn main() {
|
|||||||
"/api/settings/global-limits",
|
"/api/settings/global-limits",
|
||||||
get(handlers::get_global_limit_handler).post(handlers::set_global_limit_handler),
|
get(handlers::get_global_limit_handler).post(handlers::set_global_limit_handler),
|
||||||
)
|
)
|
||||||
|
.fallback(handlers::static_handler); // Serve static files for everything else
|
||||||
|
|
||||||
|
#[cfg(feature = "push-notifications")]
|
||||||
|
let app = app
|
||||||
.route("/api/push/public-key", get(handlers::get_push_public_key_handler))
|
.route("/api/push/public-key", get(handlers::get_push_public_key_handler))
|
||||||
.route("/api/push/subscribe", post(handlers::subscribe_push_handler))
|
.route("/api/push/subscribe", post(handlers::subscribe_push_handler));
|
||||||
.fallback(handlers::static_handler) // Serve static files for everything else
|
|
||||||
|
let app = app
|
||||||
.layer(TraceLayer::new_for_http())
|
.layer(TraceLayer::new_for_http())
|
||||||
.layer(
|
.layer(
|
||||||
CompressionLayer::new()
|
CompressionLayer::new()
|
||||||
|
|||||||
Reference in New Issue
Block a user