Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create and receive mozmail relay alias #993

Merged
merged 38 commits into from
Aug 24, 2021
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1af261e
Cast boolean to ADMIN_ENABLED var
say-yawn Jul 27, 2021
9a98ad0
Uniform method to get Relay email domain
say-yawn Jul 29, 2021
94b06cf
Add domain field in Relay Address model
say-yawn Jul 29, 2021
0ab81b7
Get the RelayAddress with appropriate domain
say-yawn Jul 29, 2021
c8a0310
Make RelayAddress with different domains
say-yawn Jul 29, 2021
3a45102
Delete RelayAddress and hash the domain
say-yawn Jul 29, 2021
2022c5b
Logger info
say-yawn Aug 5, 2021
e6cbcce
Use plus rather than append
say-yawn Aug 5, 2021
53c061e
Use mozmail.com based on env var
say-yawn Aug 5, 2021
2dc05d3
Pass domain in retries
say-yawn Aug 5, 2021
7742448
Use index to grab first item
say-yawn Aug 5, 2021
e89525a
Domain not in profile
say-yawn Aug 5, 2021
5480991
Get domain from relay address object
say-yawn Aug 5, 2021
2e08f7a
Remove loggers
say-yawn Aug 5, 2021
10d63fc
Pass domain portion for address hash
say-yawn Aug 12, 2021
7d1f550
Fix views tests on emails app
say-yawn Aug 12, 2021
55b43b2
Fix get email domain from settings
say-yawn Aug 12, 2021
b93e80f
Add get email domain test
say-yawn Aug 12, 2021
6080e2d
Get domain from relay address when copying
say-yawn Aug 12, 2021
42f78f7
Revert changes to deleted DomainAddress
say-yawn Aug 12, 2021
c7ac965
Test address hash with non-default domain
say-yawn Aug 12, 2021
1c76a38
Test domain field on RelayAddress
say-yawn Aug 12, 2021
9aa604f
Fix flake8 errors on emails
say-yawn Aug 12, 2021
92dce9c
Make static migration
say-yawn Aug 18, 2021
d525c8f
Move domains to utils
say-yawn Aug 18, 2021
75ba71f
Add domains environment variables to sample
say-yawn Aug 18, 2021
4b9ef53
Fix emails/views with new domains logic
say-yawn Aug 18, 2021
3c6c411
Remove unneeded code snippet
say-yawn Aug 18, 2021
36588a9
Test get_domains_from_settings
say-yawn Aug 18, 2021
000da4f
Return domain value on profile
say-yawn Aug 18, 2021
74dad3f
Fix broken tests
say-yawn Aug 18, 2021
ee9a67c
Use Firefox address on address_hash logic
say-yawn Aug 18, 2021
8cd6652
Enable mozmail for Mozillians
say-yawn Aug 18, 2021
b74c38b
Pass domain in the parameter
say-yawn Aug 20, 2021
bfc8c84
Display correct domain for alias
say-yawn Aug 24, 2021
279cd39
Use mozmail domain when TEST_MOZMAIL is True
say-yawn Aug 24, 2021
7d05ba2
Return domain of RelayAddress
say-yawn Aug 24, 2021
8673e35
Return full_address for RelayAddress
say-yawn Aug 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion emails/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def _index_POST(request):
)
return JsonResponse({
'id': relay_address.id,
'address': address_string
'address': address_string,
'domain': relay_addres.domain_value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to add the domain property to the response that's good, but this doesn't fix the issue, because the address_string is still '%s@%s where the 2nd string substitution is based on the relay_from_domain. So the add-on will need to:

  1. get the localpart from the address value by splitting it at the @ character
  2. append the domain part from the domain value

AND we will need to coordinate the release of the add-on with the additional parsing code with the release of the server code.

A better fix that de-couples the code-bases, but still extends the response in a way the add-on can use later:

diff --git a/emails/models.py b/emails/models.py
index 621589b..fb62ff0 100644
--- a/emails/models.py
+++ b/emails/models.py
@@ -272,6 +272,10 @@ class RelayAddress(models.Model):
     def domain_value(self):
         return DOMAINS.get(self.get_domain_display())
 
+    @property
+    def full_address(self):
+        return '%s@%s' % (self.address, self.domain_value)
+
 
 class DeletedAddress(models.Model):
     address_hash = models.CharField(max_length=64, db_index=True)
diff --git a/emails/views.py b/emails/views.py
index ec587a8..790c529 100644
--- a/emails/views.py
+++ b/emails/views.py
@@ -115,12 +115,10 @@ def _index_POST(request):
             return redirect('profile')
 
     if settings.SITE_ORIGIN not in request.headers.get('Origin', ''):
-        address_string = '%s@%s' % (
-            relay_address.address, relay_from_domain(request)['RELAY_DOMAIN']
-        )
         return JsonResponse({
             'id': relay_address.id,
-            'address': address_string
+            'address': relay_address.full_address,
+            'domain': relay_address.domain_value
         }, status=201)
 
     return redirect('profile')

}, status=201)

return redirect('profile')
Expand Down