Skip to content

Commit f42ca3a

Browse files
authored
Merge pull request #52248 from nextcloud/backport/52240/stable31
[stable31] fix(mail): use matching text color for primary elements
2 parents 287753e + dada9b5 commit f42ca3a

File tree

3 files changed

+44
-32
lines changed

3 files changed

+44
-32
lines changed

apps/settings/tests/Mailer/NewUserMailHelperTest.php

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ public function testGenerateTemplateWithPasswordResetToken(): void {
146146
->method('getName')
147147
->willReturn('TestCloud');
148148
$this->defaults
149-
->expects($this->any())
150-
->method('getTextColorPrimary')
149+
->expects($this->atLeastOnce())
150+
->method('getDefaultColorPrimary')
151+
->willReturn('#00679e');
152+
$this->defaults
153+
->expects($this->atLeastOnce())
154+
->method('getDefaultTextColorPrimary')
151155
->willReturn('#ffffff');
152156

153157
$expectedHtmlBody = <<<EOF
@@ -175,7 +179,7 @@ public function testGenerateTemplateWithPasswordResetToken(): void {
175179
<table class="row collapse" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
176180
<tbody>
177181
<tr style="padding:0;text-align:left;vertical-align:top">
178-
<center data-parsed="" style="background-color:;min-width:175px;max-height:175px; padding:35px 0px;border-radius:200px">
182+
<center data-parsed="" style="background-color:#00679e;min-width:175px;max-height:175px; padding:35px 0px;border-radius:200px">
179183
<img class="logo float-center" src="" alt="TestCloud" align="center" style="-ms-interpolation-mode:bicubic;clear:both;display:block;float:none;margin:0 auto;outline:0;text-align:center;text-decoration:none;max-height:105px;max-width:105px;width:auto;height:auto">
180184
</center>
181185
</tr>
@@ -260,13 +264,13 @@ public function testGenerateTemplateWithPasswordResetToken(): void {
260264
<tr style="padding:0;text-align:left;vertical-align:top">
261265
<th style="Margin:0;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
262266
<center data-parsed="" style="min-width:490px;width:100%">
263-
<table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;border-radius:8px;max-width:300px;padding:0;text-align:center;vertical-align:top;width:auto;background:;background-color:;color:#fefefe;">
267+
<table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;border-radius:8px;max-width:300px;padding:0;text-align:center;vertical-align:top;width:auto;background:#00679e;background-color:#00679e;color:#fefefe;">
264268
<tr style="padding:0;text-align:left;vertical-align:top">
265269
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
266270
<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
267271
<tr style="padding:0;text-align:left;vertical-align:top">
268-
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border:0 solid ;border-collapse:collapse!important;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
269-
<a href="https://example.com/resetPassword/MySuperLongSecureRandomToken" style="Margin:0;border:0 solid ;color:#ffffff;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:normal;margin:0;padding:8px;text-align:left;outline:1px solid #ffffff;text-decoration:none">Set your password</a>
272+
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border:0 solid #00679e;border-collapse:collapse!important;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
273+
<a href="https://example.com/resetPassword/MySuperLongSecureRandomToken" style="Margin:0;border:0 solid #00679e;color:#ffffff;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:normal;margin:0;padding:8px;text-align:left;outline:1px solid #ffffff;text-decoration:none">Set your password</a>
270274
</td>
271275
</tr>
272276
</table>
@@ -382,8 +386,12 @@ public function testGenerateTemplateWithoutPasswordResetToken(): void {
382386
->method('getName')
383387
->willReturn('TestCloud');
384388
$this->defaults
385-
->expects($this->any())
386-
->method('getTextColorPrimary')
389+
->expects($this->atLeastOnce())
390+
->method('getDefaultColorPrimary')
391+
->willReturn('#00679e');
392+
$this->defaults
393+
->expects($this->atLeastOnce())
394+
->method('getDefaultTextColorPrimary')
387395
->willReturn('#ffffff');
388396

389397
$expectedHtmlBody = <<<EOF
@@ -411,7 +419,7 @@ public function testGenerateTemplateWithoutPasswordResetToken(): void {
411419
<table class="row collapse" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
412420
<tbody>
413421
<tr style="padding:0;text-align:left;vertical-align:top">
414-
<center data-parsed="" style="background-color:;min-width:175px;max-height:175px; padding:35px 0px;border-radius:200px">
422+
<center data-parsed="" style="background-color:#00679e;min-width:175px;max-height:175px; padding:35px 0px;border-radius:200px">
415423
<img class="logo float-center" src="" alt="TestCloud" align="center" style="-ms-interpolation-mode:bicubic;clear:both;display:block;float:none;margin:0 auto;outline:0;text-align:center;text-decoration:none;max-height:105px;max-width:105px;width:auto;height:auto">
416424
</center>
417425
</tr>
@@ -496,13 +504,13 @@ public function testGenerateTemplateWithoutPasswordResetToken(): void {
496504
<tr style="padding:0;text-align:left;vertical-align:top">
497505
<th style="Margin:0;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
498506
<center data-parsed="" style="min-width:490px;width:100%">
499-
<table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;border-radius:8px;max-width:300px;padding:0;text-align:center;vertical-align:top;width:auto;background:;background-color:;color:#fefefe;">
507+
<table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;border-radius:8px;max-width:300px;padding:0;text-align:center;vertical-align:top;width:auto;background:#00679e;background-color:#00679e;color:#fefefe;">
500508
<tr style="padding:0;text-align:left;vertical-align:top">
501509
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
502510
<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
503511
<tr style="padding:0;text-align:left;vertical-align:top">
504-
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border:0 solid ;border-collapse:collapse!important;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
505-
<a href="https://example.com/" style="Margin:0;border:0 solid ;color:#ffffff;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:normal;margin:0;padding:8px;text-align:left;outline:1px solid #ffffff;text-decoration:none">Go to TestCloud</a>
512+
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border:0 solid #00679e;border-collapse:collapse!important;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
513+
<a href="https://example.com/" style="Margin:0;border:0 solid #00679e;color:#ffffff;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:normal;margin:0;padding:8px;text-align:left;outline:1px solid #ffffff;text-decoration:none">Go to TestCloud</a>
506514
</td>
507515
</tr>
508516
</table>
@@ -622,8 +630,12 @@ public function testGenerateTemplateWithoutUserId(): void {
622630
->method('getName')
623631
->willReturn('TestCloud');
624632
$this->defaults
625-
->expects($this->any())
626-
->method('getTextColorPrimary')
633+
->expects($this->atLeastOnce())
634+
->method('getDefaultColorPrimary')
635+
->willReturn('#00679e');
636+
$this->defaults
637+
->expects($this->atLeastOnce())
638+
->method('getDefaultTextColorPrimary')
627639
->willReturn('#ffffff');
628640

629641
$expectedHtmlBody = <<<EOF
@@ -651,7 +663,7 @@ public function testGenerateTemplateWithoutUserId(): void {
651663
<table class="row collapse" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
652664
<tbody>
653665
<tr style="padding:0;text-align:left;vertical-align:top">
654-
<center data-parsed="" style="background-color:;min-width:175px;max-height:175px; padding:35px 0px;border-radius:200px">
666+
<center data-parsed="" style="background-color:#00679e;min-width:175px;max-height:175px; padding:35px 0px;border-radius:200px">
655667
<img class="logo float-center" src="" alt="TestCloud" align="center" style="-ms-interpolation-mode:bicubic;clear:both;display:block;float:none;margin:0 auto;outline:0;text-align:center;text-decoration:none;max-height:105px;max-width:105px;width:auto;height:auto">
656668
</center>
657669
</tr>
@@ -721,13 +733,13 @@ public function testGenerateTemplateWithoutUserId(): void {
721733
<tr style="padding:0;text-align:left;vertical-align:top">
722734
<th style="Margin:0;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
723735
<center data-parsed="" style="min-width:490px;width:100%">
724-
<table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;border-radius:8px;max-width:300px;padding:0;text-align:center;vertical-align:top;width:auto;background:;background-color:;color:#fefefe;">
736+
<table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;border-radius:8px;max-width:300px;padding:0;text-align:center;vertical-align:top;width:auto;background:#00679e;background-color:#00679e;color:#fefefe;">
725737
<tr style="padding:0;text-align:left;vertical-align:top">
726738
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
727739
<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
728740
<tr style="padding:0;text-align:left;vertical-align:top">
729-
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border:0 solid ;border-collapse:collapse!important;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
730-
<a href="https://example.com/" style="Margin:0;border:0 solid ;color:#ffffff;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:normal;margin:0;padding:8px;text-align:left;outline:1px solid #ffffff;text-decoration:none">Go to TestCloud</a>
741+
<td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border:0 solid #00679e;border-collapse:collapse!important;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:normal;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
742+
<a href="https://example.com/" style="Margin:0;border:0 solid #00679e;color:#ffffff;display:inline-block;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',Arial,sans-serif;font-size:16px;font-weight:regular;line-height:normal;margin:0;padding:8px;text-align:left;outline:1px solid #ffffff;text-decoration:none">Go to TestCloud</a>
731743
</td>
732744
</tr>
733745
</table>

lib/private/Mail/EMailTemplate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ public function addBodyButtonGroup(
523523
$this->ensureBodyListClosed();
524524

525525
$color = $this->themingDefaults->getDefaultColorPrimary();
526-
$textColor = $this->themingDefaults->getTextColorPrimary();
526+
$textColor = $this->themingDefaults->getDefaultTextColorPrimary();
527527

528528
$this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]);
529529
$this->plainBody .= PHP_EOL . $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
@@ -554,7 +554,7 @@ public function addBodyButton(string $text, string $url, $plainText = ''): void
554554
}
555555

556556
$color = $this->themingDefaults->getDefaultColorPrimary();
557-
$textColor = $this->themingDefaults->getTextColorPrimary();
557+
$textColor = $this->themingDefaults->getDefaultTextColorPrimary();
558558
$this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]);
559559

560560
if ($plainText !== false) {

tests/lib/Mail/EMailTemplateTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function setUp(): void {
4747

4848
public function testEMailTemplateCustomFooter(): void {
4949
$this->defaults
50-
->expects($this->any())
50+
->expects($this->atLeastOnce())
5151
->method('getDefaultColorPrimary')
5252
->willReturn('#0082c9');
5353
$this->defaults
@@ -59,8 +59,8 @@ public function testEMailTemplateCustomFooter(): void {
5959
->method('getName')
6060
->willReturn('TestCloud');
6161
$this->defaults
62-
->expects($this->any())
63-
->method('getTextColorPrimary')
62+
->expects($this->atLeastOnce())
63+
->method('getDefaultTextColorPrimary')
6464
->willReturn('#ffffff');
6565
$this->urlGenerator
6666
->expects($this->once())
@@ -88,7 +88,7 @@ public function testEMailTemplateCustomFooter(): void {
8888

8989
public function testEMailTemplateDefaultFooter(): void {
9090
$this->defaults
91-
->expects($this->any())
91+
->expects($this->atLeastOnce())
9292
->method('getDefaultColorPrimary')
9393
->willReturn('#0082c9');
9494
$this->defaults
@@ -104,8 +104,8 @@ public function testEMailTemplateDefaultFooter(): void {
104104
->method('getLogo')
105105
->willReturn('/img/logo-mail-header.png');
106106
$this->defaults
107-
->expects($this->any())
108-
->method('getTextColorPrimary')
107+
->expects($this->atLeastOnce())
108+
->method('getDefaultTextColorPrimary')
109109
->willReturn('#ffffff');
110110
$this->urlGenerator
111111
->expects($this->once())
@@ -131,7 +131,7 @@ public function testEMailTemplateDefaultFooter(): void {
131131

132132
public function testEMailTemplateSingleButton(): void {
133133
$this->defaults
134-
->expects($this->any())
134+
->expects($this->atLeastOnce())
135135
->method('getDefaultColorPrimary')
136136
->willReturn('#0082c9');
137137
$this->defaults
@@ -147,8 +147,8 @@ public function testEMailTemplateSingleButton(): void {
147147
->method('getLogo')
148148
->willReturn('/img/logo-mail-header.png');
149149
$this->defaults
150-
->expects($this->any())
151-
->method('getTextColorPrimary')
150+
->expects($this->atLeastOnce())
151+
->method('getDefaultTextColorPrimary')
152152
->willReturn('#ffffff');
153153
$this->urlGenerator
154154
->expects($this->once())
@@ -176,7 +176,7 @@ public function testEMailTemplateSingleButton(): void {
176176

177177
public function testEMailTemplateAlternativePlainTexts(): void {
178178
$this->defaults
179-
->expects($this->any())
179+
->expects($this->atLeastOnce())
180180
->method('getDefaultColorPrimary')
181181
->willReturn('#0082c9');
182182
$this->defaults
@@ -192,8 +192,8 @@ public function testEMailTemplateAlternativePlainTexts(): void {
192192
->method('getLogo')
193193
->willReturn('/img/logo-mail-header.png');
194194
$this->defaults
195-
->expects($this->any())
196-
->method('getTextColorPrimary')
195+
->expects($this->atLeastOnce())
196+
->method('getDefaultTextColorPrimary')
197197
->willReturn('#ffffff');
198198
$this->urlGenerator
199199
->expects($this->once())

0 commit comments

Comments
 (0)