Skip to content

Commit 79a3dff

Browse files
JSKittyclaude
andcommitted
chore: clean up dead code and unused imports from extraction
Remove unused imports: crypto, db, net, NoOpSendCallback from message/sending.rs. Remove stale re-exports: extension_from_mime, is_image_mime, hex_to_bytes_16, EncryptionParams, generate_encryption_params, encrypt_data. Remove dead re-exports from message/mod.rs (Message, Attachment, 9 compact types). Delete check_url_live (dedup remnant) and EMPTY_FILE_HASH constant. Warnings reduced from 18 to 5 (remaining: 2 MLS vars, 2 whisper feature-gated, 1 Android-gated). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5e87526 commit 79a3dff

7 files changed

Lines changed: 8 additions & 57 deletions

File tree

src-tauri/src/crypto.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ use chacha20poly1305::{
1717
use zeroize::Zeroize;
1818

1919
// Re-export shared crypto from vector-core
20-
pub use vector_core::crypto::{
21-
EncryptionParams, generate_encryption_params, encrypt_data, decrypt_data,
22-
};
20+
pub use vector_core::crypto::decrypt_data;
2321

2422
/// Hash a password using Argon2id (with zeroization of the owned password).
2523
pub async fn hash_pass(mut password: String) -> [u8; 32] {

src-tauri/src/message/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,9 @@ mod files;
2121
pub use sending::*;
2222
pub use files::*;
2323
pub use types::{
24-
Message, ImageMetadata, Attachment,
25-
AttachmentFile, Reaction, EditEntry,
26-
};
27-
pub use vector_core::compact::{
28-
CompactMessage, CompactMessageVec, CompactReaction, CompactAttachment,
29-
AttachmentFlags, MessageFlags, NpubInterner, NO_NPUB,
30-
encode_message_id, decode_message_id,
24+
ImageMetadata, AttachmentFile, Reaction, EditEntry,
3125
};
26+
pub use vector_core::compact::CompactAttachment;
3227

3328
/// Protocol-agnostic reaction function that works for both DMs and Group Chats
3429
#[tauri::command]

src-tauri/src/message/sending.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,9 @@ use ::image::{ImageBuffer, Rgba};
2222
#[cfg(not(target_os = "android"))]
2323
use tauri_plugin_clipboard_manager::ClipboardExt;
2424

25-
use crate::crypto;
26-
use crate::db;
2725
use crate::mls::MlsService;
2826
use crate::util::{bytes_to_hex_string, hex_string_to_bytes};
2927
use crate::util::calculate_file_hash;
30-
use crate::net;
3128
use crate::STATE;
3229
use crate::util;
3330
use crate::TAURI_APP;
@@ -36,7 +33,7 @@ use crate::miniapps::realtime::{generate_topic_id, encode_topic_id};
3633

3734
use super::types::{AttachmentFile, ImageMetadata, Message, Attachment};
3835

39-
use vector_core::sending::{SendCallback, SendConfig, NoOpSendCallback};
36+
use vector_core::sending::{SendCallback, SendConfig};
4037

4138
/// Result of sending a message, returned to frontend for state update
4239
#[derive(serde::Serialize)]
@@ -528,9 +525,6 @@ pub async fn message(receiver: String, content: String, replied_to: String, file
528525
// Calculate the file hash first (before encryption)
529526
let file_hash = calculate_file_hash(&*attached_file.bytes);
530527

531-
// The SHA-256 hash of an empty file - we should never reuse this
532-
const EMPTY_FILE_HASH: &str = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
533-
534528
// ============================================================
535529
// MLS GROUP ATTACHMENTS: Use MIP-04 encryption with imeta tags
536530
// ============================================================

src-tauri/src/mls/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use mdk_core::prelude::*;
1010
use mdk_sqlite_storage::MdkSqliteStorage;
1111
use tauri::{AppHandle, Runtime, Emitter};
1212
use crate::{TAURI_APP, NOSTR_CLIENT, TRUSTED_RELAYS, active_trusted_relays, STATE, Message};
13-
use crate::rumor::{RumorEvent, RumorContext, ConversationType, process_rumor, RumorProcessingResult};
13+
use crate::rumor::{RumorEvent, RumorContext, ConversationType, RumorProcessingResult};
1414
use crate::db::save_chat_messages;
1515
use crate::db::chats::{SlimChatDB, save_slim_chat};
1616
use crate::util::{bytes_to_hex_string, hex_string_to_bytes};

src-tauri/src/net.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -539,38 +539,3 @@ fn normalize_url(url: &str, domain: &str) -> String {
539539
}
540540
}
541541

542-
/// Check if a URL is live and accessible
543-
/// Returns true if the URL responds with a success status (2xx)
544-
pub async fn check_url_live(url: &str) -> Result<bool, &'static str> {
545-
validate_url_not_private(url)?;
546-
// Create a client with a reasonable timeout for checking
547-
let client = Client::builder()
548-
.timeout(std::time::Duration::from_secs(10))
549-
.build()
550-
.map_err(|_| "Failed to create HTTP client")?;
551-
552-
// Try a HEAD request first (more efficient)
553-
match client.head(url).send().await {
554-
Ok(response) => {
555-
// Check if status is 2xx (success)
556-
Ok(response.status().is_success())
557-
}
558-
Err(_) => {
559-
// If HEAD fails, try a GET request with minimal range
560-
// Some servers don't support HEAD requests
561-
match client
562-
.get(url)
563-
.header("Range", "bytes=0-1")
564-
.send()
565-
.await
566-
{
567-
Ok(response) => {
568-
// Accept both 200 (full content) and 206 (partial content)
569-
let status = response.status();
570-
Ok(status.is_success() || status.as_u16() == 206)
571-
}
572-
Err(_) => Ok(false), // URL is not accessible
573-
}
574-
}
575-
}
576-
}

src-tauri/src/profile.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::message::AttachmentFile;
1414
#[cfg(target_os = "android")]
1515
use crate::android::filesystem;
1616

17-
pub use vector_core::profile::{Profile, ProfileFlags};
17+
// Profile/ProfileFlags re-exported at crate root from vector_core (lib.rs line 49)
1818

1919
/// Cache profile images (avatar and banner) in the background
2020
///

src-tauri/src/util.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use fast_thumbhash::{rgba_to_thumb_hash, thumb_hash_to_rgba, base91_encode, base
44

55
// Re-export from vector-core (supersedes local MIME HashMaps)
66
pub use vector_core::crypto::{
7-
extension_from_mime, mime_from_extension_safe, is_image_mime,
8-
mime_from_magic_bytes, format_bytes,
7+
mime_from_extension_safe, mime_from_magic_bytes, format_bytes,
98
};
109

1110
/// Convert a file extension to a MIME type. Returns owned String for backward compatibility.
@@ -30,7 +29,7 @@ pub fn data_uri(mime: &str, bytes: &[u8]) -> String {
3029

3130
pub use vector_core::hex::{
3231
bytes_to_hex_16, bytes_to_hex_32, bytes_to_hex_string,
33-
hex_string_to_bytes, hex_to_bytes_16, hex_to_bytes_32,
32+
hex_string_to_bytes, hex_to_bytes_32,
3433
};
3534

3635
pub use crate::simd::{

0 commit comments

Comments
 (0)