mirror of
https://github.com/chatmail/core.git
synced 2026-05-13 20:06:30 +03:00
feat: Never remove primary transport when applying SyncTransports message
If we missed a message changing the primary transport, we shouldn't remove it when applying a SyncTransports message, such a state doesn't look correct even if it's temporary.
This commit is contained in:
@@ -806,8 +806,6 @@ UPDATE config SET value=? WHERE keyname='configured_addr' AND value!=?1
|
|||||||
if transport_changed {
|
if transport_changed {
|
||||||
info!(context, "Primary transport changed to {from_addr:?}.");
|
info!(context, "Primary transport changed to {from_addr:?}.");
|
||||||
context.sql.uncache_raw_config("configured_addr").await;
|
context.sql.uncache_raw_config("configured_addr").await;
|
||||||
|
|
||||||
// Regenerate User ID in V4 keys.
|
|
||||||
context.self_public_key.lock().await.take();
|
context.self_public_key.lock().await.take();
|
||||||
|
|
||||||
context.emit_event(EventType::TransportsModified);
|
context.emit_event(EventType::TransportsModified);
|
||||||
|
|||||||
@@ -97,8 +97,7 @@ async fn test_receive_both() -> Result<()> {
|
|||||||
let alice_chat_id = alice.create_group_with_members("", &[bob]).await;
|
let alice_chat_id = alice.create_group_with_members("", &[bob]).await;
|
||||||
|
|
||||||
let (pre_message, post_message, alice_msg_id) =
|
let (pre_message, post_message, alice_msg_id) =
|
||||||
send_large_file_message(alice, alice_chat_id, Viewtype::File, &vec![0u8; 200_000])
|
send_large_file_message(alice, alice_chat_id, Viewtype::File, &vec![0u8; 200_000]).await?;
|
||||||
.await?;
|
|
||||||
|
|
||||||
let msg = bob.recv_msg(&pre_message).await;
|
let msg = bob.recv_msg(&pre_message).await;
|
||||||
let _ = bob.recv_msg_trash(&post_message).await;
|
let _ = bob.recv_msg_trash(&post_message).await;
|
||||||
|
|||||||
@@ -791,7 +791,18 @@ pub(crate) async fn sync_transports(
|
|||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.transaction(|transaction| {
|
.transaction(|transaction| {
|
||||||
|
let configured_addr = transaction.query_row(
|
||||||
|
"SELECT value FROM config WHERE keyname='configured_addr'",
|
||||||
|
(),
|
||||||
|
|row| {
|
||||||
|
let addr: String = row.get(0)?;
|
||||||
|
Ok(addr)
|
||||||
|
},
|
||||||
|
)?;
|
||||||
for RemovedTransportData { addr, timestamp } in removed_transports {
|
for RemovedTransportData { addr, timestamp } in removed_transports {
|
||||||
|
if *addr == configured_addr {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
modified |= transaction.execute(
|
modified |= transaction.execute(
|
||||||
"DELETE FROM transports
|
"DELETE FROM transports
|
||||||
WHERE addr=? AND add_timestamp<=?",
|
WHERE addr=? AND add_timestamp<=?",
|
||||||
|
|||||||
Reference in New Issue
Block a user