feat(digest): inline file thumbnails in the daily activity digest email#2548
Open
karlitschek wants to merge 1 commit intomasterfrom
Open
feat(digest): inline file thumbnails in the daily activity digest email#2548karlitschek wants to merge 1 commit intomasterfrom
karlitschek wants to merge 1 commit intomasterfrom
Conversation
The daily activity digest currently lists each event with the provider's small icon URL. For file-related events that's a generic mime-type icon, which makes the digest feel like a server log rather than a "things that happened to your stuff today" summary. Show the actual file preview instead, when one is available. `DigestSender::getPreviewDataUri()` resolves the file as the affected user (so access mirrors what the recipient sees in the web UI), generates a 96×96 preview via `IPreview`, and returns a base64 data URI inlined directly into the email — no public preview endpoint needed, and the digest renders fully offline. Returns null on any failure (not a file event, file deleted, no read permission, preview generation unsupported, anything thrown). The existing `$event->getIcon()` is the seamless fallback, so existing behaviour is preserved for non-file or no-preview events. The 96px cap keeps each thumbnail around 3-5 KB; even at the 20-event ACTIVITY_LIMIT the digest stays well under common message-size thresholds. `IRootFolder` and `IPreview` are auto-wired through standard DI; `DigestSender` is not explicitly registered in `Application.php`, so no AppInfo change is needed. Signed-off-by: Frank Karlitschek <frank@nextcloud.com>
miaulalala
requested changes
May 4, 2026
Comment on lines
+249
to
+264
| $userFolder = $this->rootFolder->getUserFolder($uid); | ||
| $node = $userFolder->getFirstNodeById($event->getObjectId()); | ||
| if (!$node instanceof File) { | ||
| return null; | ||
| } | ||
|
|
||
| if (!$this->previewManager->isAvailable($node)) { | ||
| return null; | ||
| } | ||
|
|
||
| $preview = $this->previewManager->getPreview($node, self::PREVIEW_PIXELS, self::PREVIEW_PIXELS, true); | ||
| $content = $preview->getContent(); | ||
| if ($content === '') { | ||
| return null; | ||
| } | ||
| $mime = $preview->getMimeType() ?: 'image/png'; |
Collaborator
There was a problem hiding this comment.
This does image processing for every preview - and may be quite heavy for documents such as pdfs and office documents.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The daily activity digest currently lists each event with the provider's small icon URL. For file-related events that's a generic mime-type icon, which makes the digest feel like a server log rather than a "things that happened to your stuff today" summary. Show the actual file preview instead, when one is available.
DigestSender::getPreviewDataUri()resolves the file as the affected user (so access mirrors what the recipient sees in the web UI), generates a 96×96 preview viaIPreview, and returns a base64 data URI inlined directly into the email — no public preview endpoint needed, and the digest renders fully offline.Returns null on any failure (not a file event, file deleted, no read permission, preview generation unsupported, anything thrown). The existing
$event->getIcon()is the seamless fallback, so existing behaviour is preserved for non-file or no-preview events.The 96px cap keeps each thumbnail around 3-5 KB; even at the 20-event ACTIVITY_LIMIT the digest stays well under common message-size thresholds.
IRootFolderandIPrevieware auto-wired through standard DI;DigestSenderis not explicitly registered inApplication.php, so no AppInfo change is needed.