mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 00:48:32 +01:00
set contact name, use website_email instead of website_from in alias endpoint
This commit is contained in:
parent
c686767d4d
commit
d1e5b9f9b7
2 changed files with 7 additions and 7 deletions
|
@ -14,6 +14,7 @@ from app.dashboard.views.index import (
|
||||||
get_alias_infos_with_pagination,
|
get_alias_infos_with_pagination,
|
||||||
get_alias_info,
|
get_alias_info,
|
||||||
)
|
)
|
||||||
|
from app.email_utils import parseaddr_unicode
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import Alias, Contact
|
from app.models import Alias, Contact
|
||||||
|
@ -166,11 +167,11 @@ def get_alias_activities(alias_id):
|
||||||
}
|
}
|
||||||
if alias_log.is_reply:
|
if alias_log.is_reply:
|
||||||
activity["from"] = alias_log.alias
|
activity["from"] = alias_log.alias
|
||||||
activity["to"] = alias_log.website_from or alias_log.website_email
|
activity["to"] = alias_log.website_email
|
||||||
activity["action"] = "reply"
|
activity["action"] = "reply"
|
||||||
else:
|
else:
|
||||||
activity["to"] = alias_log.alias
|
activity["to"] = alias_log.alias
|
||||||
activity["from"] = alias_log.website_from or alias_log.website_email
|
activity["from"] = alias_log.website_email
|
||||||
|
|
||||||
if alias_log.bounced:
|
if alias_log.bounced:
|
||||||
activity["action"] = "bounced"
|
activity["action"] = "bounced"
|
||||||
|
@ -244,7 +245,7 @@ def serialize_contact(contact: Contact) -> dict:
|
||||||
"creation_timestamp": contact.created_at.timestamp,
|
"creation_timestamp": contact.created_at.timestamp,
|
||||||
"last_email_sent_date": None,
|
"last_email_sent_date": None,
|
||||||
"last_email_sent_timestamp": None,
|
"last_email_sent_timestamp": None,
|
||||||
"contact": contact.website_from or contact.website_email,
|
"contact": contact.website_email,
|
||||||
"reverse_alias": contact.website_send_to(),
|
"reverse_alias": contact.website_send_to(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,8 +341,7 @@ def create_contact_route(alias_id):
|
||||||
if not Contact.get_by(reply_email=reply_email):
|
if not Contact.get_by(reply_email=reply_email):
|
||||||
break
|
break
|
||||||
|
|
||||||
_, contact_email = parseaddr(contact_addr)
|
contact_name, contact_email = parseaddr_unicode(contact_addr)
|
||||||
contact_email = contact_email.lower()
|
|
||||||
|
|
||||||
# already been added
|
# already been added
|
||||||
if Contact.get_by(alias_id=alias.id, website_email=contact_email):
|
if Contact.get_by(alias_id=alias.id, website_email=contact_email):
|
||||||
|
@ -351,7 +351,7 @@ def create_contact_route(alias_id):
|
||||||
user_id=alias.user_id,
|
user_id=alias.user_id,
|
||||||
alias_id=alias.id,
|
alias_id=alias.id,
|
||||||
website_email=contact_email,
|
website_email=contact_email,
|
||||||
website_from=contact_addr,
|
name=contact_name,
|
||||||
reply_email=reply_email,
|
reply_email=reply_email,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ def test_create_contact_route(flask_client):
|
||||||
)
|
)
|
||||||
|
|
||||||
assert r.status_code == 201
|
assert r.status_code == 201
|
||||||
assert r.json["contact"] == "First Last <first@example.com>"
|
assert r.json["contact"] == "first@example.com"
|
||||||
assert "creation_date" in r.json
|
assert "creation_date" in r.json
|
||||||
assert "creation_timestamp" in r.json
|
assert "creation_timestamp" in r.json
|
||||||
assert r.json["last_email_sent_date"] is None
|
assert r.json["last_email_sent_date"] is None
|
||||||
|
|
Loading…
Reference in a new issue