Skip to content

fix: avatars in dashboard widgets#13314

Open
madbob wants to merge 1 commit into
nextcloud:mainfrom
madbob:issue_11634
Open

fix: avatars in dashboard widgets#13314
madbob wants to merge 1 commit into
nextcloud:mainfrom
madbob:issue_11634

Conversation

@madbob

@madbob madbob commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Fixes #11634

Warning: those changes do not address apparent issues caused by the avatars' cache: just changing an image may not provide immediate results until the cache is expired and recalculated.

Summary by CodeRabbit

  • New Features

    • Mail dashboard items now display sender avatars when available.
    • External avatars are supported with appropriate URL handling.
    • A fallback guest avatar is shown when no sender avatar is available.
  • Tests

    • Added coverage for avatar retrieval and display in important mail items.

@ChristophWurst ChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Comment thread lib/Dashboard/MailWidget.php Outdated
Comment thread lib/Dashboard/MailWidget.php Outdated
Comment thread lib/Dashboard/MailWidget.php Outdated
Comment thread lib/Dashboard/MailWidget.php Outdated
Comment thread lib/Dashboard/MailWidget.php Outdated
@ChristophWurst ChristophWurst self-assigned this Jul 21, 2026
@madbob
madbob force-pushed the issue_11634 branch 4 times, most recently from ca77ff3 to 259d727 Compare July 21, 2026 22:13
@ChristophWurst

Copy link
Copy Markdown
Member

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Dashboard avatar resolution

Layer / File(s) Summary
Avatar resolution and widget integration
lib/Dashboard/MailWidget.php
MailWidget receives IAvatarService, resolves sender avatars through getAvatar(), handles external and fallback URLs, and assigns the result to each widget item.
Avatar flow test coverage
tests/Unit/Dashboard/ImportantMailWidgetTest.php
Tests inject an avatar service mock, provide sender data, configure an avatar result, and verify item creation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: gretad, kesselb

Sequence Diagram(s)

sequenceDiagram
  participant ImportantMailWidget
  participant MailWidget
  participant IAvatarService
  ImportantMailWidget->>MailWidget: request mail items
  MailWidget->>IAvatarService: resolve avatar from sender email
  IAvatarService-->>MailWidget: return Avatar
  MailWidget-->>ImportantMailWidget: return WidgetItem with avatar URL
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The widget avatar fix addresses the dashboard part of #11634, but the message detail/open-message view requirement is not covered. Extend the avatar resolution fix to the message detail/open-message list views and verify all places in #11634.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the avatar fix in dashboard widgets.
Out of Scope Changes check ✅ Passed The changes stay focused on avatar resolution in MailWidget and its unit test, with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
tests/Unit/Dashboard/ImportantMailWidgetTest.php (2)

20-20: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Mock the interface and declare the fixture property.

$this->avatarService is undeclared, and the test mocks the concrete service although the widget consumes IAvatarService. Add a typed IAvatarService&MockObject property and mock that interface.

Proposed fix
-use OCA\Mail\Service\AvatarService;
+use OCA\Mail\Contracts\IAvatarService;

 private IInitialState&MockObject $initialState;
+private IAvatarService&MockObject $avatarService;

-$this->avatarService = $this->createMock(AvatarService::class);
+$this->avatarService = $this->createMock(IAvatarService::class);

As per coding guidelines, “Mock dependencies in PHP tests via $this->createMock(Interface::class)”.

Also applies to: 47-47

Source: Coding guidelines


123-130: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the avatar value, not just item creation.

This passes if the avatar returned by the service is ignored or replaced. Constrain getAvatar() to ('john@doe.com', 'bob') and assert the resulting WidgetItem exposes https://example.com/avatar.png; add a separate external-avatar case for the proxy route.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 55f2a240-930d-497b-910d-74bdcbc29698

📥 Commits

Reviewing files that changed from the base of the PR and between a21d05d and 259d727.

📒 Files selected for processing (2)
  • lib/Dashboard/MailWidget.php
  • tests/Unit/Dashboard/ImportantMailWidgetTest.php

Signed-off-by: Roberto Guido <info@madbob.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avatars not shown in Dashboard widget and message detail

2 participants