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
|
||||
run: |
|
||||
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
|
||||
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"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["push-notifications"]
|
||||
push-notifications = ["web-push", "openssl"]
|
||||
|
||||
[dependencies]
|
||||
axum = { version = "0.8", features = ["macros", "ws"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
@@ -26,6 +30,6 @@ thiserror = "2.0.18"
|
||||
dotenvy = "0.15.7"
|
||||
utoipa = { version = "5.4.0", features = ["axum_extras"] }
|
||||
utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] }
|
||||
web-push = "0.10"
|
||||
web-push = { version = "0.10", optional = true }
|
||||
base64 = "0.22"
|
||||
openssl = { version = "0.10", features = ["vendored"] }
|
||||
openssl = { version = "0.10", features = ["vendored"], optional = true }
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use crate::{
|
||||
push,
|
||||
xmlrpc::{self, RpcParam},
|
||||
AppState,
|
||||
};
|
||||
#[cfg(feature = "push-notifications")]
|
||||
use crate::push;
|
||||
use axum::{
|
||||
extract::{Json, Path, State},
|
||||
http::{header, StatusCode, Uri},
|
||||
@@ -677,6 +678,7 @@ pub async fn handle_timeout_error(err: BoxError) -> (StatusCode, &'static str) {
|
||||
|
||||
// --- PUSH NOTIFICATION HANDLERS ---
|
||||
|
||||
#[cfg(feature = "push-notifications")]
|
||||
/// Get VAPID public key for push subscription
|
||||
#[utoipa::path(
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
#[cfg(feature = "push-notifications")]
|
||||
/// Subscribe to push notifications
|
||||
#[utoipa::path(
|
||||
post,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
mod diff;
|
||||
mod handlers;
|
||||
#[cfg(feature = "push-notifications")]
|
||||
mod push;
|
||||
mod scgi;
|
||||
mod sse;
|
||||
@@ -31,6 +32,7 @@ pub struct AppState {
|
||||
pub tx: Arc<watch::Sender<Vec<Torrent>>>,
|
||||
pub event_bus: broadcast::Sender<AppEvent>,
|
||||
pub scgi_socket_path: String,
|
||||
#[cfg(feature = "push-notifications")]
|
||||
pub push_store: push::PushSubscriptionStore,
|
||||
}
|
||||
|
||||
@@ -51,6 +53,7 @@ struct Args {
|
||||
port: u16,
|
||||
}
|
||||
|
||||
#[cfg(feature = "push-notifications")]
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(
|
||||
paths(
|
||||
@@ -89,6 +92,41 @@ struct Args {
|
||||
)]
|
||||
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]
|
||||
async fn main() {
|
||||
// Load .env file
|
||||
@@ -143,6 +181,7 @@ async fn main() {
|
||||
tx: tx.clone(),
|
||||
event_bus: event_bus.clone(),
|
||||
scgi_socket_path: args.socket.clone(),
|
||||
#[cfg(feature = "push-notifications")]
|
||||
push_store: push::PushSubscriptionStore::new(),
|
||||
};
|
||||
|
||||
@@ -150,6 +189,7 @@ async fn main() {
|
||||
let tx_clone = tx.clone();
|
||||
let event_bus_tx = event_bus.clone();
|
||||
let socket_path = args.socket.clone(); // Clone for background task
|
||||
#[cfg(feature = "push-notifications")]
|
||||
let push_store_clone = app_state.push_store.clone();
|
||||
|
||||
tokio::spawn(async move {
|
||||
@@ -202,6 +242,7 @@ async fn main() {
|
||||
diff::DiffResult::Partial(updates) => {
|
||||
for update in updates {
|
||||
// Check if this is a torrent completion notification
|
||||
#[cfg(feature = "push-notifications")]
|
||||
if let AppEvent::Notification(ref notif) = update {
|
||||
if notif.message.contains("tamamlandı") {
|
||||
// Send push notification in background
|
||||
@@ -295,9 +336,14 @@ async fn main() {
|
||||
"/api/settings/global-limits",
|
||||
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/subscribe", post(handlers::subscribe_push_handler))
|
||||
.fallback(handlers::static_handler) // Serve static files for everything else
|
||||
.route("/api/push/subscribe", post(handlers::subscribe_push_handler));
|
||||
|
||||
let app = app
|
||||
.layer(TraceLayer::new_for_http())
|
||||
.layer(
|
||||
CompressionLayer::new()
|
||||
|
||||
Reference in New Issue
Block a user