Support setting alias name in POST /api/v3/alias/custom/new

This commit is contained in:
Son NK 2020-06-03 21:22:29 +02:00
parent d76aad3f17
commit 9fc0748fcc
3 changed files with 6 additions and 0 deletions

View File

@ -835,6 +835,7 @@ Input:
- signed_suffix: should be one of the suffixes returned in the `GET /api/v4/alias/options` endpoint.
- mailbox_ids: list of mailbox_id that "owns" this alias
- (Optional) note: alias note
- (Optional) name: alias name
Output:
If success, 201 with the new alias info. Use the same format as in GET /api/aliases/:alias_id

View File

@ -204,6 +204,7 @@ def new_custom_alias_v3():
mailbox_ids: list of int
optional "hostname" in args
optional "note"
optional "name"
Output:
201 if success
@ -231,6 +232,7 @@ def new_custom_alias_v3():
signed_suffix = data.get("signed_suffix", "").strip()
mailbox_ids = data.get("mailbox_ids")
note = data.get("note")
name = data.get("name")
alias_prefix = convert_to_id(alias_prefix)
# check if mailbox is not tempered with
@ -277,6 +279,7 @@ def new_custom_alias_v3():
user_id=user.id,
email=full_alias,
note=note,
name=name or None,
mailbox_id=mailboxes[0].id,
custom_domain_id=custom_domain_id,
)

View File

@ -211,6 +211,7 @@ def test_success_v3(flask_client):
"signed_suffix": suffix,
"note": "test note",
"mailbox_ids": [user.default_mailbox_id, mb.id],
"name": "your name"
},
)
@ -228,6 +229,7 @@ def test_success_v3(flask_client):
assert "nb_reply" in res
assert "enabled" in res
assert "note" in res
assert res["name"] == "your name"
new_alias: Alias = Alias.get_by(email=r.json["alias"])
assert new_alias.note == "test note"