Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Sep 6, 2024
2 parents bd5abba + 853e38e commit e9e386c
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 42 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [1.142.12] - 2024-09-02

### Fixes

- Display Config::MdnsEnabled as true by default ([#5948](https://github.com/deltachat/deltachat-core-rust/pull/5948)).

## [1.142.11] - 2024-08-30

### Fixes
Expand Down Expand Up @@ -4799,3 +4805,4 @@ https://github.com/deltachat/deltachat-core-rust/pulls?q=is%3Apr+is%3Aclosed
[1.142.9]: https://github.com/deltachat/deltachat-core-rust/compare/v1.142.8...v1.142.9
[1.142.10]: https://github.com/deltachat/deltachat-core-rust/compare/v1.142.9..v1.142.10
[1.142.11]: https://github.com/deltachat/deltachat-core-rust/compare/v1.142.10..v1.142.11
[1.142.12]: https://github.com/deltachat/deltachat-core-rust/compare/v1.142.11..v1.142.12
28 changes: 17 additions & 11 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltachat"
version = "1.142.11"
version = "1.142.12"
edition = "2021"
license = "MPL-2.0"
rust-version = "1.77"
Expand Down
2 changes: 1 addition & 1 deletion deltachat-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltachat_ffi"
version = "1.142.11"
version = "1.142.12"
description = "Deltachat FFI"
edition = "2018"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion deltachat-jsonrpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltachat-jsonrpc"
version = "1.142.11"
version = "1.142.12"
description = "DeltaChat JSON-RPC API"
edition = "2021"
default-run = "deltachat-jsonrpc-server"
Expand Down
2 changes: 1 addition & 1 deletion deltachat-jsonrpc/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@
},
"type": "module",
"types": "dist/deltachat.d.ts",
"version": "1.142.11"
"version": "1.142.12"
}
2 changes: 1 addition & 1 deletion deltachat-repl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltachat-repl"
version = "1.142.11"
version = "1.142.12"
license = "MPL-2.0"
edition = "2021"
repository = "https://github.com/deltachat/deltachat-core-rust"
Expand Down
2 changes: 1 addition & 1 deletion deltachat-rpc-client/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "deltachat-rpc-client"
version = "1.142.11"
version = "1.142.12"
description = "Python client for Delta Chat core JSON-RPC interface"
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down
9 changes: 8 additions & 1 deletion deltachat-rpc-client/tests/test_securejoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_qr_setup_contact_svg(acfactory) -> None:

@pytest.mark.parametrize("protect", [True, False])
def test_qr_securejoin(acfactory, protect, tmp_path):
alice, bob = acfactory.get_online_accounts(2)
alice, bob, fiona = acfactory.get_online_accounts(3)

# Setup second device for Alice
# to test observing securejoin protocol.
Expand Down Expand Up @@ -112,6 +112,13 @@ def test_qr_securejoin(acfactory, protect, tmp_path):
alice2_contact_bob_snapshot = alice2_contact_bob.get_snapshot()
assert alice2_contact_bob_snapshot.is_verified

# The QR code token is synced, so alice2 must be able to handle join requests.
logging.info("Fiona joins verified group via alice2")
alice.stop_io()
fiona.secure_join(qr_code)
alice2.wait_for_securejoin_inviter_success()
fiona.wait_for_securejoin_joiner_success()


def test_qr_securejoin_contact_request(acfactory) -> None:
"""Alice invites Bob to a group when Bob's chat with Alice is in a contact request mode."""
Expand Down
2 changes: 1 addition & 1 deletion deltachat-rpc-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deltachat-rpc-server"
version = "1.142.11"
version = "1.142.12"
description = "DeltaChat JSON-RPC server"
edition = "2021"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion deltachat-rpc-server/npm-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
},
"type": "module",
"types": "index.d.ts",
"version": "1.142.11"
"version": "1.142.12"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@
"test:mocha": "mocha node/test/test.mjs --growl --reporter=spec --bail --exit"
},
"types": "node/dist/index.d.ts",
"version": "1.142.11"
"version": "1.142.12"
}
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "deltachat"
version = "1.142.11"
version = "1.142.12"
description = "Python bindings for the Delta Chat Core library using CFFI against the Rust-implemented libdeltachat"
readme = "README.rst"
requires-python = ">=3.7"
Expand Down
2 changes: 1 addition & 1 deletion release-date.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-08-30
2024-09-02
30 changes: 18 additions & 12 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ impl ChatId {
) -> Result<Self> {
let chat_id = match ChatIdBlocked::lookup_by_contact(context, contact_id).await? {
Some(chat) => {
if create_blocked == Blocked::Not && chat.blocked != Blocked::Not {
chat.id.set_blocked(context, Blocked::Not).await?;
if create_blocked != Blocked::Not || chat.blocked == Blocked::Not {
return Ok(chat.id);
}
chat.id.set_blocked(context, Blocked::Not).await?;
chat.id
}
None => {
Expand Down Expand Up @@ -1954,8 +1955,8 @@ impl Chat {
msg.param.set_int(Param::AttachGroupImage, 1);
self.param.remove(Param::Unpromoted);
self.update_param(context).await?;
// send_sync_msg() is called (usually) a moment later at send_msg_to_smtp()
// when the group creation message is actually sent through SMTP --
// send_sync_msg() is called a moment later at `smtp::send_smtp_messages()`
// when the group creation message is already in the `smtp` table --
// this makes sure, the other devices are aware of grpid that is used in the sync-message.
context
.sync_qr_code_tokens(Some(self.id))
Expand Down Expand Up @@ -3753,17 +3754,13 @@ pub(crate) async fn add_contact_to_chat_ex(
bail!("can not add contact because the account is not part of the group/broadcast");
}

let sync_qr_code_tokens;
if from_handshake && chat.param.get_int(Param::Unpromoted).unwrap_or_default() == 1 {
chat.param.remove(Param::Unpromoted);
chat.update_param(context).await?;
if context
.sync_qr_code_tokens(Some(chat_id))
.await
.log_err(context)
.is_ok()
{
context.scheduler.interrupt_smtp().await;
}
sync_qr_code_tokens = true;
} else {
sync_qr_code_tokens = false;
}

if context.is_self_addr(contact.get_addr()).await? {
Expand Down Expand Up @@ -3807,6 +3804,15 @@ pub(crate) async fn add_contact_to_chat_ex(
return Err(e);
}
sync = Nosync;
if sync_qr_code_tokens
&& context
.sync_qr_code_tokens(Some(chat_id))
.await
.log_err(context)
.is_ok()
{
context.scheduler.interrupt_smtp().await;
}
}
context.emit_event(EventType::ChatModified(chat_id));
if sync.into() {
Expand Down
16 changes: 9 additions & 7 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ pub enum Config {

/// True if Message Delivery Notifications (read receipts) should
/// be sent and requested.
#[strum(props(default = "1"))]
MdnsEnabled,

/// True if "Sent" folder should be watched for changes.
Expand Down Expand Up @@ -543,18 +544,15 @@ impl Context {

/// Returns whether MDNs should be requested.
pub(crate) async fn should_request_mdns(&self) -> Result<bool> {
match self.get_config_bool_opt(Config::MdnsEnabled).await? {
Some(val) => Ok(val),
None => Ok(!self.get_config_bool(Config::Bot).await?),
match self.config_exists(Config::MdnsEnabled).await? {
true => self.get_config_bool(Config::MdnsEnabled).await,
false => Ok(!self.get_config_bool(Config::Bot).await?),
}
}

/// Returns whether MDNs should be sent.
pub(crate) async fn should_send_mdns(&self) -> Result<bool> {
Ok(self
.get_config_bool_opt(Config::MdnsEnabled)
.await?
.unwrap_or(true))
self.get_config_bool(Config::MdnsEnabled).await
}

/// Gets configured "delete_server_after" value.
Expand Down Expand Up @@ -1011,9 +1009,13 @@ mod tests {
let t = &TestContext::new_alice().await;
assert!(t.should_request_mdns().await?);
assert!(t.should_send_mdns().await?);
// The setting should be displayed correctly.
assert!(t.get_config_bool(Config::MdnsEnabled).await?);

t.set_config_bool(Config::Bot, true).await?;
assert!(!t.should_request_mdns().await?);
assert!(t.should_send_mdns().await?);
assert!(t.get_config_bool(Config::MdnsEnabled).await?);
Ok(())
}

Expand Down
35 changes: 35 additions & 0 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,10 @@ mod tests {
use anyhow::bail;

use super::*;
use crate::chat::ProtectionStatus;
use crate::chatlist::Chatlist;
use crate::contact::{Contact, Origin};
use crate::securejoin::get_securejoin_qr;
use crate::test_utils::{TestContext, TestContextManager};
use crate::tools::SystemTime;

Expand Down Expand Up @@ -630,4 +632,37 @@ mod tests {
assert_eq!(msg.text, "hi");
Ok(())
}

#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_unpromoted_group_no_qr_sync() -> Result<()> {
let mut tcm = TestContextManager::new();
let alice = &tcm.alice().await;
alice.set_config_bool(Config::SyncMsgs, true).await?;
let alice_chatid =
chat::create_group_chat(alice, ProtectionStatus::Protected, "the chat").await?;
let qr = get_securejoin_qr(alice, Some(alice_chatid)).await?;
let msg_id = alice.send_sync_msg().await?;
assert!(msg_id.is_none());

let bob = &tcm.bob().await;
tcm.exec_securejoin_qr(bob, alice, &qr).await;
let msg_id = alice.send_sync_msg().await?;
// The group becomes promoted when Bob joins, so the QR code token is synced.
assert!(msg_id.is_some());
let sent = alice.pop_sent_msg().await;
let msg = alice.parse_msg(&sent).await;
let mut sync_items = msg.sync_items.unwrap().items;
assert_eq!(sync_items.len(), 1);
let data = sync_items.pop().unwrap().data;
let SyncDataOrUnknown::SyncData(AddQrToken(_)) = data else {
unreachable!();
};

let fiona = &tcm.fiona().await;
tcm.exec_securejoin_qr(fiona, alice, &qr).await;
let msg_id = alice.send_sync_msg().await?;
// The QR code token was already synced before.
assert!(msg_id.is_none());
Ok(())
}
}

0 comments on commit e9e386c

Please sign in to comment.