Skip to content

fix: show the right avatars and file previews for multiple accounts on the same server - #6914

Merged
AndyScherzinger merged 3 commits into
masterfrom
differentiateAvatarsOneSameInstance
Oct 17, 2026
Merged

AndyScherzinger merged 3 commits into
masterfrom
differentiateAvatarsOneSameInstance

Conversation

@mahibi

@mahibi mahibi commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator
  • Problem 1: wrong avatar for one-to-one conversations

    • Applies to two accounts on the same server that have a one-to-one conversation with each other.
    • Cause: one-to-one avatars were loaded from …/room/{token}/avatar. For one-to-one rooms the server answers with the other participant's avatar, so the same URL returns a different image per account. Coil's memory/disk caches and OkHttp's HTTP cache are keyed by URL, so whichever account loaded first decided what both accounts saw.
    • Fix: one-to-one rooms use the other participant's user avatar /index.php/avatar/{user}/…, as the chat toolbar and conversation info already do. That URL returns the same image to everyone, so caching stays safe.
      • One-to-one rooms are never federated (server: participants can't be added, and the avatar fallback is a local user).
      • Callers that only know the room token (direct share shortcut updates on new messages, the ongoing-call notification) skip the caches for one-to-one rooms.
    • Reproduce on master:
      a. Set up accounts A and B on the same server, with a one-to-one conversation between them and different profile pictures.
      b. Add both accounts to the app, with A active, and open the conversation list.
      c. Switch to B.
      d. Expected bug: the conversation with A shows B's own avatar. The user status shown on it is still correct.
  • Problem 2: wrong thumbnails in the remote file browser ("Share from ")

    • Cause: thumbnails were loaded from core/preview.png?file=. The server resolves that path in the requesting user's own files, so the same URL can mean different files for different accounts, and the URL-keyed caches mixed them up.
    • Fix: previews are requested by fileId (core/preview?fileId=…), with the fileId taken from oc:id, as the Nextcloud Files app and talk-ios do. The path-based URL helper was removed because nothing else used it.
    • Reproduce on master:
      a. Set up accounts A and B on the same server. Each has its own file at the same path with different content, e.g. /Photos/test.jpg.
      b. With A active, open a conversation → attachment button → "Share from " → Photos/. A's thumbnail is shown.
      c. Switch to B and repeat.
      d. Expected bug: B's row shows A's thumbnail next to B's own file size and date.
      e. The same browser opens from Profile → change avatar → choose from Nextcloud.
  • Tests:

    • ConversationAvatarContentTest: one-to-one rooms use the user-avatar endpoint and never the room endpoint, with and without the avatar capability.
    • RemoteFileBrowserItemTest (new): parsing the fileId from oc:id.
  • Side effects:

    • One-to-one avatars and file browser thumbnails load once more after the update, because their URLs changed.
    • The direct share shortcut update and the ongoing-call notification download one-to-one avatars without caching them.

Related: nextcloud/talk-ios#1794 is the same avatar bug in the iOS app, still open there.

🖼️ Screenshots for Problem 1

testuser1' real avatar image: the living room
grafik

testuser2' real avatar image: the keyboard
grafik

🏚️ Before

active account: testuser2 active account: testuser1. Bug: avatar of testuser2 is the living room
grafik grafik

🏡 After

active account: testuser2 active account: testuser1
grafik grafik

🏁 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

@mahibi mahibi self-assigned this Oct 16, 2026
@mahibi mahibi changed the title Differentiate avatars one same instance fix: show the right avatars and file previews for multiple accounts on the same server Oct 16, 2026
@mahibi mahibi added this to the 25.1.0 milestone Oct 16, 2026
@mahibi mahibi added the 3. to review Waiting for reviews label Oct 16, 2026
@mahibi
mahibi requested a review from rapterjet2004 October 16, 2026 13:55
@mahibi
mahibi marked this pull request as ready for review October 16, 2026 13:56
The conversation avatar endpoint answers depending on the requesting
account (one-to-one rooms return the other participant's avatar), but
accounts on the same server request the same URL. Coil's memory and disk
caches and OkHttp's HTTP cache were keyed by URL only, so one account
could be shown another account's cached avatar.

Scope the Coil cache keys of conversation avatar requests to the account
sending them and keep OkHttp's URL-keyed cache out of image loading;
Coil's own disk cache still revalidates per the server's cache headers.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
The preview-by-path endpoint used by the remote file browser resolves the
path in the requesting user's own files, so accounts on the same server
request the same URL for different files. Treat it like the conversation
avatar endpoint and scope its Coil cache keys per account; the
interceptor is renamed accordingly as it no longer handles avatars only.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
…ches

Replace the account-scoped cache keys with URLs whose response is the
same for every account, so caches keyed by URL are correct again (as in
the Nextcloud Files app):

- One-to-one rooms show the peer's user avatar instead of the
  conversation avatar endpoint, which answers per requesting account.
  One-to-one rooms are never federated, so the peer is a local user.
- Callers that only know the room token (direct share shortcuts, the
  ongoing call notification) bypass the caches for one-to-one rooms.
- The remote file browser requests previews by file id instead of by
  path, which the server resolves in the requesting user's files.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@AndyScherzinger
AndyScherzinger force-pushed the differentiateAvatarsOneSameInstance branch from a8a2383 to b1cd347 Compare October 16, 2026 17:15
@github-actions

Copy link
Copy Markdown
Contributor

📱 QA build

Download app-qa-debug.apk
QR code Open the QR code for this download
Commit b1cd347
Version 6914
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.

@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

@AndyScherzinger
AndyScherzinger merged commit 9408582 into master Oct 17, 2026
16 of 20 checks passed
@AndyScherzinger
AndyScherzinger deleted the differentiateAvatarsOneSameInstance branch October 17, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants