mirror of
https://github.com/simple-login/app.git
synced 2025-02-23 23:34:05 +08:00
Add default field to GET /api/mailboxes
This commit is contained in:
parent
0367ab0e78
commit
78d9a88328
3 changed files with 18 additions and 5 deletions
|
@ -1138,18 +1138,20 @@ Input:
|
|||
- `Authentication` header that contains the api key
|
||||
|
||||
Output:
|
||||
List of mailboxes. Each mailbox has id, email field.
|
||||
List of mailboxes. Each mailbox has id, email, default field
|
||||
|
||||
```json
|
||||
{
|
||||
"mailboxes": [
|
||||
{
|
||||
"email": "a@b.c",
|
||||
"id": 1
|
||||
"id": 1,
|
||||
"default": true
|
||||
},
|
||||
{
|
||||
"email": "m1@example.com",
|
||||
"id": 2
|
||||
"id": 2,
|
||||
"default": false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -161,12 +161,20 @@ def get_mailboxes():
|
|||
- mailboxes: list of alias:
|
||||
- id
|
||||
- email
|
||||
- default: boolean - whether the mailbox is the default one
|
||||
"""
|
||||
user = g.user
|
||||
|
||||
return (
|
||||
jsonify(
|
||||
mailboxes=[{"id": mb.id, "email": mb.email} for mb in user.mailboxes()]
|
||||
mailboxes=[
|
||||
{
|
||||
"id": mb.id,
|
||||
"email": mb.email,
|
||||
"default": user.default_mailbox_id == mb.id,
|
||||
}
|
||||
for mb in user.mailboxes()
|
||||
]
|
||||
),
|
||||
200,
|
||||
)
|
||||
|
|
|
@ -182,6 +182,9 @@ def test_get_mailboxes(flask_client):
|
|||
assert r.status_code == 200
|
||||
# m2@example.com is not returned as it's not verified
|
||||
assert r.json == {
|
||||
"mailboxes": [{"email": "a@b.c", "id": 1}, {"email": "m1@example.com", "id": 2}]
|
||||
"mailboxes": [
|
||||
{"email": "a@b.c", "id": 1, "default": True},
|
||||
{"email": "m1@example.com", "id": 2, "default": False},
|
||||
]
|
||||
}
|
||||
print(json.dumps(r.json, indent=2))
|
||||
|
|
Loading…
Reference in a new issue