return creation_timestamp in GET /mailboxes

This commit is contained in:
Son NK 2020-05-31 11:49:53 +02:00
parent 28287ff93e
commit 0530a8aab5
3 changed files with 15 additions and 10 deletions

View file

@ -1138,7 +1138,7 @@ Input:
- `Authentication` header that contains the api key - `Authentication` header that contains the api key
Output: Output:
List of mailboxes. Each mailbox has id, email, default field List of mailboxes. Each mailbox has id, email, default, creation_timestamp field
```json ```json
{ {
@ -1146,12 +1146,14 @@ List of mailboxes. Each mailbox has id, email, default field
{ {
"email": "a@b.c", "email": "a@b.c",
"id": 1, "id": 1,
"default": true "default": true,
"creation_timestamp": 1590918512
}, },
{ {
"email": "m1@example.com", "email": "m1@example.com",
"id": 2, "id": 2,
"default": false "default": false,
"creation_timestamp": 1590918512
} }
] ]
} }

View file

@ -162,6 +162,7 @@ def get_mailboxes():
- id - id
- email - email
- default: boolean - whether the mailbox is the default one - default: boolean - whether the mailbox is the default one
- creation_timestamp
""" """
user = g.user user = g.user
@ -172,6 +173,7 @@ def get_mailboxes():
"id": mb.id, "id": mb.id,
"email": mb.email, "email": mb.email,
"default": user.default_mailbox_id == mb.id, "default": user.default_mailbox_id == mb.id,
"creation_timestamp": mb.created_at.timestamp,
} }
for mb in user.mailboxes() for mb in user.mailboxes()
] ]

View file

@ -181,10 +181,11 @@ def test_get_mailboxes(flask_client):
) )
assert r.status_code == 200 assert r.status_code == 200
# m2@example.com is not returned as it's not verified # m2@example.com is not returned as it's not verified
assert r.json == { assert len(r.json["mailboxes"]) == 2
"mailboxes": [ for mb in r.json["mailboxes"]:
{"email": "a@b.c", "id": 1, "default": True}, assert "email" in mb
{"email": "m1@example.com", "id": 2, "default": False}, assert "id" in mb
] assert "default" in mb
} assert "creation_timestamp" in mb
print(json.dumps(r.json, indent=2))
print(r.json)