mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Forward convertkit confirmation email
This commit is contained in:
parent
ae3ff6f34b
commit
9d753e3c0e
3 changed files with 293 additions and 4 deletions
|
|
@ -27,11 +27,21 @@ export class ConvertkitHandler extends ContentHandler {
|
|||
dom: Document
|
||||
}): Promise<boolean> {
|
||||
const dom = input.dom
|
||||
return Promise.resolve(
|
||||
dom.querySelectorAll(
|
||||
'img[src*="convertkit.com"], img[src*="convertkit-mail"]'
|
||||
).length > 0
|
||||
const icons = dom.querySelectorAll(
|
||||
'img[src*="convertkit.com"], img[src*="convertkit-mail"]'
|
||||
)
|
||||
if (icons.length === 0) {
|
||||
return Promise.resolve(false)
|
||||
}
|
||||
// ignore newsletters that have a confirmation link to the newsletter in the body
|
||||
const links = dom.querySelectorAll(
|
||||
'a[href*="convertkit.com"], a[href*="convertkit-mail"]'
|
||||
)
|
||||
const isConfirmation = Array.from(links).some((e) => {
|
||||
return e.textContent === 'Confirm your subscription'
|
||||
})
|
||||
|
||||
return Promise.resolve(!isConfirmation)
|
||||
}
|
||||
|
||||
async parseNewsletterUrl(
|
||||
|
|
|
|||
268
packages/content-handler/test/data/convertkit-confirmation.html
Normal file
268
packages/content-handler/test/data/convertkit-confirmation.html
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<style>
|
||||
email-button:hover {
|
||||
background-color: #0875c1;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body
|
||||
style="
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-ms-text-size-adjust: 100%;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
"
|
||||
>
|
||||
<div style="background-color: #efeff3">
|
||||
<table
|
||||
role="presentation"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
class="email"
|
||||
style="
|
||||
border-collapse: separate;
|
||||
mso-table-lspace: 0pt;
|
||||
mso-table-rspace: 0pt;
|
||||
background-color: #efeff3;
|
||||
width: 100%;
|
||||
"
|
||||
bgcolor="#efeff3"
|
||||
>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="vertical-align: top">
|
||||
<div
|
||||
class="email-container"
|
||||
style="
|
||||
margin: 0 auto;
|
||||
padding: 30px 0;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
max-width: 100%;
|
||||
padding-top: 30px;
|
||||
padding-left: 20px;
|
||||
padding-bottom: 30px;
|
||||
padding-right: 20px;
|
||||
margin: 0 auto;
|
||||
max-width: 100%;
|
||||
"
|
||||
>
|
||||
<!--[if mso]><center><table cellpadding="0" cellspacing="0" align="center" style="" width="600" bgcolor="#ffffff"><tr><td><![endif]-->
|
||||
<div
|
||||
style="
|
||||
background-color: #ffffff;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
max-width: 600;
|
||||
margin: 0px auto;
|
||||
"
|
||||
>
|
||||
<table
|
||||
bgcolor="#ffffff"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
width="100%"
|
||||
style="
|
||||
border-collapse: separate;
|
||||
mso-table-lspace: 0pt;
|
||||
mso-table-rspace: 0pt;
|
||||
"
|
||||
>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="vertical-align: top; padding: 20px">
|
||||
<div
|
||||
class="email-body"
|
||||
style="background-color: #ffffff"
|
||||
>
|
||||
<div class="email-content">
|
||||
<p
|
||||
style="
|
||||
margin: 1em 0;
|
||||
font-size: 18px;
|
||||
line-height: 1.5em;
|
||||
font-family: Georgia, Times, 'Times New Roman',
|
||||
serif;
|
||||
color: #3d3d3d;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
"
|
||||
>
|
||||
Thanks for signing up for the
|
||||
<em>Weekend Upgrade</em> newsletter! Click the
|
||||
link below to confirm your subscription and
|
||||
you'll be on your way.
|
||||
</p>
|
||||
<table
|
||||
maxwidth="100"
|
||||
width="100%"
|
||||
style="
|
||||
border-collapse: separate;
|
||||
mso-table-lspace: 0pt;
|
||||
mso-table-rspace: 0pt;
|
||||
"
|
||||
>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td
|
||||
align="left"
|
||||
style="vertical-align: top"
|
||||
>
|
||||
<a
|
||||
class="email-button"
|
||||
href="https://click.convertkit-mail2.com/d0uo2xqod0a5fm76qdtm/reh8hohqg8ogd5i2/aHR0cHM6Ly9hcHAuY29udmVydGtpdC5jb20vZm9ybXMvY29uZmlybT9rZXk9MTY0OTkzZWJlM2ViY2Y2YWMxMjFiMjU0M2M2ODEwNzUwNGRlOGY4ZSZzaWQ9NTIwOTgzNTkzNg=="
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style="
|
||||
color: #0875c1;
|
||||
margin-bottom: 0.5em;
|
||||
border: 0 none;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
background-color: #0875c1;
|
||||
color: #ffffff;
|
||||
border-radius: 4px;
|
||||
color: #ffffff;
|
||||
display: inline-block;
|
||||
background: #d71c1c;
|
||||
padding: 6px 12px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
border-radius: 4px;
|
||||
margin: 6px 0;
|
||||
"
|
||||
url-id="1496943150"
|
||||
>Confirm your subscription</a
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p
|
||||
style="
|
||||
margin: 1em 0;
|
||||
font-size: 18px;
|
||||
line-height: 1.5em;
|
||||
font-family: Georgia, Times, 'Times New Roman',
|
||||
serif;
|
||||
color: #3d3d3d;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
"
|
||||
>
|
||||
It's good to have you!
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="email-body-footer"
|
||||
style="
|
||||
border-top: 1px dotted #888;
|
||||
padding: 20px;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
color: #aaa;
|
||||
font-size: 12px;
|
||||
"
|
||||
>
|
||||
<p
|
||||
style="
|
||||
margin: 1em 0;
|
||||
font-size: 18px;
|
||||
line-height: 1.5em;
|
||||
font-family: Georgia, Times, 'Times New Roman',
|
||||
serif;
|
||||
color: #3d3d3d;
|
||||
font-size: 16px;
|
||||
line-height: 1.5;
|
||||
text-align: center;
|
||||
"
|
||||
>
|
||||
<a
|
||||
href="https://unsubscribe.convertkit-mail2.com/d0uo2xqod0a5fm76qdtm"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style="color: #0875c1"
|
||||
>Unsubscribe</a
|
||||
>
|
||||
|
|
||||
<a
|
||||
href="https://preferences.convertkit-mail2.com/d0uo2xqod0a5fm76qdtm"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style="color: #0875c1"
|
||||
>Update your profile</a
|
||||
>
|
||||
| 714 Venture Dr. #185, Morgantown, WV 26508
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="built-with"
|
||||
style="
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-top: 30px;
|
||||
"
|
||||
>
|
||||
<a
|
||||
href="https://click.convertkit-mail2.com/d0uo2xqod0a5fm76qdtm/l2hehmhkgg99mnb6/aHR0cHM6Ly9jb252ZXJ0a2l0LmNvbS9mZWF0dXJlcy9lbWFpbC1tYXJrZXRpbmc_dXRtX2NhbXBhaWduPXBvd2VyZWRieSZ1dG1fY29udGVudD1lbWFpbCZ1dG1fbWVkaXVtPXJlZmVycmFsJnV0bV9zb3VyY2U9ZHluYW1pYw=="
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
style="
|
||||
color: #0875c1;
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
"
|
||||
url-id="1337634290"
|
||||
><img
|
||||
src="https://cdn.convertkit.com/assets/light-built-with-badge.png"
|
||||
alt="Built with ConvertKit"
|
||||
style="
|
||||
display: block;
|
||||
height: auto;
|
||||
line-height: 100%;
|
||||
outline: none;
|
||||
-webkit-text-decoration: none;
|
||||
text-decoration: none;
|
||||
max-width: 100%;
|
||||
border: 0 none;
|
||||
width: 190px;
|
||||
height: 36px;
|
||||
"
|
||||
width="190"
|
||||
height="36"
|
||||
/></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--[if mso]></td></tr></table></center><![endif]-->
|
||||
</div>
|
||||
</td>
|
||||
<td style="vertical-align: top"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- -->
|
||||
<img
|
||||
src="https://open.convertkit-mail2.com/d0uo2xqod0a5fm76qdtm"
|
||||
alt=""
|
||||
style="
|
||||
border: 0 none;
|
||||
display: block;
|
||||
height: auto;
|
||||
line-height: 100%;
|
||||
outline: none;
|
||||
-webkit-text-decoration: none;
|
||||
text-decoration: none;
|
||||
max-width: 100%;
|
||||
"
|
||||
/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -246,6 +246,17 @@ describe('Newsletter email test', () => {
|
|||
})
|
||||
expect(handler).to.be.instanceOf(ConvertkitHandler)
|
||||
})
|
||||
|
||||
it('returns undefined for convertkit confirmation email', async () => {
|
||||
const html = load('./test/data/convertkit-confirmation.html')
|
||||
const handler = await getNewsletterHandler({
|
||||
html,
|
||||
postHeader: '',
|
||||
from: '',
|
||||
unSubHeader: '',
|
||||
})
|
||||
expect(handler).to.be.undefined
|
||||
})
|
||||
})
|
||||
|
||||
describe('findNewsletterUrl', async () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue