Skip to content
Closed
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
79 changes: 65 additions & 14 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ buzz-media = { path = "crates/buzz-media" }
buzz-sdk = { path = "crates/buzz-sdk" }
buzz-ws-client = { path = "crates/buzz-ws-client" }
buzz-relay-mesh = { path = "crates/buzz-relay-mesh" }
# Sonar sticker pack wire model and validators. Keep this exact revision in
# sync with the standalone desktop Tauri workspace.
sonar-stickers = { git = "https://github.com/hedwig-corp/bitchat-to-sonar", rev = "eea8ada304517d6a3ea6c81d6ffa57ce00504bcd", package = "sonar-stickers" }

# CI profile — builds the relay for desktop e2e. Dependencies keep full
# release optimization (warm from main's cache; they carry the runtime hot
Expand Down
3 changes: 3 additions & 0 deletions crates/buzz-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ chrono = { workspace = true }
# Typed event builders for all write operations
buzz-sdk = { workspace = true }
buzz-core = { workspace = true }
sonar-stickers = { workspace = true, features = ["signal-import"] }

# Base64 encoding — NIP-98 event serialization for Authorization header
base64 = "0.22"
Expand All @@ -59,6 +60,8 @@ hex = { workspace = true }

# MIME type detection via magic bytes — file upload validation
infer = "0.19"
imagesize = "0.14"
zeroize = "1"

# URL parsing — extract server domain for Blossom auth tag
url = { workspace = true }
Expand Down
19 changes: 18 additions & 1 deletion crates/buzz-cli/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub fn build_imeta_tag(d: &BlobDescriptor) -> Vec<String> {
const ALLOWED_MIMES: &[&str] = &[
"image/jpeg",
"image/png",
"image/apng",
"image/gif",
"image/webp",
"video/mp4",
Expand Down Expand Up @@ -325,6 +326,22 @@ impl BuzzClient {
return Err(CliError::Usage(format!("unsupported file type: {mime}")));
}

self.upload_bytes(bytes, &mime).await
}

/// Upload already-buffered media bytes to the relay's Blossom endpoint.
///
/// Callers that accept a narrower media set (for example Sonar stickers)
/// must validate that policy before calling this shared transport helper.
pub async fn upload_bytes(
&self,
bytes: Vec<u8>,
mime: &str,
) -> Result<BlobDescriptor, CliError> {
if !ALLOWED_MIMES.contains(&mime) {
return Err(CliError::Usage(format!("unsupported file type: {mime}")));
}

// 3. Size check
let max = if mime.starts_with("video/") {
MAX_VIDEO_BYTES
Expand Down Expand Up @@ -394,7 +411,7 @@ impl BuzzClient {
.put(&url)
.timeout(upload_timeout)
.header("Authorization", &auth_header)
.header("Content-Type", &mime)
.header("Content-Type", mime)
.header("X-SHA-256", &sha256);

let resp = self.with_auth_tag(req).body(bytes).send().await?;
Expand Down
1 change: 1 addition & 0 deletions crates/buzz-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod pr;
pub mod reactions;
pub mod repos;
pub mod social;
pub mod stickers;
pub mod upload;
pub mod users;
pub mod workflows;
Loading