Merge pull request #209 from mozilla/start-email-wrapping-56

wip: start wrapped_email.html
This commit is contained in:
luke crouch 2020-05-20 12:39:01 -05:00 коммит произвёл GitHub
Родитель 7823c224b3 8774ad7f00
Коммит 21eaaf8494
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 90 добавлений и 1 удалений

Просмотреть файл

@ -14,6 +14,7 @@ SOCKETLABS_SECRET_KEY="dummy-value"
SOCKETLABS_API_KEY="dummy-value"
SOCKETLABS_VALIDATION_KEY="dummy-value"
RELAY_FROM_ADDRESS="localhost relay <relay@127.0.0.1:8000>"
SITE_ORIGIN="http://127.0.0.1:8000"
TWILIO_ACCOUNT_SID=
TWILIO_AUTH_TOKEN=
TWILIO_SERVICE_ID=

Просмотреть файл

@ -0,0 +1,74 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width"/>
<title>Firefox Private Relay</title>
<style>
* {
box-sizing: border-box;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif !important;
}
a {
text-decoration: none;
color: #6200a4;
}
a:hover,
a:focus,
a:active {
transition: all 0.2s ease;
}
.relay-text {
line-height: 1.5;
}
.visit-dashboard {
background-color: rgb(237, 237, 240);
}
.visit-dashboard:hover,
.visit-dashboard:focus {
background-color: rgba(215, 215, 219, 1);
}
.visit-dashboard:active {
background-color: rgba(177, 177, 179, 1);
}
</style>
</head>
<body style="padding: 0; margin: 0;">
<table width="100%" bgcolor="#f9f9fa" style="background: #f9f9fa; padding-top: 0; padding-right: 30px; padding-left: 30px; padding-bottom: 40px; margin-top: 0px; margin-bottom: 30px; width: 100%;">
<tr>
<td align="center" valign="top" width="100%" style="width: 100%; max-width: 550px; padding-top: 20px;">
<table width="100%" style="text-align: center; border-collapse: collapse; max-width: 550px;">
<tr>
<td align="center" style="margin-top: 0">
<img width="100%" src="{{ SITE_ORIGIN }}/static/images/private-relay-beta-logo-emails.png" style="display: inline-block; margin-bottom: 0px; width:100%; max-width: 280px;" alt="Private Relay Logo" />
</td>
</tr>
<tr>
<td align="center">
<p class="relay-text" style="color: #4a4a4f; font-size: 14px; line-height: 150%; font-family: sans-serif;">This email was sent to your alias <span style="font-weight: bolder; color: #6200a4;">{{ display_email|safe }}</span>. To stop receiving emails sent to this alias, update the forwarding settings in your dashboard.</p>
</td>
</tr>
<tr>
<td width="100%" valign="center" align="center" style="text-align: center; padding-top: 20px;">
<a
class="visit-dashboard"
href="{{ SITE_ORIGIN }}/accounts/profile/?utm_source=emails&utm_medium=email&utm_campaign=alias-email"
style="text-align: center; border-radius: 4px; position: relative; padding-top: 8px; padding-bottom: 8px; padding-left: 16px; padding-right: 16px; text-decoration: none; color: #6200a4; font-family: sans-serif; font-weight: bolder; font-size: 16px;"
target="_blank">
Visit Dashboard
</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
{{ original_html|safe }}
</body>
</html>

Просмотреть файл

@ -5,6 +5,7 @@ from hashlib import sha256
import json
import logging
import markus
import re
from decouple import config
from socketlabs.injectionapi import SocketLabsClient
@ -16,6 +17,7 @@ from django.contrib import messages
from django.core.exceptions import PermissionDenied
from django.http import HttpResponse, JsonResponse
from django.shortcuts import redirect, render, get_object_or_404
from django.template.loader import render_to_string
from django.views.decorators.csrf import csrf_exempt
from .context_processors import relay_from_domain
@ -178,8 +180,19 @@ def _inbound_logic(json_body):
# Forward to real email address
sl_message = BasicMessage()
sl_message.subject = subject
sl_message.html_body = html
# scramble alias so that clients don't recognize it and apply default link styles
display_email = re.sub('([@.:])', r'<span>\1</span>', email_to)
wrapped_html = render_to_string('emails/wrapped_email.html', {
'original_html': html,
'email_to': email_to,
'display_email': display_email,
'SITE_ORIGIN': settings.SITE_ORIGIN,
})
sl_message.html_body = wrapped_html
sl_message.plain_text_body = text
relay_from_address, relay_from_display = _generate_relay_From(from_address)
sl_message.from_email_address = EmailAddress(
relay_from_address, relay_from_display

Просмотреть файл

@ -100,6 +100,7 @@ SOCKETLABS_API_KEY = config('SOCKETLABS_API_KEY', None)
SOCKETLABS_SECRET_KEY = config('SOCKETLABS_SECRET_KEY', None)
SOCKETLABS_VALIDATION_KEY = config('SOCKETLABS_VALIDATION_KEY', None)
RELAY_FROM_ADDRESS = config('RELAY_FROM_ADDRESS', None)
SITE_ORIGIN = config('SITE_ORIGIN', None)
TWILIO_ACCOUNT_SID = config('TWILIO_ACCOUNT_SID', None)
TWILIO_AUTH_TOKEN = config('TWILIO_AUTH_TOKEN', None)

Двоичные данные
static/images/private-relay-beta-logo-emails.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.3 KiB