Skip to content

fix: add self user to MLS conversation when joining via invite link [WPB-22305]#21209

Merged
thisisamir98 merged 4 commits into
devfrom
mo/fix/send-welcome-for-self-clients-when-joining-via-link
May 5, 2026
Merged

fix: add self user to MLS conversation when joining via invite link [WPB-22305]#21209
thisisamir98 merged 4 commits into
devfrom
mo/fix/send-welcome-for-self-clients-when-joining-via-link

Conversation

@MohamadJaara
Copy link
Copy Markdown
Member

@MohamadJaara MohamadJaara commented May 4, 2026

StoryWPB-22305 [Web] Joining MLS conversation by guest link doesn't produce welcome message

when joining a conv via invite link the web app was not sending welcome message to invite self user other clients to the conv

to test the fix you must have user A on web and mobile, and user B does not matter

  1. B create a new empty MLS group
  2. B create an invite link and send it to A in 1:1
  3. A open the link from their web client
  4. B send a message in that group

expected:
A should see this message on web and mobile
actual:
A sees the message only on web

to fix it i used codex with GPT-5.5 using this prompt


join an MLS conv via invite link is broken for other self clients when joining from this web app
my theory is the app is not doing step 8 from what the android app is doing

Here’s the Android/Kalium flow for “join MLS conversation via invite link”, with the CoreCrypto calls called out.

Flow

  1. Public API: JoinConversationViaCodeUseCase
    calls conversationGroupRepository.joinViaInviteCode(code, key, null, password).

  2. Backend invite join: ConversationGroupRepository
    calls:

    conversationApi.joinConversation(code, key, uri, password)

    Network side is POST /conversations/join.

  3. If backend returns Changed, Kalium emits the local member-join event, reads the conversation protocol, and if it is MLS-capable starts crypto transaction joinViaInviteCode.

  4. Inside that transaction, Kalium first joins the MLS group:
    JoinExistingMLSConversationUseCase
    fetches group info:

    GET /conversations/{domain}/{conversationId}/groupinfo

    implemented at ConversationApiV5.

  5. Then Kalium calls:

    mlsConversationRepository.joinGroupByExternalCommit(mlsContext, groupId, groupInfo)

    which calls CoreCrypto:

    mlsContext.joinByExternalCommit(groupInfo)

    at MLSConversationRepository.

  6. The actual CoreCrypto binding call is:

    context.joinByExternalCommit(
        groupInfo = publicGroupState.toGroupInfo(),
        customConfiguration = CUSTOM_CONFIGURATION_DEFAULT,
        credentialType = DEFAULT or X509,
    )

    at MLSClientImpl.

  7. After that succeeds, Kalium reads the local epoch:

    mlsContext.conversationEpoch(groupId)

    and marks the local DB group state as ESTABLISHED.

  8. Important second step: after external commit succeeds, invite-link join also calls:

    mlsConversationRepository.addMemberToMLSGroup(
        mlsContext,
        groupId,
        listOf(selfUserId),
        cipherSuite
    )

    See ConversationGroupRepository.

  9. addMemberToMLSGroup first commits pending proposals:

    mlsContext.commitPendingProposals(groupId)

    then claims key packages for selfUserId, then calls either:

    mlsContext.addMember(groupId, clientKeyPackageList)

    or, if there are no key packages:

    mlsContext.updateKeyingMaterial(groupId)

    See MLSConversationRepository and MLSConversationRepository.

  10. CoreCrypto implementations for those are:

context.commitPendingProposals(groupId.toCrypto())
context.addClientsToConversation(groupId.toCrypto(), keyPackages)
context.updateKeyingMaterial(groupId.toCrypto())

See MLSClientImpl and MLSClientImpl.

Transport detail web may be missing
Kalium does not manually POST every generated MLS commit from the repository. The MLS client is created with an MLSTransporter; CoreCrypto uses that transport to send commit bundles. The transport calls:

mlsMessageApi.sendCommitBundle(...)

which posts:

POST /mls/commit-bundles
Content-Type: message/mls

See MLSTransportProvider and MLSMessageApiV5.

So the short version to send web is:

After POST /conversations/join succeeds for an MLS conversation:
1. Fetch /conversations/{domain}/{conv}/groupinfo.
2. Call CoreCrypto joinByExternalCommit(groupInfo, config, credentialType).
3. Let CoreCrypto/MLS transport send the produced commit bundle to POST /mls/commit-bundles.
4. Read local conversationEpoch and mark local group established.
5. Then add the current user/self clients to the MLS group:
   - commitPendingProposals(groupId)
   - claim self key packages
   - addClientsToConversation(groupId, keyPackages)
     OR updateKeyingMaterial(groupId) if no key packages
6. Those commit-producing calls also need their commit bundles sent via POST /mls/commit-bundles.

@MohamadJaara MohamadJaara changed the title fix: add self user to MLS conversation when joining via invite link fix: add self user to MLS conversation when joining via invite link [WPB-22305] May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

🔗 Download Full Report Artifact

🧪 Playwright Test Summary

  • Passed: 15
  • Failed: 0
  • Skipped: 0
  • 🔁 Flaky: 0
  • 📊 Total: 15
  • Total Runtime: 111.0s (~ 1 min 51 sec)

Comment thread libraries/core/src/conversation/conversationService/conversationService.ts Outdated
Comment thread apps/webapp/src/script/repositories/conversation/ConversationRepository.ts Outdated
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 5, 2026

@thisisamir98 thisisamir98 added this pull request to the merge queue May 5, 2026
Merged via the queue into dev with commit a3c765d May 5, 2026
35 checks passed
@thisisamir98 thisisamir98 deleted the mo/fix/send-welcome-for-self-clients-when-joining-via-link branch May 5, 2026 12:30
screendriver pushed a commit that referenced this pull request May 15, 2026
…WPB-22305] (#21209)

* fix: add self user to MLS conversation when joining via invite link

* pr comments

* refactor

* improve logs

---------

Co-authored-by: Amir Ghezelbash <thisisamir98@gmail.com>
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.

2 participants