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
35 changes: 2 additions & 33 deletions Cargo.lock

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

7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "gurk"
description = "Signal messenger client for terminal"
version = "0.7.2"
version = "0.8.0-dev"
authors = ["boxdot <[email protected]>"]
edition = "2024"
keywords = ["signal", "tui"]
Expand All @@ -26,7 +26,7 @@ lto = "thin"
debug = true

[features]
dev = ["prost", "base64"]
dev = ["prost", "base64", "serde_json"]

[dependencies]
presage = { git = "https://github.com/whisperfish/presage", rev = "ed011688fc8d9c0ee07c3d44743c138c1fa4dfda" }
Expand Down Expand Up @@ -64,7 +64,7 @@ ratatui = "0.29.0"
regex = "1.11.1"
scopeguard = "1.2.0"
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.134"
serde_json = { version = "1.0.134", optional = true }
sqlx = { version = "0.8.2", features = [
"sqlite",
"runtime-tokio-rustls",
Expand Down Expand Up @@ -108,7 +108,6 @@ ignored = ["libsqlite3-sys"]
[dev-dependencies]
criterion = { version = "0.7", features = ["async_tokio", "html_reports"] }
hex-literal = "1.0.0"
insta = { version = "1.41.1", features = ["json"] }
quickcheck = "1.0.3"
quickcheck_macros = "1.0.0"

Expand Down
18 changes: 0 additions & 18 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ pub struct Config {
skip_serializing_if = "is_default_data_dir"
)]
pub data_dir: PathBuf,
/// Path to the JSON file (incl. filename) storing channels and messages.
#[serde(
default = "default_data_json_path",
rename = "data_path",
skip_serializing
)]
pub deprecated_data_path: PathBuf,
/// Path to the Signal database containing the linked device data.
#[serde(
rename = "signal_db_path",
Expand Down Expand Up @@ -123,7 +116,6 @@ impl Config {
Config {
user,
data_dir: default_data_dir(),
deprecated_data_path: default_data_json_path(),
deprecated_signal_db_path: default_signal_db_path(),
first_name_only: false,
show_receipts: true,
Expand Down Expand Up @@ -202,12 +194,6 @@ impl Config {
message: "sqlite is now enabled by default",
});
}
if config_value.get("data_path").is_some() {
keys.push(DeprecatedConfigKey {
key: "data_path",
message: "is not used anymore, and is migrated to sqlite.url",
});
}
if config_value.get("signal_db_path").is_some() {
keys.push(DeprecatedConfigKey {
key: "signal_db_path",
Expand Down Expand Up @@ -327,10 +313,6 @@ fn is_default_data_dir(path: &Path) -> bool {
path == default_data_dir()
}

fn default_data_json_path() -> PathBuf {
default_data_dir().join("gurk.data.json")
}

fn default_true() -> bool {
true
}
Expand Down
5 changes: 0 additions & 5 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,6 @@ impl Message {
})
}

/// Returns whether this message is an edit of an another message
pub(crate) fn is_edit(&self) -> bool {
self.edit.is_some()
}

pub fn is_empty(&self) -> bool {
self.message.is_none()
&& self.attachments.is_empty()
Expand Down
20 changes: 3 additions & 17 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ use crossterm::{
};
use gurk::{app::App, config::Config};
use gurk::{backoff::Backoff, passphrase::Passphrase};
use gurk::{config, signal, ui};
use gurk::{
onboarding,
storage::{JsonStorage, MemCache, SqliteStorage, Storage, sync_from_signal},
storage::{MemCache, SqliteStorage, Storage, sync_from_signal},
};
use gurk::{signal, ui};
use presage::libsignal_service::content::Content;
use ratatui::{Terminal, backend::CrosstermBackend};
use tokio::{runtime, select};
Expand Down Expand Up @@ -135,23 +135,9 @@ async fn run(config: Config, passphrase: Passphrase, relink: bool) -> anyhow::Re
};

debug!(%url, "opening sqlite data storage");
let mut sqlite_storage = SqliteStorage::maybe_encrypt_and_open(&url, &passphrase, false)
let sqlite_storage = SqliteStorage::maybe_encrypt_and_open(&url, &passphrase, false)
.await
.with_context(|| format!("failed to open sqlite data storage at: {url}"))?;
if sqlite_storage.is_empty() || !(sqlite_storage.metadata().fully_migrated.unwrap_or(false))
{
if let Ok(json_storage) = JsonStorage::new(
&config.deprecated_data_path,
config::fallback_data_path().as_deref(),
) {
println!("converting JSON storage to SQLite storage at {url}");
let stats = sqlite_storage.copy_from(&json_storage).await?;
let mut metadata = sqlite_storage.metadata().into_owned();
metadata.fully_migrated = Some(true);
sqlite_storage.store_metadata(metadata);
info!(?stats, "converted");
}
}
Box::new(MemCache::new(sqlite_storage))
};

Expand Down
13 changes: 0 additions & 13 deletions src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,4 @@ mod tests {
assert!(Receipt::Sent < Receipt::Delivered);
assert!(Receipt::Delivered < Receipt::Read);
}

#[test]
fn test_receipt_serde() -> anyhow::Result<()> {
assert_eq!(serde_json::to_string(&Receipt::Nothing)?, "\"Nothing\"");
assert_eq!(serde_json::to_string(&Receipt::Sent)?, "\"Sent\"");
assert_eq!(serde_json::to_string(&Receipt::Delivered)?, "\"Delivered\"");
assert_eq!(serde_json::to_string(&Receipt::Read)?, "\"Read\"");

let receipt: Receipt = serde_json::from_str("\"Unknown\"")?;
assert_eq!(receipt, Receipt::Nothing);

Ok(())
}
}
30 changes: 0 additions & 30 deletions src/storage/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,6 @@ use crate::signal::SignalManager;

use super::Storage;

#[derive(Debug, Default)]
pub struct Stats {
pub channels: usize,
pub messages: usize,
pub names: usize,
}

pub fn copy(from: &dyn Storage, to: &mut dyn Storage) -> Stats {
let mut stats = Stats::default();

to.store_metadata(from.metadata().into_owned());

for channel in from.channels() {
let channel_id = channel.id;
to.store_channel(channel.into_owned());
stats.channels += 1;
for message in from.messages(channel_id) {
to.store_message(channel_id, message.into_owned());
stats.messages += 1;
}
}

for (id, name) in from.names() {
to.store_name(id, name.into_owned());
stats.names += 1;
}

stats
}

/// Copies contacts and groups from the signal manager into the storages
///
/// If contact/group is not in the storage, a new one is created. Group channels are updated,
Expand Down
Loading