Skip to content

fix: open phone book contacts with the account of their server - #6938

Merged
mahibi merged 1 commit into
masterfrom
fix/noid/contact-chat-account
Oct 23, 2026
Merged

mahibi merged 1 commit into
masterfrom
fix/noid/contact-chat-account

Conversation

@AndyScherzinger

@AndyScherzinger AndyScherzinger commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Opening a Nextcloud contact from the Android Contacts app ("Chat via Talk") reported "account not found" for contacts that belong to an existing account other than the current default one.

Cause: the phone book integration (ContactAddressBookWorker) syncs for the account that is the default at the time, and stores the contact's cloud ID (user@host[/path]). After switching the default account, entries synced for the previous one remain. MainActivity.openChatOfContact() only compared the contact's server with the current default account, so these contacts could not be opened although their account exists.

Fix: choose the account by the server in the contact's cloud ID: the default account if it is on that server, otherwise another account on it (MainActivity.accountForContactServer()). The error is only shown if no account is on that server.

The server is now compared exactly (scheme stripped, trailing slash and case ignored) instead of with currentUser.baseUrl.endsWith(server), which also matched e.g. https://mycloud.example.com for a contact on cloud.example.com.

The snackbar for the "account not found" case is left as is here; #6937 turns it into a toast, as it was shown underneath the conversation list.

Tests: MainActivityContactAccountTest covers default account, another account on the contact's server, no default account, no matching account, suffix-only match, path, case/trailing slash and invalid servers. ktlint clean; detekt only reports the existing CyclomaticComplexMethod on handleIntent (same on master).

🖼️ Screenshots

🏚️ Before 🏡 After
B A

🚧 TODO

  • Test on a device with two accounts on different servers: sync the phone book with account A as default, switch the default to B, open a contact of A from the Contacts app

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔖 Capability is checked or not needed
  • 🔙 Backport requests are created or not needed: /backport to stable-xx.x
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

The phone book integration syncs for the account that is the default
at the time, so a contact entry can belong to another account than the
current default one, e.g. after switching it. Opening such a contact
only compared it with the default account and reported that no account
was found, although one exists.

Choose the account by the server in the contact's cloud ID: the default
account if it is on that server, otherwise another account on it. Also
compare the server exactly instead of with endsWith(), which matched
https://mycloud.example.com for a contact on cloud.example.com.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger AndyScherzinger added the bug Something isn't working label Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Codacy

Lint

TypemasterPR
Warnings138138
Errors1515

SpotBugs

CategoryBaseNew
Bad practice77
Correctness88
Dodgy code4040
Internationalization33
Malicious code vulnerability33
Performance88
Security1111
Total8080

@github-actions

Copy link
Copy Markdown
Contributor

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit 26892c8
Version 6938
Available until 7 days after this build

The QA build installs alongside a released Nextcloud app, so you can keep
using your existing install while testing.

Downloading the file requires a GitHub account, so open this link on the
device you want to test on, or transfer the APK to it.

@mahibi
mahibi self-requested a review October 23, 2026 08:51

@mahibi mahibi 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.

tested and works fine

@mahibi mahibi added this to the 25.1.0 milestone Oct 23, 2026
@mahibi
mahibi merged commit 4180c83 into master Oct 23, 2026
21 checks passed
@mahibi
mahibi deleted the fix/noid/contact-chat-account branch October 23, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI assisted bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants