From 63af3297f735c21bea3372eca9cbee9f27c2abff Mon Sep 17 00:00:00 2001 From: Son NK Date: Sun, 26 Apr 2020 10:38:58 +0200 Subject: [PATCH] return alias name in GET /api/v2/aliases --- README.md | 3 +++ app/api/serializer.py | 1 + tests/api/test_alias.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 3283c5e9..1324843b 100644 --- a/README.md +++ b/README.md @@ -870,6 +870,7 @@ If success, 200 with the list of aliases. Each alias has the following fields: - id - email +- name - enabled - creation_timestamp - note @@ -896,6 +897,7 @@ Here's an example: "creation_date": "2020-04-06 17:57:14+00:00", "creation_timestamp": 1586195834, "email": "prefix1.cat@sl.local", + "name": "A Name", "enabled": true, "id": 3, "mailbox": { @@ -920,6 +922,7 @@ Here's an example: "creation_date": "2020-04-06 17:57:14+00:00", "creation_timestamp": 1586195834, "email": "prefix0.hey@sl.local", + "name": null, "enabled": true, "id": 2, "mailbox": { diff --git a/app/api/serializer.py b/app/api/serializer.py index edd0dfc2..58d44d5a 100644 --- a/app/api/serializer.py +++ b/app/api/serializer.py @@ -47,6 +47,7 @@ def serialize_alias_info_v2(alias_info: AliasInfo) -> dict: "creation_timestamp": alias_info.alias.created_at.timestamp, "enabled": alias_info.alias.enabled, "note": alias_info.alias.note, + "name": alias_info.alias.name, # activity "nb_forward": alias_info.nb_forward, "nb_block": alias_info.nb_blocked, diff --git a/tests/api/test_alias.py b/tests/api/test_alias.py index 3992f831..a1e32138 100644 --- a/tests/api/test_alias.py +++ b/tests/api/test_alias.py @@ -155,6 +155,7 @@ def test_get_aliases_v2(flask_client): # "email": "prefix1.yeah@sl.local", # "enabled": true, # "id": 3, + # "name": "Hey hey", # "latest_activity": { # "action": "forward", # "contact": { @@ -173,6 +174,7 @@ def test_get_aliases_v2(flask_client): # "nb_reply": 0, # "note": null # } + assert "name" in r0 assert r0["email"].startswith("prefix1") assert r0["latest_activity"]["action"] == "forward" assert "timestamp" in r0["latest_activity"]