Skip to content

fix: Hide synced chat if we only know its visibility#8343

Merged
j-g00da merged 1 commit into
mainfrom
j-g00da/fix-pinned-chat-sync
Jun 18, 2026
Merged

fix: Hide synced chat if we only know its visibility#8343
j-g00da merged 1 commit into
mainfrom
j-g00da/fix-pinned-chat-sync

Conversation

@j-g00da

@j-g00da j-g00da commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Prevents showing "empty" chat on other devices,
when pinning a chat that did not complete securejoin yet.

Fixes: #7713

@j-g00da

j-g00da commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Tested with deltachat-desktop.

Maybe we should default to setting Blocked::Yes when creating new chats in sync_alter_chat, but there may be side effects hard to predict. That's why I only changed it in this single specific case (SyncId::ContactFingerprint with SyncAction::SetVisibility).

@j-g00da j-g00da requested a review from Hocuri June 17, 2026 11:56
@j-g00da

j-g00da commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Difference (unrelated to the bug itself) from UX perspective:

Normally chat won't display on other devices until you send a first message or pin it (then it will display as a contact request, which IMO is confusing anyway, as we initiated the chat, not the other way around).

After this change the chat will be displayed on other devices only after first message is sent.

@j-g00da j-g00da marked this pull request as ready for review June 17, 2026 12:10
@j-g00da j-g00da requested a review from link2xt June 17, 2026 12:12
@Hocuri

Hocuri commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Maybe we should default to setting Blocked::Yes when creating new chats in sync_alter_chat, but there may be side effects hard to predict. That's why I only changed it in this single specific case (SyncId::ContactFingerprint with SyncAction::SetVisibility).

Do any tests fail when setting the default to Blocked::Yes?

Going through the SyncActions:

    Block,
    Unblock,
    Accept, // These three anyways set the blocked state of the chat, so that it doesn't matter what it was before

    SetVisibility(ChatVisibility),

    SetMuted(MuteDuration), // This one probably had the same bug as SetVisibility - muting a chat with an unfinished securejoin process probably created a weird chat on the second device

    CreateOutBroadcast {
        chat_name: String,
        secret: String,
    },
    CreateGroupEncrypted(String), // These two are anyways handled by a different part of the match statement

    Rename(String), // The function returns before `get_for_contact()` is called

    SetContacts(Vec<String>),
    SetPgpContacts(Vec<(String, String)>),
    SetDescription(String),  // These three are about groups and channels, not about 1:1 chats

    Delete, // The chat will be deleted, no need to worry about it

Not sure if all of my comments are understandable, but the result is that I think it's fine to change to Blocked::Yes unconditionally.

@Hocuri

Hocuri commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Also, could you add a test? You can look at test_blocked_bob_cant_create_11_chat_via_securejoin for how to test syncing and securejoin. The exec_securejoin_qr_multi_device() function (and some other functions in test_utils.rs) run the full securejoin process; in order to control which device receives which message, you can also pop the messages one by one, just like in test_deduplicate_member_added().

@j-g00da

j-g00da commented Jun 17, 2026

Copy link
Copy Markdown
Contributor Author

Reading the comment few lines higher:

                // Use `Request` so that even if the program crashes, the user doesn't have to look
                // into the blocked contacts.

This is a bit odd though and it feels like we should be safe setting it to just Blocked::Yes? (Also it's setting Blocked for a chat, not a contact, which is a different concept) cc: @iequidoo

@iequidoo iequidoo self-requested a review June 17, 2026 15:48
@iequidoo

iequidoo commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

This is a bit odd though and it feels like we should be safe setting it to just Blocked::Yes? (Also it's setting Blocked for a chat, not a contact, which is a different concept) cc: @iequidoo

The comment is indeed wrong, but Blocked::Yes would also look strange and i made an experiment, this:

                let chat_id = ChatIdBlocked::get_for_contact(self, contact_id, Blocked::Yes)
                    .await?
                    .id;
                ensure!(false);
                chat_id

creates a hidden chat on the other device. Maybe just remove the comment and leave Request so that the chat is at least visible if some error happens.

Comment thread src/chat.rs Outdated
@j-g00da j-g00da force-pushed the j-g00da/fix-pinned-chat-sync branch from 501651d to b35008b Compare June 18, 2026 08:29

@Hocuri Hocuri left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing! Just some minor, and not too important, comments.

Comment thread src/chat.rs Outdated
Comment thread src/chat.rs Outdated
Comment thread src/chat/chat_tests.rs Outdated
Comment thread src/chat/chat_tests.rs
Prevents showing "empty" chat on other devices,
when pinning a chat that did not complete securejoin yet.

Fixes: #7713
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
@j-g00da j-g00da force-pushed the j-g00da/fix-pinned-chat-sync branch from b35008b to b3c8e31 Compare June 18, 2026 11:31
@j-g00da j-g00da enabled auto-merge (squash) June 18, 2026 11:33
@j-g00da j-g00da merged commit 8a1d97d into main Jun 18, 2026
31 checks passed
@j-g00da j-g00da deleted the j-g00da/fix-pinned-chat-sync branch June 18, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrong sync of pinned chat with pending secure-join

3 participants