[Rt-commit] rt branch 5.0/dashboard-email-force-light-theme created. rt-5.0.3-123-gbf8a0b90cc

BPS Git Server git at git.bestpractical.com
Wed Sep 28 07:50:21 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/dashboard-email-force-light-theme has been created
        at  bf8a0b90ccde92b6baf8b39bb097bad5f94cf9fe (commit)

- Log -----------------------------------------------------------------
commit bf8a0b90ccde92b6baf8b39bb097bad5f94cf9fe
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Sep 28 14:21:42 2022 +0800

    Force to use light theme for dashboard emails
    
    Light theme has better compatibility with email clients. Considering
    clients usually have their own dark theme applied, it's not necessary to
    explicitly apply dark theme to emails.
    
    This is initially to fix an issue for Outlook desktop clients: as it
    only supports background-color for partial tags, dark theme emails were
    rendered weirdly when config $EmailDashboardInlineCSS(implemented in
    5.0/dashboard-inline-css) is enabled.

diff --git a/lib/RT/Dashboard/Mailer.pm b/lib/RT/Dashboard/Mailer.pm
index 84275ecfa3..7205a48bdd 100644
--- a/lib/RT/Dashboard/Mailer.pm
+++ b/lib/RT/Dashboard/Mailer.pm
@@ -100,6 +100,19 @@ sub MailDashboards {
         $Users->Limit( FIELD => 'id', VALUE => $user->Id || 0 );
     }
 
+    # Force to use light theme for better compatibility with email clients
+    {
+        my $original_config_get = \&RT::Config::Get;
+        no warnings 'redefine';
+        *RT::Config::Get = sub {
+            my ( $self, $name ) = @_;
+            if ( $name eq 'WebDefaultStylesheet' ) {
+                return 'elevator-light';
+            }
+            return $original_config_get->(@_);
+        };
+    }
+
     while (defined(my $user = $Users->Next)) {
         my ($hour, $dow, $dom) = HourDowDomIn($args{Time}, $user->Timezone || RT->Config->Get('Timezone'));
         $hour .= ':00';

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list