• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #12979

pending completion
#12979

push

circleci

web-flow
Merge pull request #2940 from mozilla/MNTOR-1468-trim-links

Remove spaces around links in email footer

282 of 1595 branches covered (17.68%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 1 file covered. (100.0%)

959 of 4308 relevant lines covered (22.26%)

1.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/views/emails/email-2022.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
import AppConstants from '../../app-constants.js'
6
import { getMessage } from '../../utils/fluent.js'
7

8
const companyAddress = '2 Harrison St. #175, San Francisco, California 94105 USA'
×
9
const links = (data) => ({
×
10
  faq: 'https://support.mozilla.org/kb/firefox-monitor-faq',
11
  hibp: 'https://haveibeenpwned.com/',
12
  legal: `https://www.mozilla.org/about/legal?utm_source=fx-monitor&utm_medium=email&utm_campaign=${data.utmCampaign}&utm_content=email-footer-link`,
13
  termsAndPrivacy: `https://www.mozilla.org/privacy/firefox-monitor?utm_source=fx-monitor&utm_medium=email&utm_campaign=${data.utmCampaign}&utm_content=email-footer-link`
14
})
15

16
const images = {
×
17
  header: `${AppConstants.SERVER_URL}/images/email/person-at-desk.png`,
18
  footer: `${AppConstants.SERVER_URL}/images/email/mozilla-logo-bw.png`,
19
  logoDark: `${AppConstants.SERVER_URL}/images/email/monitor-logo-transparent-dark-mode.png`,
20
  logoLight: `${AppConstants.SERVER_URL}/images/email/monitor-logo-bg-light.png`
21
}
22

23
const bodyStyle = `
×
24
  color: black;
25
  font: normal 16px/1.2 sans-serif;
26
`
27

28
const tableStyle = `
×
29
  margin: auto;
30
  max-width: 1080px;
31
  text-align: center;
32
  width: 100%;
33
`
34

35
const headerTableStyle = `
×
36
  background-color: #321c64;
37
  color: white;
38
  height: 331px;
39
  text-align: left;
40
  width: 100%;
41
`
42

43
const headerImageContainerStyle = `
×
44
  background-color: #321c64;
45
  vertical-align: bottom;
46
  width: 50%;
47
`
48

49
const headerImageStyle = `
×
50
  display: block;
51
  margin-left: auto;
52
  max-width: 100%;
53
  object-fit: cover;
54
  object-position: left;
55
`
56

57
const footerContainerStyle = `
×
58
  background: #f9f9fa;
59
  border-top: 1px solid #dddddd;
60
  padding: 24px 0;
61
`
62

63
const footerImageStyle = `
×
64
  display: block;
65
  margin: 24px auto 0;
66
`
67

68
const emailHeader = (data) => `
×
69
  <tr class='logo'>
70
    <td height='100'></td>
71
  </tr>
72
  <tr class='header'>
73
    <td>
74
      <table
75
        border='0'
76
        cellpadding='0'
77
        cellspacing='0'
78
        role='presentation'
79
        style='${headerTableStyle}'
80
      >
81
        <tr>
82
          <td>
83
            <h1>
84
              ${getMessage(data.heading)}
85
            </h1>
86
            ${data.subhead !== ''
×
87
              ? `<p>${getMessage(data.subhead)}</p>`
88
              : ''
89
            }
90
          </td>
91
          <td
92
            class='header-image'
93
            style='${headerImageContainerStyle}'
94
          >
95
            <img
96
              alt=''
97
              height='331'
98
              src='${images.header}'
99
              style='${headerImageStyle}'
100
              width='476'
101
            >
102
          </td>
103
        </tr>
104
      </table>
105
    </td>
106
  </tr>
107
`
108

109
function getUnsubscribeCopy (data) {
110
  const unsubLink = `<a href='${data.unsubscribeUrl}'>${getMessage('email-unsub-link')}</a>`
×
111
  const faqLink = `<a href='${links(data).faq}'>${getMessage('frequently-asked-questions')}</a>`
×
112

113
  return getMessage('email-footer-blurb', {
×
114
    unsubLink,
115
    faqLink
116
  })
117
}
118

119
const emailFooter = (data) => `
×
120
  <tr class='footer'>
121
    <td style='${footerContainerStyle}'>
122
      ${
123
        data.unsubscribeUrl
×
124
          ? `<p>${getUnsubscribeCopy(data)}</p>`
125
          : ''
126
      }
127
      <p>
128
        ${getMessage('email-2022-hibp-attribution', {
129
          'hibp-link-attr': `href='${links(data).hibp}' rel='noopener'`
130
        })}
131
      </p>
132
      <img
133
        alt='${getMessage('mozilla')}'
134
        src='${images.footer}'
135
        style='${footerImageStyle}'
136
        width='130px'
137
      >
138
      <p>
139
        ${companyAddress}
140
      </p>
141
      <p>
142
        <a href='${links(data).legal}'>
143
          ${getMessage('legal')}
144
        </a>
145
        ${' • '}
146
        <a href='${links(data).termsAndPrivacy}'>
147
          ${getMessage('terms-and-privacy')}
148
        </a>
149
      </p>
150
    </td>
151
  </tr>
152
`
153

154
const getStyles = () => `
×
155
  <style>
156
    .email-body,
157
    .email-body * {
158
      margin: 0;
159
      padding: 0;
160
    }
161

162
    body.email-body,
163
    .email-container {
164
      color: black;
165
      font: normal 16px/1.2 sans-serif;
166
    }
167

168
    .email-container h1,
169
    .email-container p {
170
      margin: 12px auto;
171
      max-width: 600px;
172
      padding: 0 24px;
173
    }
174

175
    .email-container a {
176
      color: #592acb;
177
      text-decoration: none;
178
    }
179

180
    .email-container table {
181
      table-layout: fixed;
182
    }
183

184
    .email-container .logo > td {
185
      height: 100px;
186
      background-color: #f9f9fa;
187
      background-position: 50%;
188
      background-image: url('${images.logoLight}');
189
      background-repeat: no-repeat;
190
      background-size: 240px 50px;
191
      width: 100%;
192
    }
193

194
    @media screen and (max-width:600px) {
195
      .email-container .header-image {
196
        display: none;
197
      }
198
    }
199

200
    @media (prefers-color-scheme: dark) {
201
      .email-container .logo > td {
202
        background-image: url('${images.logoDark}')
203
      }
204
    }
205
  </style>
206
`
207

208
const getEmailContent = (data, partial) => {
×
209
  return `
×
210
    <table
211
      border='0'
212
      class='email-container'
213
      cellpadding='0'
214
      cellspacing='0'
215
      role='presentation'
216
      style='${tableStyle}'
217
    >
218
      ${emailHeader({
219
        heading: data.heading,
220
        subhead: data.subheading ?? ''
×
221
      })}
222
      ${partial(data)}
223
      ${emailFooter(data)}
224
    </table>
225
  `
226
}
227

228
const getPreviewTemplate = (data, partial) => `
×
229
  ${getStyles()}
230
  ${getEmailContent(data, partial)}
231
`
232

233
const getTemplate = (data, partial) => {
×
234
  return `
×
235
    <!doctype html>
236
    <html>
237
      <head>
238
        <meta name='viewport' content='width=device-width, initial-scale=1.0' />
239
        <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
240

241
        <title>
242
          ${getMessage('brand-fx-monitor')}
243
        </title>
244

245
        ${getStyles()}
246
      </head>
247

248
      <body class='email-body' style='${bodyStyle}'>
249
        ${getEmailContent(data, partial)}
250
      </body>
251
    </html>
252
  `
253
}
254

255
export { getPreviewTemplate, getTemplate }
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc