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
8 changes: 4 additions & 4 deletions src-tauri/Cargo.lock

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

8 changes: 4 additions & 4 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ tauri-build = { version = "2.5.3", features = [] }
[dependencies]
nostr-sdk = { version = "0.44.1", features = ["nip06", "nip44", "nip59"] }
nostr-blossom = "0.44.0"
mdk-core = { git = "https://github.com/parres-hq/mdk", rev = "7c3157c", features = ["mip04"] }
mdk-sqlite-storage = { git = "https://github.com/parres-hq/mdk", rev = "7c3157c" }
mdk-storage-traits = { git = "https://github.com/parres-hq/mdk", rev = "7c3157c" }
mdk-core = { git = "https://github.com/parres-hq/mdk", rev = "1ad73229ab712018c078d5295e11ec38e10d6a24", features = ["mip04"] }
mdk-sqlite-storage = { git = "https://github.com/parres-hq/mdk", rev = "1ad73229ab712018c078d5295e11ec38e10d6a24" }
mdk-storage-traits = { git = "https://github.com/parres-hq/mdk", rev = "1ad73229ab712018c078d5295e11ec38e10d6a24" }
bip39 = { version = "2.2.2", features = ["rand"] }
tokio = { version = "1.49.0", features = ["sync", "time"] }
futures-util = "0.3.31"
Expand All @@ -37,7 +37,6 @@ reqwest = { version = "0.12", features = ["rustls-tls", "json", "stream", "block
scraper = "0.24.0"
aes = "0.8.4"
aes-gcm = "0.10.3"
hex = "0.4.3"
sha2 = "0.10.9"
once_cell = "1.21.3"
lazy_static = "1.5.0"
Expand All @@ -58,6 +57,7 @@ hound = "3.5.1"
rubato = "0.16.2"
symphonia = { version = "0.5.5", features = ["mp3", "wav", "flac", "pcm"] }
rusqlite = { version = "0.32", features = ["bundled"] }
rayon = "1.11.0"

# Mini Apps (WebXDC) support
zip = "2.4"
Expand Down
1 change: 0 additions & 1 deletion src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ fn main() {
"get_messages_around_id",
"get_system_events",
"get_chat_message_count",
"get_file_hash_index",
"evict_chat_messages",
"generate_blurhash_preview",
"decode_blurhash",
Expand Down
1 change: 0 additions & 1 deletion src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"allow-get-messages-around-id",
"allow-get-system-events",
"allow-get-chat-message-count",
"allow-get-file-hash-index",
"allow-evict-chat-messages",
"allow-generate-blurhash-preview",
"allow-decode-blurhash",
Expand Down
11 changes: 0 additions & 11 deletions src-tauri/permissions/autogenerated/get_file_hash_index.toml

This file was deleted.

21 changes: 19 additions & 2 deletions src-tauri/src/account_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ CREATE TABLE IF NOT EXISTS events (
failed INTEGER NOT NULL DEFAULT 0,
wrapper_event_id TEXT,
npub TEXT,
preview_metadata TEXT,
FOREIGN KEY (chat_id) REFERENCES chats(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES profiles(id) ON DELETE SET NULL
);
Expand Down Expand Up @@ -909,10 +910,26 @@ fn run_migrations(conn: &mut rusqlite::Connection) -> Result<(), String> {
Ok(())
})?;

// Migration 13: Add preview_metadata column to events table for link preview caching
run_atomic_migration(conn, 13, "Add preview_metadata to events table", |tx| {
// Check if column already exists (may have been added by a prior dev build)
let col_exists: bool = tx.query_row(
"SELECT COUNT(*) FROM pragma_table_info('events') WHERE name='preview_metadata'",
[], |row| row.get::<_, i32>(0)
).map(|c| c > 0).unwrap_or(false);
if !col_exists {
tx.execute(
"ALTER TABLE events ADD COLUMN preview_metadata TEXT",
[]
).map_err(|e| format!("Failed to add preview_metadata column: {}", e))?;
}
Ok(())
})?;

// =========================================================================
// Future migrations (13+) follow the same pattern:
// Future migrations (14+) follow the same pattern:
//
// run_atomic_migration(conn, 13, "Description here", |tx| {
// run_atomic_migration(conn, 14, "Description here", |tx| {
// tx.execute("...", [])?;
// Ok(())
// })?;
Expand Down
3 changes: 2 additions & 1 deletion src-tauri/src/android/filesystem.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::sync::Arc;
use jni::objects::{JObject, JValue, JString};

use crate::message::{AttachmentFile, FileInfo};
Expand Down Expand Up @@ -418,7 +419,7 @@ fn read_from_android_uri_internal(
let _ = env.call_method(&input_stream, "close", "()V", &[]);

Ok(AttachmentFile {
bytes,
bytes: Arc::new(bytes),
img_meta: None,
extension,
})
Expand Down
26 changes: 9 additions & 17 deletions src-tauri/src/android/miniapp_jni.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use jni::JNIEnv;
use log::{debug, error, info, warn};
use std::io::Read;
use std::path::Path;
use crate::util::bytes_to_hex_string;
use crate::TAURI_APP;

// ============================================================================
// Constants
Expand Down Expand Up @@ -482,35 +484,25 @@ fn get_user_display_name() -> String {
}

fn get_granted_permissions_for_package(package_path: &str) -> Result<String, String> {
// Compute file hash for permission lookup
let path = Path::new(package_path);
if !path.exists() {
return Err("Package file not found".to_string());
}

let bytes = std::fs::read(path).map_err(|e| format!("Failed to read package: {}", e))?;
// Compute file hash for permission lookup - fs::read fails with NotFound if missing
let bytes = std::fs::read(package_path).map_err(|e| format!("Failed to read package: {}", e))?;

use sha2::{Sha256, Digest};
let mut hasher = Sha256::new();
hasher.update(&bytes);
let _file_hash = hex::encode(hasher.finalize());
let file_hash = bytes_to_hex_string(hasher.finalize().as_slice());

// TODO: Look up permissions from database using _file_hash
// For now, return empty (no permissions granted)
Ok(String::new())
// Look up permissions from database using file_hash
let handle = TAURI_APP.get().ok_or("Tauri app not initialized")?;
crate::db::get_miniapp_granted_permissions(handle, &file_hash)
}

fn serve_file_from_package(
env: &mut JNIEnv,
package_path: &str,
path: &str,
) -> Result<jobject, String> {
let package_file = Path::new(package_path);
if !package_file.exists() {
return Err("Package file not found".to_string());
}

let file = std::fs::File::open(package_file).map_err(|e| format!("Failed to open package: {}", e))?;
let file = std::fs::File::open(package_path).map_err(|e| format!("Failed to open package: {}", e))?;
let mut archive =
zip::ZipArchive::new(file).map_err(|e| format!("Failed to read ZIP: {}", e))?;

Expand Down
Loading