From 9ee824576041a73065e3aed5928703f6b296b8b2 Mon Sep 17 00:00:00 2001 From: Son NK Date: Fri, 20 Mar 2020 09:54:38 +0100 Subject: [PATCH] make sure to set user_id when creating contact --- app/api/views/alias.py | 1 + app/dashboard/views/alias_contact_manager.py | 1 + email_handler.py | 1 + tests/api/test_alias.py | 3 +++ 4 files changed, 6 insertions(+) diff --git a/app/api/views/alias.py b/app/api/views/alias.py index 46ae5e04..52dfa7e6 100644 --- a/app/api/views/alias.py +++ b/app/api/views/alias.py @@ -320,6 +320,7 @@ def create_contact_route(alias_id): return jsonify(error="Contact already added"), 409 contact = Contact.create( + user_id=alias.user_id, alias_id=alias.id, website_email=website_email, website_from=contact_email, diff --git a/app/dashboard/views/alias_contact_manager.py b/app/dashboard/views/alias_contact_manager.py index 2e0affd0..6bb4828e 100644 --- a/app/dashboard/views/alias_contact_manager.py +++ b/app/dashboard/views/alias_contact_manager.py @@ -87,6 +87,7 @@ def alias_contact_manager(alias_id, contact_id=None): ) contact = Contact.create( + user_id=alias.user_id, alias_id=alias.id, website_email=website_email, website_from=contact_email, diff --git a/email_handler.py b/email_handler.py index b15ade4e..d8aaf810 100644 --- a/email_handler.py +++ b/email_handler.py @@ -236,6 +236,7 @@ def get_or_create_contact(website_from_header: str, alias: Alias) -> Contact: reply_email = f"reply+{random_string(30)}@{EMAIL_DOMAIN}" contact = Contact.create( + user_id=alias.user_id, alias_id=alias.id, website_email=website_email, website_from=website_from_header, diff --git a/tests/api/test_alias.py b/tests/api/test_alias.py index 7b067eac..f83a643c 100644 --- a/tests/api/test_alias.py +++ b/tests/api/test_alias.py @@ -164,6 +164,7 @@ def test_alias_activities(flask_client): website_email="marketing@example.com", reply_email="reply@a.b", alias_id=alias.id, + user_id=alias.user_id, ) db.session.commit() @@ -236,6 +237,7 @@ def test_alias_contacts(flask_client): website_email=f"marketing-{i}@example.com", reply_email=f"reply-{i}@a.b", alias_id=alias.id, + user_id=alias.user_id, ) db.session.commit() @@ -318,6 +320,7 @@ def test_delete_contact(flask_client): alias_id=alias.id, website_email="contact@example.com", reply_email="reply+random@sl.io", + user_id=alias.user_id, ) db.session.commit()