Quellcode durchsuchen

return alias name in GET /api/v2/aliases

Son NK vor 5 Jahren
Ursprung
Commit
63af3297f7
3 geänderte Dateien mit 6 neuen und 0 gelöschten Zeilen
  1. 3 0
      README.md
  2. 1 0
      app/api/serializer.py
  3. 2 0
      tests/api/test_alias.py

+ 3 - 0
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": {

+ 1 - 0
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,

+ 2 - 0
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"]