浏览代码

return nb_alias in GET /mailboxes

Son NK 5 年之前
父节点
当前提交
48998ff07e
共有 3 个文件被更改,包括 7 次插入4 次删除
  1. 4 2
      README.md
  2. 2 0
      app/api/views/mailbox.py
  3. 1 2
      tests/api/test_mailbox.py

+ 4 - 2
README.md

@@ -1147,13 +1147,15 @@ List of mailboxes. Each mailbox has id, email, default, creation_timestamp field
       "email": "a@b.c",
       "id": 1,
       "default": true,
-      "creation_timestamp": 1590918512
+      "creation_timestamp": 1590918512,
+      "nb_alias": 10
     },
     {
       "email": "m1@example.com",
       "id": 2,
       "default": false,
-      "creation_timestamp": 1590918512
+      "creation_timestamp": 1590918512,
+      "nb_alias": 0
     }
   ]
 }

+ 2 - 0
app/api/views/mailbox.py

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

+ 1 - 2
tests/api/test_mailbox.py

@@ -187,5 +187,4 @@ def test_get_mailboxes(flask_client):
         assert "id" in mb
         assert "default" in mb
         assert "creation_timestamp" in mb
-
-    print(r.json)
+        assert "nb_alias" in mb