Compare commits

..

3 Commits

Author SHA1 Message Date
link2xt
acd7a1d17e chore(release): prepare for 1.148.2 2024-10-23 17:52:24 +00:00
link2xt
db6d451c90 feat: add more logging for iroh initialization and peer addition 2024-10-23 17:48:33 +00:00
link2xt
4b3a6445fb fix: never initialize Iroh if realtime is disabled 2024-10-23 17:48:33 +00:00
15 changed files with 51 additions and 53 deletions

View File

@@ -1,5 +1,20 @@
# Changelog
## [1.148.2] - 2024-10-23
### Fixes
- Never initialize Iroh if realtime is disabled.
### Features / Changes
- Add more logging for iroh initialization and peer addition.
### Build system
- `nix flake update nixpkgs`.
- `nix flake update fenix`.
## [1.148.1] - 2024-10-23
### Build system
@@ -5084,3 +5099,4 @@ https://github.com/deltachat/deltachat-core-rust/pulls?q=is%3Apr+is%3Aclosed
[1.147.1]: https://github.com/deltachat/deltachat-core-rust/compare/v1.147.0..v1.147.1
[1.148.0]: https://github.com/deltachat/deltachat-core-rust/compare/v1.147.1..v1.148.0
[1.148.1]: https://github.com/deltachat/deltachat-core-rust/compare/v1.148.0..v1.148.1
[1.148.2]: https://github.com/deltachat/deltachat-core-rust/compare/v1.148.1..v1.148.2

10
Cargo.lock generated
View File

@@ -1293,7 +1293,7 @@ dependencies = [
[[package]]
name = "deltachat"
version = "1.148.1"
version = "1.148.2"
dependencies = [
"anyhow",
"async-broadcast",
@@ -1393,7 +1393,7 @@ dependencies = [
[[package]]
name = "deltachat-jsonrpc"
version = "1.148.1"
version = "1.148.2"
dependencies = [
"anyhow",
"async-channel 2.3.1",
@@ -1418,7 +1418,7 @@ dependencies = [
[[package]]
name = "deltachat-repl"
version = "1.148.1"
version = "1.148.2"
dependencies = [
"anyhow",
"deltachat",
@@ -1434,7 +1434,7 @@ dependencies = [
[[package]]
name = "deltachat-rpc-server"
version = "1.148.1"
version = "1.148.2"
dependencies = [
"anyhow",
"deltachat",
@@ -1463,7 +1463,7 @@ dependencies = [
[[package]]
name = "deltachat_ffi"
version = "1.148.1"
version = "1.148.2"
dependencies = [
"anyhow",
"deltachat",

View File

@@ -1,6 +1,6 @@
[package]
name = "deltachat"
version = "1.148.1"
version = "1.148.2"
edition = "2021"
license = "MPL-2.0"
rust-version = "1.77"

View File

@@ -1,6 +1,6 @@
[package]
name = "deltachat_ffi"
version = "1.148.1"
version = "1.148.2"
description = "Deltachat FFI"
edition = "2018"
readme = "README.md"

View File

@@ -1,6 +1,6 @@
[package]
name = "deltachat-jsonrpc"
version = "1.148.1"
version = "1.148.2"
description = "DeltaChat JSON-RPC API"
edition = "2021"
default-run = "deltachat-jsonrpc-server"

View File

@@ -58,5 +58,5 @@
},
"type": "module",
"types": "dist/deltachat.d.ts",
"version": "1.148.1"
"version": "1.148.2"
}

View File

@@ -1,6 +1,6 @@
[package]
name = "deltachat-repl"
version = "1.148.1"
version = "1.148.2"
license = "MPL-2.0"
edition = "2021"
repository = "https://github.com/deltachat/deltachat-core-rust"

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "deltachat-rpc-client"
version = "1.148.1"
version = "1.148.2"
description = "Python client for Delta Chat core JSON-RPC interface"
classifiers = [
"Development Status :: 5 - Production/Stable",

View File

@@ -1,6 +1,6 @@
[package]
name = "deltachat-rpc-server"
version = "1.148.1"
version = "1.148.2"
description = "DeltaChat JSON-RPC server"
edition = "2021"
readme = "README.md"

View File

@@ -15,5 +15,5 @@
},
"type": "module",
"types": "index.d.ts",
"version": "1.148.1"
"version": "1.148.2"
}

View File

@@ -55,5 +55,5 @@
"test:mocha": "mocha node/test/test.mjs --growl --reporter=spec --bail --exit"
},
"types": "node/dist/index.d.ts",
"version": "1.148.1"
"version": "1.148.2"
}

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "deltachat"
version = "1.148.1"
version = "1.148.2"
description = "Python bindings for the Delta Chat Core library using CFFI against the Rust-implemented libdeltachat"
readme = "README.rst"
requires-python = ">=3.7"

View File

@@ -23,7 +23,7 @@
//! (scoped per WebXDC app instance/message-id). The other peers can then join the gossip with `joinRealtimeChannel().setListener()`
//! and `joinRealtimeChannel().send()` just like the other peers.
use anyhow::{anyhow, Context as _, Result};
use anyhow::{anyhow, bail, Context as _, Result};
use email::Header;
use futures_lite::StreamExt;
use iroh_gossip::net::{Event, Gossip, GossipEvent, JoinOptions, GOSSIP_ALPN};
@@ -232,6 +232,7 @@ impl ChannelState {
impl Context {
/// Create iroh endpoint and gossip.
async fn init_peer_channels(&self) -> Result<Iroh> {
info!(self, "Initializing peer channels.");
let secret_key = SecretKey::generate();
let public_key = secret_key.public();
@@ -277,6 +278,10 @@ impl Context {
/// Get or initialize the iroh peer channel.
pub async fn get_or_try_init_peer_channel(&self) -> Result<&Iroh> {
if !self.get_config_bool(Config::WebxdcRealtimeEnabled).await? {
bail!("Attempt to get Iroh when realtime is disabled");
}
let ctx = self.clone();
self.iroh
.get_or_try_init(|| async { ctx.init_peer_channels().await })
@@ -949,6 +954,10 @@ mod tests {
// creates iroh endpoint as side effect
leave_webxdc_realtime(alice, MsgId::new(1)).await.unwrap();
assert!(alice.ctx.iroh.get().is_none())
assert!(alice.ctx.iroh.get().is_none());
// This internal function should return error
// if accidentally called with the setting disabled.
assert!(alice.ctx.get_or_try_init_peer_channel().await.is_err());
}
}

View File

@@ -1454,12 +1454,18 @@ async fn add_parts(
let relay_server = node_addr.relay_url().map(|relay| relay.as_str());
iroh_add_peer_for_topic(context, instance_id, topic, node_id, relay_server)
.await?;
let iroh = context.get_or_try_init_peer_channel().await?;
iroh.maybe_add_gossip_peers(topic, vec![node_addr]).await?;
if context
.get_config_bool(Config::WebxdcRealtimeEnabled)
.await?
{
let iroh = context.get_or_try_init_peer_channel().await?;
iroh.maybe_add_gossip_peers(topic, vec![node_addr]).await?;
}
info!(context, "Added iroh peer to the topic of {instance_id}.");
} else {
warn!(
context,
"Could not add iroh peer because {instance_id} has no topic"
"Could not add iroh peer because {instance_id} has no topic."
);
}
chat_id = DC_CHAT_ID_TRASH;

View File

@@ -1070,15 +1070,6 @@ CREATE INDEX msgs_status_updates_index2 ON msgs_status_updates (uid);
.await?;
}
inc_and_check(&mut migration_version, 124)?;
if dbversion < migration_version {
sql.execute_migration(
"INSERT INTO contacts (name, addr, origin, authname, is_bot) VALUES ('xstore', 'xstore@testrun.org', 67108864, '', true);",
migration_version,
)
.await?;
}
let new_version = sql
.get_raw_config_int(VERSION_CFG)
.await?
@@ -1142,27 +1133,3 @@ impl Sql {
self.set_db_version_in_cache(version).await
}
}
#[cfg(test)]
mod tests {
use crate::{contact, test_utils::TestContext};
use anyhow::Result;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_name() -> Result<()> {
let bob = TestContext::new_bob().await;
let xstore_id = contact::Contact::lookup_id_by_addr(
&bob,
"xstore@testrun.org",
contact::Origin::Unknown,
)
.await?
.expect("Expect xstore contact");
let xstore = contact::Contact::get_by_id(&bob, xstore_id).await?;
assert_eq!(xstore.get_name(), "xstore");
assert_eq!(xstore.get_addr(), "xstore@testrun.org");
assert_eq!(xstore.origin, contact::Origin::ManuallyCreated);
assert_eq!(xstore.is_bot(), true);
Ok(())
}
}