Files
ignacionelson 6e47d76ba6 ProjectSend 2.0.0
Client file sharing, rebuilt from the ground up: a private area per
client, resumable uploads, folders, groups and categories, sharing with
expiry dates and download limits, comments, file versions, an activity
log, a REST API, and sixteen languages.

This repository begins here. ProjectSend 2 was developed privately, and
that development history is not published — the previous generation
remains available, with its own history, at projectsend/legacy.

Free software under the GNU General Public License v2, or (at your
option) any later version.
2026-08-14 01:38:12 -03:00

50 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Modules\Platform\Notifications;
use App\Modules\Platform\Attribution\Attribution;
use App\Modules\Platform\Theming\EmailThemeRegistry;
use App\Modules\Platform\Theming\EmailThemeService;
use Illuminate\Notifications\Channels\MailChannel;
use Illuminate\Support\Facades\View;
/**
* Every notification's toMail() funnels through
* MailChannel::markdownRenderer() before the markdown view is rendered —
* the single choke point that lets the tenant's chosen email theme
* (Setting::EmailTheme) apply to all of them without touching each
* Notification class individually. Bound over the stock MailChannel in
* PlatformServiceProvider.
*
* `$mail_theme`/`$mail_theme_context`/`$mail_attribution` are shared with
* the view factory (rather than passed as view data) because the
* published header/footer partials are rendered as components nested
* inside Markdown::render()'s own view call, which doesn't forward the
* outer $data array to them.
*
* Attribution is resolved here, per message, rather than once at boot:
* this runs inside a queue worker that stays alive for hours, and a
* footer cached at boot would keep naming ProjectSend in mail sent long
* after an operator white-labelled the installation.
*
* See docs/theming-email-checklist.md before adding a theme or changing
* anything here — a new Notification class needs none of this, by
* design (that's the whole point of the choke point above).
*/
class ThemedMailChannel extends MailChannel
{
protected function markdownRenderer($message)
{
$theme = $message->theme ?? app(EmailThemeService::class)->currentThemeKey();
$context = app(EmailThemeRegistry::class)->get($theme)?->context;
View::share('mail_theme', $theme);
View::share('mail_theme_context', $context !== null ? $context() : []);
View::share('mail_attribution', app(Attribution::class)->visible());
return $this->markdown->theme($theme);
}
}