diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 3acd178..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,7 +0,0 @@ -[target.x86_64-unknown-linux-gnu] -linker = "clang" -rustflags = ["-C", "link-arg=--ld-path=wild"] - -[target.x86_64-unknown-linux-musl] -linker = "clang" -rustflags = ["-C", "link-arg=--ld-path=wild"] diff --git a/.gitignore b/.gitignore index fedaa2b..2b3b29d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target .env +.cargo/config.toml diff --git a/CLAUDE.md b/CLAUDE.md index 96c6a0d..f7fba5e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -14,7 +14,6 @@ This file provides context for AI assistants working on this codebase. ``` ndl/ ├── Cargo.toml # Workspace manifest (shared version here) -├── .cargo/config.toml # Linker config (wild on Linux) ├── ndl/ # TUI client │ ├── Cargo.toml │ ├── build.rs # Embeds git version at compile time @@ -51,7 +50,6 @@ ndl/ - **Async Runtime**: tokio - **Serialization**: serde + serde_json for config and API - **Bluesky**: bsky-sdk + atrium-api (AT Protocol) -- **Linker**: wild (Linux) - configured in `.cargo/config.toml` ## Versioning diff --git a/ndl-core/src/oauth.rs b/ndl-core/src/oauth.rs index a6f55f9..8966ee7 100644 --- a/ndl-core/src/oauth.rs +++ b/ndl-core/src/oauth.rs @@ -1,14 +1,33 @@ -use serde::Deserialize; +use serde::{Deserialize, Deserializer, de}; use thiserror::Error; pub const TOKEN_URL: &str = "https://graph.threads.net/oauth/access_token"; pub const OAUTH_SCOPES: &str = "threads_basic,threads_read_replies,threads_manage_replies,threads_content_publish"; +/// Deserialize user_id from either a string or number (Threads API returns both) +fn deserialize_user_id<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + #[derive(Deserialize)] + #[serde(untagged)] + enum StringOrNumber { + String(String), + Number(u64), + } + + match StringOrNumber::deserialize(deserializer)? { + StringOrNumber::String(s) => s.parse().map_err(de::Error::custom), + StringOrNumber::Number(n) => Ok(n), + } +} + #[derive(Debug, Deserialize)] pub struct TokenResponse { pub access_token: String, #[allow(dead_code)] + #[serde(deserialize_with = "deserialize_user_id")] pub user_id: u64, /// Number of seconds until the token expires (3600 for short-lived, 5184000 for long-lived) #[serde(default)] diff --git a/ndld/Dockerfile b/ndld/Dockerfile index 3c58c7e..3962c19 100644 --- a/ndld/Dockerfile +++ b/ndld/Dockerfile @@ -7,11 +7,9 @@ RUN apt-get update && apt-get install -y \ musl-tools \ clang \ && rm -rf /var/lib/apt/lists/* \ - && rustup target add x86_64-unknown-linux-musl \ - && cargo install wild-linker + && rustup target add x86_64-unknown-linux-musl # Copy workspace files -COPY .cargo .cargo COPY Cargo.toml Cargo.lock ./ COPY ndl ndl COPY ndld ndld @@ -27,6 +25,7 @@ COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/ndld /ndld ENV NDLD_PORT=8080 EXPOSE 8080 +EXPOSE 443 # Run as non-root (UID 10001) USER 10001:10001